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

Refactor/deprecate trace config #2303

Merged

Conversation

pitoniak32
Copy link
Contributor

@pitoniak32 pitoniak32 commented Nov 17, 2024

resolves: #2294

Changes

Moving away from trace::Config and .with_config(...) to remain consistent with the MeterProvider, and LoggerProvider.

Migration Guide

Moving away from TracerProvider::builder().with_config(trace::Config::default()).

Simple Example

The provider interface should be similar to the old method. For example, a TracerProvider being configured.

// old
let tracer_provider: TracerProvider = TracerProvider::builder()
    .with_config(Config::default().with_resource(Resource::empty()))
    .build();

// new
let tracer_provider: TracerProvider = TracerProvider::builder()
    .with_resource(Resource::empty())
    .build();

Advanced Example

// old
let tracer_provider = TracerProvider::builder()
    .with_config(
        Config::default()
            .with_resource(Resource::empty())
            .with_sampler(Sampler::AlwaysOn)
            .with_max_events_per_span(16),
    )
    .build();

// new
let tracer_provider = TracerProvider::builder()
    .with_resource(Resource::empty())
    .with_sampler(Sampler::AlwaysOn)
    .with_max_events_per_span(16)
    .build();

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)

@pitoniak32 pitoniak32 requested a review from a team as a code owner November 17, 2024 18:17
Copy link

codecov bot commented Nov 17, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 29 lines in your changes missing coverage. Please review.

Project coverage is 79.5%. Comparing base (41afd7f) to head (7e6645c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
opentelemetry-sdk/src/trace/provider.rs 40.4% 28 Missing ⚠️
opentelemetry-zipkin/src/exporter/mod.rs 0.0% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #2303     +/-   ##
=======================================
- Coverage   79.6%   79.5%   -0.2%     
=======================================
  Files        123     123             
  Lines      21263   21293     +30     
=======================================
- Hits       16940   16938      -2     
- Misses      4323    4355     +32     

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


🚨 Try these New Features:

"tracing-jaeger",
)])),
)
.with_resource(Resource::new(vec![KeyValue::new(
Copy link
Member

Choose a reason for hiding this comment

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

we could potentially offer an easier ways for users who is just trying to add service name. For another time!

@@ -308,10 +310,77 @@ impl Builder {
}

/// The sdk [`crate::trace::Config`] that this provider will use.
#[deprecated(
Copy link
Member

Choose a reason for hiding this comment

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

Please add a changelog too.

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.

LGTM. Lets add changelog too, will merge after one more approval.

Note: This will be part of 0.27.1 as there is no actual method removal, just deprecation warning this time. Actual removal will be 0.28.0 time only

Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

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

LGTM, with nit comments.

opentelemetry-sdk/src/trace/provider.rs Show resolved Hide resolved
opentelemetry-sdk/src/trace/provider.rs Show resolved Hide resolved
opentelemetry-sdk/src/trace/provider.rs Show resolved Hide resolved
opentelemetry-sdk/src/trace/provider.rs Show resolved Hide resolved
opentelemetry-sdk/src/trace/provider.rs Show resolved Hide resolved
@@ -106,6 +106,7 @@ impl ZipkinPipelineBuilder {
));
cfg
} else {
#[allow(deprecated)]
Copy link
Member

Choose a reason for hiding this comment

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

Would be good to cleanup this instead of having deprecated code. Not a blocker for this PR though :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it seems like Zipkin needs to be updated to follow the builder pattern that was added for otlp also, its currently using the pipeline version.

I will try and get this refactored to not use the allow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe there can be a followup for the zipkin to match the otlp crate.

Copy link
Member

Choose a reason for hiding this comment

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

Its best to do as a follow up to keep the scope for this PR smaller.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, that's what I was thinking. I went simple with the approach on this PR, but I would like to open another to move to the Builder pattern if that would be welcomed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my current change actually ignores the config, I'm going to revert to using the deprecated annotation, and then do a followup PR to move to the builder pattern to avoid too many changes in this PR.

@pitoniak32 pitoniak32 force-pushed the refactor/deprecate-trace-config branch from 3c1ba0c to be6b8dd Compare November 19, 2024 01:27
@pitoniak32 pitoniak32 force-pushed the refactor/deprecate-trace-config branch from 3a37cc8 to 7e6645c Compare November 19, 2024 01:48
@cijothomas cijothomas merged commit 849778d into open-telemetry:main Nov 19, 2024
23 of 25 checks passed
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.

Consistent way to set resource to provider
3 participants