opentelemetry-java icon indicating copy to clipboard operation
opentelemetry-java copied to clipboard

Add scope attribute setter on MeterBuilder, TracerBuilder, LogEmitterBuilder

Open jack-berg opened this issue 2 years ago • 1 comments

Related to #4695.

jack-berg avatar Aug 22 '22 17:08 jack-berg

This PR was marked stale due to lack of activity. It will be closed in 14 days.

github-actions[bot] avatar Sep 07 '22 20:09 github-actions[bot]

This PR was marked stale due to lack of activity. It will be closed in 14 days.

github-actions[bot] avatar Sep 21 '22 22:09 github-actions[bot]

Now that https://github.com/open-telemetry/opentelemetry-specification/pull/2789 was merged, should the attributes field be removed from InstrumentationScopeInfo equals()/hashCode() methods?

mateuszrzeszutek avatar Sep 22 '22 08:09 mateuszrzeszutek

@mateuszrzeszutek addressing that has been on my todo list! It minimally needs to be reflected in the ComponentRegistry's key definition of what constitutes a distinct instrumentation scope, which currently uses InstrumentationScopeInfo equals()/hashCode().

However, I think we can keep InstrumentationScopeInfo equals()/hashCode() as is. InstrumentationScopeInfo is a record class, and although spec API / SDK defines a definition of of tracer / meter / logger uniqueness which excludes scope attributes, that feels like an internal implementation detail which doesn't need to bubble up to the public API. It's still useful to have a equals / hashcode definition which reflects equality in the traditional java sense, where all fields are considered.

jack-berg avatar Sep 23 '22 18:09 jack-berg

Codecov Report

Base: 90.92% // Head: 90.93% // Increases project coverage by +0.00% :tada:

Coverage data is based on head (0f64b36) compared to base (f8a4d81). Patch coverage: 92.30% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #4711   +/-   ##
=========================================
  Coverage     90.92%   90.93%           
- Complexity     4816     4821    +5     
=========================================
  Files           545      547    +2     
  Lines         14382    14391    +9     
  Branches       1382     1382           
=========================================
+ Hits          13077    13086    +9     
- Misses          898      899    +1     
+ Partials        407      406    -1     
Impacted Files Coverage Δ
.../opentelemetry/api/logs/DefaultLoggerProvider.java 84.61% <0.00%> (-7.06%) :arrow_down:
...ava/io/opentelemetry/api/metrics/MeterBuilder.java 100.00% <100.00%> (ø)
...java/io/opentelemetry/api/trace/TracerBuilder.java 100.00% <100.00%> (ø)
...va/io/opentelemetry/sdk/logs/SdkLoggerBuilder.java 100.00% <100.00%> (ø)
.../io/opentelemetry/sdk/metrics/SdkMeterBuilder.java 100.00% <100.00%> (ø)
...a/io/opentelemetry/sdk/trace/SdkTracerBuilder.java 100.00% <100.00%> (ø)
...metry/sdk/metrics/export/PeriodicMetricReader.java 87.14% <0.00%> (-2.86%) :arrow_down:
...telemetry/sdk/trace/export/BatchSpanProcessor.java 93.10% <0.00%> (+2.06%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Sep 23 '22 19:09 codecov[bot]

This PR was marked stale due to lack of activity. It will be closed in 14 days.

github-actions[bot] avatar Oct 17 '22 10:10 github-actions[bot]

This PR was marked stale due to lack of activity. It will be closed in 14 days.

github-actions[bot] avatar Nov 03 '22 04:11 github-actions[bot]

@jkwatson can you take a look when you have a chance?

jack-berg avatar Nov 08 '22 23:11 jack-berg

This PR was marked stale due to lack of activity. It will be closed in 14 days.

github-actions[bot] avatar Nov 23 '22 00:11 github-actions[bot]

We had discussed during the SIG meeting that perhaps what we need is a scope object we can set on the builder, rather than having to do it piecemeal.

jkwatson avatar Nov 23 '22 04:11 jkwatson

This PR was marked stale due to lack of activity. It will be closed in 14 days.

github-actions[bot] avatar Dec 07 '22 06:12 github-actions[bot]

We had discussed during the SIG meeting that perhaps what we need is a scope object we can set on the builder, rather than having to do it piecemeal.

@jkwatson I think we should close this until users ask for it. Adding a scope object is nice from an API ergonomics perspective, but means that we'll have a 3rd class floating around representing a scope-like thing: InstrumentationScopeInfo, the deprecated InstrumentationLibraryInfo, and whatever we call this new scope. InstrumentationScopeInfo would do the trick but we can't move InstrumentationScopeInfo to the API module without a breaking change.

jack-berg avatar Dec 07 '22 13:12 jack-berg

We had discussed during the SIG meeting that perhaps what we need is a scope object we can set on the builder, rather than having to do it piecemeal.

@jkwatson I think we should close this until users ask for it. Adding a scope object is nice from an API ergonomics perspective, but means that we'll have a 3rd class floating around representing a scope-like thing: InstrumentationScopeInfo, the deprecated InstrumentationLibraryInfo, and whatever we call this new scope. InstrumentationScopeInfo would do the trick but we can't move InstrumentationScopeInfo to the API module without a breaking change.

Sounds fine to me. Just thinking out loud here, but could we create a Scope interface in the API that is additionally implemented by InstrumentationScopeInfo? Or would that not add much value?

jkwatson avatar Dec 07 '22 14:12 jkwatson

Sounds fine to me. Just thinking out loud here, but could we create a Scope interface in the API that is additionally implemented by InstrumentationScopeInfo? Or would that not add much value?

I don't think it would add much value because the consumers of these are totally different. The caller of the API is an instrumentation author, and the consumer of scope in the SDK is probably someone writing an exporter. Would want something to keep the two implementations in sync with each other, but hard for it to not feel awkward.

jack-berg avatar Dec 13 '22 22:12 jack-berg