-
Notifications
You must be signed in to change notification settings - Fork 834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge the current Resource object with custom Resource Object. #5619
Conversation
7e88457
to
89a4c02
Compare
sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLoggerProviderBuilder.java
Outdated
Show resolved
Hide resolved
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #5619 +/- ##
============================================
- Coverage 91.31% 91.23% -0.08%
+ Complexity 4982 4980 -2
============================================
Files 554 554
Lines 14749 14758 +9
Branches 1376 1376
============================================
- Hits 13468 13465 -3
- Misses 887 897 +10
- Partials 394 396 +2
☔ View full report in Codecov by Sentry. |
@open-telemetry/java-approvers https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md does not mention this use case - should it be added? |
The use case you describe in the PR description is already possible in a couple of different ways. You can add a resource customizer:
Or you can define a custom resource provider:
I don't think we need additional syntactic sugar to provide another way to achieve the same thing. |
Hi @jack-berg , IMO, this is the issue what you explain, this will update the resource at globle level (For all SdkProviderBuilder like Log, Metrics and Traces), but I want to customize the resource of any one of them (As an example SdkMeterProviderBuilder) then I think as of now there is no such a way, if it already exist then please provide your suggetion. |
I don't have a citation from the spec handy, but I'm pretty sure you should NOT be using different |
Hello @breedx-splk,
There is another way to archive this, public SdkTracerProviderBuilder addAttributes(Attributes attributes) {
if (!attributes.isEmpty()) {
this.resource = this.resource.toBuilder().putAll(attributes).build();
}
return this;
} But at the end have to add method to append the attributes from any of the way. |
@parth1601 see my comment in a related issue. In summary, I support the addition of this method, but generally don't recommend having a resource that differs by signal. The addition of this method would help alleviate accidental removal of the default resource attributes, which I'm supportive of. |
Should the new method(s) be called "mergeResource" or "addResource" do you think? |
Smallish +1 for addResource over mergeResource |
Changed the method name to addResource. |
@jkwatson take a look when you can. Would be good to get this in for the 1.29.0 release. |
Merge the current Resource object with custom Resource Object.
Issue
Solution
mergeResource
to the all SdkProviderBuilder that takes an object od Resource Class and merge with the current one.