Skip to content

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
@codecov
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!

}

/// 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.

));
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
dongsupark added a commit to dongsupark/azure-init that referenced this pull request Feb 4, 2025
As opentelemetry 0.27 or newer does not have a method `with_config` for
TraceBuilder, it is necessary to call `with_sampler` directly from
TraceBuilder without `with_config`. Needed to fix build issues with
opentelemetry(_sdk) 0.27 or newer as well as tracing_opentelemetry 0.28
or newer.

See also open-telemetry/opentelemetry-rust#2303.
dongsupark added a commit to Azure/azure-init that referenced this pull request Feb 5, 2025
…uild issues (#161)

* Update opentelemetry_sdk requirement from 0.26 to 0.27

Updates the requirements on [opentelemetry_sdk](https://github.com/open-telemetry/opentelemetry-rust) to permit the latest version.
- [Release notes](https://github.com/open-telemetry/opentelemetry-rust/releases)
- [Commits](open-telemetry/opentelemetry-rust@opentelemetry_sdk-0.26.0...opentelemetry_sdk-0.27.1)

---
updated-dependencies:
- dependency-name: opentelemetry_sdk
  dependency-type: direct:production
...

* Update opentelemetry requirement from 0.26 to 0.27

Updates the requirements on [opentelemetry](https://github.com/open-telemetry/opentelemetry-rust) to permit the latest version.
- [Release notes](https://github.com/open-telemetry/opentelemetry-rust/releases)
- [Commits](open-telemetry/opentelemetry-rust@opentelemetry-0.26.0...opentelemetry-0.27.1)

---
updated-dependencies:
- dependency-name: opentelemetry
  dependency-type: direct:production
...

* Update tracing-opentelemetry requirement from 0.27 to 0.28

Updates the requirements on [tracing-opentelemetry](https://github.com/tokio-rs/tracing-opentelemetry) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/tracing-opentelemetry/releases)
- [Changelog](https://github.com/tokio-rs/tracing-opentelemetry/blob/v0.1.x/CHANGELOG.md)
- [Commits](tokio-rs/tracing-opentelemetry@v0.27.0...v0.28.0)

---
updated-dependencies:
- dependency-name: tracing-opentelemetry
  dependency-type: direct:production
...

* Do not use with_config for opentelemetry 0.27

As opentelemetry 0.27 or newer does not have a method `with_config` for
TraceBuilder, it is necessary to call `with_sampler` directly from
TraceBuilder without `with_config`. Needed to fix build issues with
opentelemetry(_sdk) 0.27 or newer as well as tracing-opentelemetry 0.28
or newer.

See also open-telemetry/opentelemetry-rust#2303.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Dongsu Park <[email protected]>
bantonsson pushed a commit to bantonsson/opentelemetry-rust that referenced this pull request Oct 9, 2025
bantonsson pushed a commit to bantonsson/opentelemetry-rust that referenced this pull request Oct 9, 2025
bantonsson pushed a commit to bantonsson/opentelemetry-rust that referenced this pull request Oct 9, 2025
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