Skip to content
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

Unify builders across signals #2220

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stormshield-fabs
Copy link
Contributor

Fixes #1527 #2164

Changes

The consensus reached during the SIG meeting is that we'd like to unify the builder APIs across signals, limit duplication and keep our traits object-safe. Proposed changed :

  • remove the Logger and Tracer builders that were only used to wrap the InstrumentationLibrary builder
  • remove the deprecated versioned_ methods on providers
  • reduce the public API to Provider::signal(name: &str) and Provider::library_signal(library: Arc<InstrumentationLibrary>)

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 86.02151% with 13 lines in your changes missing coverage. Please review.

Project coverage is 79.4%. Comparing base (4852a5e) to head (414af83).

Files with missing lines Patch % Lines
opentelemetry-zipkin/src/exporter/mod.rs 0.0% 10 Missing ⚠️
opentelemetry/src/global/metrics.rs 0.0% 2 Missing ⚠️
opentelemetry/src/metrics/noop.rs 0.0% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #2220     +/-   ##
=======================================
+ Coverage   79.3%   79.4%   +0.1%     
=======================================
  Files        121     121             
  Lines      20944   20773    -171     
=======================================
- Hits       16612   16499    -113     
+ Misses      4332    4274     -58     

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

@stormshield-fabs
Copy link
Contributor Author

There were some concerns about having Arc in the library_signal APIs, but someone also mentioned we want to avoid unnecessary copies. We could hide the Arc inside the InstrumentationLibrary if needed.

@@ -170,11 +170,10 @@ where
L: Logger + Send + Sync,
{
pub fn new(provider: &P) -> Self {
let library =
Arc::new(InstrumentationLibrary::builder("opentelemetry-log-appender").build());
Copy link
Member

Choose a reason for hiding this comment

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

lets keep the with_version as before.

let library = Arc::new(
InstrumentationLibrary::builder("basic")
.with_version("1.0")
.with_attributes(common_scope_attributes.clone())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.with_attributes(common_scope_attributes.clone())
.with_attributes(common_scope_attributes)

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

Left few comments but looks good overall.
Please check the comments and see if they make sense.

let library = Arc::new(
InstrumentationLibrary::builder("basic")
.with_version("1.0")
.with_attributes(common_scope_attributes.clone())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.with_attributes(common_scope_attributes.clone())
.with_attributes(common_scope_attributes)

);
let tracer = global::tracer_provider().library_tracer(library.clone());
Copy link
Member

Choose a reason for hiding this comment

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

wondering why tracing is done slightly differently than metric?

.with_schema_url("schema_url")
.with_attributes([KeyValue::new("scope_key", "scope_value")])
.build();
let library = Arc::new(
Copy link
Member

Choose a reason for hiding this comment

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

From a useability standpoint, I think its best to not require Arc here. Cloning InstrumentationLibrary should be cheap anyway.

/// Some("https://opentelemetry.io/schemas/1.2.0"),
/// Some(vec![KeyValue::new("key", "value")]),
/// let library = Arc::new(
/// InstrumentationLibrary::builder("io.opentelemetry")
Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#get-a-meter

I think we should rename InstrumentationLibrary to InstrumentationScope everywhere, as Scope is what user provides.

Copy link
Member

Choose a reason for hiding this comment

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

@lalitb @utpilla Please share your thoughts on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. InstrumentationScope also matches the term used in proto file.

Copy link
Member

@lalitb lalitb Oct 18, 2024

Choose a reason for hiding this comment

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

@cijothomas
Copy link
Member

There were some concerns about having Arc in the library_signal APIs, but someone also mentioned we want to avoid unnecessary copies. We could hide the Arc inside the InstrumentationLibrary if needed.

yes I suggest to hide Arc inside.

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.

Instrumentation scope - move to builder pattern?
4 participants