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

sdk: expose hidden Tracer::should_sample() method #1937

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## vNext

## v0.24.1

- Add hidden method to support tracing-opentelemetry

## v0.24.0

- Add "metrics", "logs" to default features. With this, default feature list is
Expand Down Expand Up @@ -34,13 +38,13 @@
- Added `non_exhaustive` annotation to [`trace::Config`]. Marked [`config`] as deprecated since it's only a wrapper for `Config::default`
- Removed [`Tracer::tracer_provder`] and [`Tracer::instrument_libraries`] as it's not part of the spec.

- **Breaking** [#1830](https://github.com/open-telemetry/opentelemetry-rust/pull/1830/files) [Traces SDK] Improves
- **Breaking** [#1830](https://github.com/open-telemetry/opentelemetry-rust/pull/1830/files) [Traces SDK] Improves
performance by sending Resource information to processors (and exporters) once, instead of sending with every log. If you are an author
of Processor, Exporter, the following are *BREAKING* changes.
- Implement `set_resource` method in your custom SpanProcessor, which invokes exporter's `set_resource`.
- Implement `set_resource` method in your custom SpanExporter. This method should save the resource object
in original or serialized format, to be merged with every span event during export.
- `SpanData` doesn't have the resource attributes. The `SpanExporter::export()` method needs to merge it
- `SpanData` doesn't have the resource attributes. The `SpanExporter::export()` method needs to merge it
with the earlier preserved resource before export.

- **Breaking** [1836](https://github.com/open-telemetry/opentelemetry-rust/pull/1836) `SpanProcessor::shutdown` now takes an immutable reference to self. Any reference can call shutdown on the processor. After the first call to `shutdown` the processor will not process any new spans.
Expand Down Expand Up @@ -95,17 +99,17 @@ The `LogRecord::target` field contains the actual target/component emitting the
- **Breaking** [#1624](https://github.com/open-telemetry/opentelemetry-rust/pull/1624) Remove `OsResourceDetector` and
`ProcessResourceDetector` resource detectors, use the
[`opentelemetry-resource-detector`](https://crates.io/crates/opentelemetry-resource-detectors) instead.
- [#1636](https://github.com/open-telemetry/opentelemetry-rust/pull/1636) [Logs SDK] Improves performance by sending
- [#1636](https://github.com/open-telemetry/opentelemetry-rust/pull/1636) [Logs SDK] Improves performance by sending
Resource information to processors (and exporters) once, instead of sending with every log. If you are an author
of Processor, Exporter, the following are *BREAKING* changes.
- Implement `set_resource` method in your custom LogProcessor, which invokes exporter's `set_resource`.
- Implement `set_resource` method in your custom LogExporter. This method should save the resource object
in original or serialized format, to be merged with every log event during export.
- `LogData` doesn't have the resource attributes. The `LogExporter::export()` method needs to merge it
- `LogData` doesn't have the resource attributes. The `LogExporter::export()` method needs to merge it
with the earlier preserved resource before export.
- Baggage propagation error will be reported to global error handler [#1640](https://github.com/open-telemetry/opentelemetry-rust/pull/1640)
- Improves `shutdown` behavior of `LoggerProvider` and `LogProcessor` [#1643](https://github.com/open-telemetry/opentelemetry-rust/pull/1643).
- `shutdown` can be called by any clone of the `LoggerProvider` without the need of waiting on all `Logger` drops. Thus, `try_shutdown` has been removed.
- `shutdown` can be called by any clone of the `LoggerProvider` without the need of waiting on all `Logger` drops. Thus, `try_shutdown` has been removed.
- `shutdown` methods in `LoggerProvider` and `LogProcessor` now takes a immutable reference
- After `shutdown`, `LoggerProvider` will return noop `Logger`
- After `shutdown`, `LogProcessor` will not process any new logs
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "opentelemetry_sdk"
version = "0.24.0"
version = "0.24.1"
description = "The SDK for the OpenTelemetry metrics collection and distributed tracing framework"
homepage = "https://github.com/open-telemetry/opentelemetry-rust"
repository = "https://github.com/open-telemetry/opentelemetry-rust"
Expand Down
10 changes: 9 additions & 1 deletion opentelemetry-sdk/src/trace/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
trace::{
provider::TracerProvider,
span::{Span, SpanData},
IdGenerator, SpanEvents, SpanLimits, SpanLinks,
IdGenerator, ShouldSample, SpanEvents, SpanLimits, SpanLinks,
},
InstrumentationLibrary,
};
Expand Down Expand Up @@ -166,6 +166,14 @@
pub fn id_generator(&self) -> &dyn IdGenerator {
&*self.provider.config().id_generator
}

/// The [`ShouldSample`] associated with this tracer.
///
// Note: this is necessary for tracing-opentelemetry's `PreSampledTracer`.
#[doc(hidden)]
pub fn should_sample(&self) -> &dyn ShouldSample {
&*self.provider.config().sampler
}

Check warning on line 176 in opentelemetry-sdk/src/trace/tracer.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/trace/tracer.rs#L174-L176

Added lines #L174 - L176 were not covered by tests
}

impl opentelemetry::trace::Tracer for Tracer {
Expand Down
Loading