Skip to content

Decode plus sign in resource attributes#8059

Open
arnav-dasgupta wants to merge 4 commits intoopen-telemetry:mainfrom
arnav-dasgupta:decode-otel-resource-attributes-correctly
Open

Decode plus sign in resource attributes#8059
arnav-dasgupta wants to merge 4 commits intoopen-telemetry:mainfrom
arnav-dasgupta:decode-otel-resource-attributes-correctly

Conversation

@arnav-dasgupta
Copy link

@arnav-dasgupta arnav-dasgupta commented Feb 7, 2026

@arnav-dasgupta arnav-dasgupta requested a review from a team as a code owner February 7, 2026 06:10
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 7, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@arnav-dasgupta arnav-dasgupta force-pushed the decode-otel-resource-attributes-correctly branch from bec5b30 to a9964e9 Compare February 7, 2026 06:31
@codecov
Copy link

codecov bot commented Feb 7, 2026

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.22%. Comparing base (c45930b) to head (f947810).

Files with missing lines Patch % Lines
...metry/sdk/autoconfigure/ResourceConfiguration.java 95.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8059   +/-   ##
=========================================
  Coverage     90.21%   90.22%           
- Complexity     7605     7611    +6     
=========================================
  Files           841      841           
  Lines         22923    22936   +13     
  Branches       2291     2294    +3     
=========================================
+ Hits          20681    20695   +14     
+ Misses         1525     1523    -2     
- Partials        717      718    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

assertThat(
ResourceConfiguration.createEnvironmentResource(
DefaultConfigProperties.createFromMap(props)))
.isEqualTo(Resource.create(Attributes.of(stringKey("key"), "hello world")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you turn these into a parameterized test please? Improves the readability to see all the test cases neatly / compactly arranged next to each other.

Example available here: https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk/common/src/test/java/io/opentelemetry/sdk/common/internal/GlobUtilTest.java

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Followed the example and changed the test.

bytes[pos++] = (byte) c;
}
return new String(bytes, 0, pos, StandardCharsets.UTF_8);
} catch (RuntimeException e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What has the potential to throw here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Value being null can throw a NullPointer exception but other than that.. nothing. Have removed the try-catch as the method handles most (if not all) edge cases.

int d1 = Character.digit(value.charAt(i + 1), 16);
int d2 = Character.digit(value.charAt(i + 2), 16);
if (d1 != -1 && d2 != -1) {
bytes[pos++] = (byte) ((d1 << 4) + d2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining what's happening here and why it works? I've looked at it closely and have convinced myself its correct, but its a high cognitive load to understand so let's give future maintainers some help 🙂

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented the details in the method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants