-
Notifications
You must be signed in to change notification settings - Fork 485
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
feat: replace OtlpPipeline with exporter builders #2221
feat: replace OtlpPipeline with exporter builders #2221
Conversation
I have started looking into replicating If you have a chance to review this @cijothomas I would really appreciate it! |
a307f3d
to
4f44160
Compare
This might be another issue / PR, but I'm noticing the |
414dfac
to
dfeb006
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2221 +/- ##
=======================================
+ Coverage 79.1% 79.6% +0.4%
=======================================
Files 121 121
Lines 21171 21094 -77
=======================================
+ Hits 16762 16805 +43
+ Misses 4409 4289 -120 ☔ View full report in Codecov by Sentry. |
dfeb006
to
b4b5118
Compare
Yes, ensuring consistency across signals wherever feasible is definitely something we need to tackle soon! |
Took a brief look and I like this direction. Left some comments, mostly about limiting the scope of PR. We really prefer short PRs each solving one particular aspect. |
I'll go through and remove some of the changes I made that weren't specific to this issue 👍 done |
b4b5118
to
c075527
Compare
As an output of this PR I would like to open a discussion / issue to talk about the following refactors:
|
dfb21bf
to
f95729d
Compare
these modules are conditionally included by the same flags in lib
f95729d
to
98d3e87
Compare
fn init_logs() -> Result<sdklogs::LoggerProvider, opentelemetry::logs::LogError> { | ||
let exporter_builder = LogExporter::builder() | ||
.with_http() | ||
.with_endpoint("http://localhost:4318/v1/logs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible for endpoint, protocol to take defaults, so users does not have to specify this (unless they want nondefaults)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call out, The defaults should already be getting used as they were before, including the http
appending the appropriate path. I added a couple more test cases for tonic to cover this.
I also changed the type of the endpoint field to Option<String>
so its more explicit that it could be empty, and its on the Builders to handle resolving it.
.logging() | ||
let exporter = LogExporter::builder() | ||
.with_tonic() | ||
.with_endpoint("http://localhost:4317") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one inconsistency I notice between grpc and http is the end point - one has to append /v1/logs in http, but grpc does not require that. This is something we can address in a follow up.
I am thinking something like:
with_tonic() or with_http() is enough for builder to know which endpoint, protocol to use by default.
builder.with_tonic().build() -- this should just work with defaults
builder.with_http().build() -- this should also just work with defaults.
if user wish to change defaults, then they can use methods like with_endpoint, with_protocol etc.
Lets come back to this after merging this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, after my most recent update, the with_{tonic,http}()
is enough to determine the http://localhost:431{7,8}
and the tests for this are updated also.
I will however need to look at the spec to see how the /v1/*
is handled for the two, and I would be happy to create a new pr to get that sorted out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, after my most recent update, the
with_{tonic,http}()
is enough to determine thehttp://localhost:431{7,8}
and the tests for this are updated also.I will however need to look at the spec to see how the
/v1/*
is handled for the two, and I would be happy to create a new pr to get that sorted out.
EDIT: After looking back through the code, this should also already be the case, I made some changes to make it a little more clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall from the user-facing changes.
Guys, I know this is still 0.x and stuff, but breaking the API on almost every release is, from a user point of view, quite painful. Staying at 0.26 for the moment. |
@pitoniak32, can you help me with |
Sure! Do you have a specific issue? Did you checkout the migration guide in the overview comment already? |
Yeah, but I cannot find |
@frederikhors Can you try something like (not tested) fn init_tracer_provider() -> Result<sdktrace::TracerProvider, TraceError> {
// Create a span exporter
let exporter = SpanExporter::builder()
.with_http()
.with_protocol(Protocol::HttpBinary)
.with_endpoint("http://localhost:4318/v1/traces")
.build()?;
let batch_config = BatchConfigBuilder::default()
.with_max_queue_size(2048)
.build();
let batch_processor = sdktrace::BatchSpanProcessor::builder(exporter, runtime::Tokio)
.with_batch_config(batch_config)
.build();
Ok(TracerProvider::builder()
.with_span_processor(batch_processor)
.with_config(Config::default().with_resource(RESOURCE.clone()))
.build())
} I think we should modify the basic-otlp-http example to show this more clearly now. |
It works. I'm having only this error now:
for the code: let layer = tracing_opentelemetry::layer()
.with_tracer(otlp_tracer_provider.tracer("otlp-tracer"))
.with_filter(EnvFilter::from("INFO"))
.boxed(); Importing |
Try importing |
It works. But ??? Is this OK? |
Yes, this is typical of Rust — the trait must be in scope for its methods to be accessible. |
Thanks all. If there are any issues/concerns with this change that need help - please open a new issue. |
> I followed the migration guide described in open-telemetry/opentelemetry-rust#2221
open-telemetry/opentelemetry-rust#2221 Need a trait to access this now So import it
* fix(deps): update opentelemetry-rust monorepo to 0.27.0 * fix(deps): update rust crate tracing-opentelemetry to 0.28.0 * fix: otel 0.27 tls_config setting open-telemetry/opentelemetry-rust#2221 Need a trait to access this now So import it --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Philip Cristiano <git@philipcristiano.com>
* chore(deps): cargo * wip: use axum & cargo fmt * wip: remove `once_cell` * wip: upgrade opentelemetry ref: open-telemetry/opentelemetry-rust#1000 ref: open-telemetry/opentelemetry-rust#2221 ref: open-telemetry/opentelemetry-rust#2085 * chore: cargo clippy * chore(deps): upgrade go * version: upgrade to 0.6.0 * chore(deps): use rkyv * chore(deps): update * chore(deps): update * wip: split mods into crates * wip: remove unused dependencies * chore(ci): upgrade rust version in Dockerfile * fix(ci): update cargo install path * chore: tidy up main.rs * fix(test): review snaps & fix tests * chore(deps): update * fix(cgroup): early stop when use `map_while` * chore: init logger before setup cgroup * chore(deps): ebpf version restore to v0.12.3 * chore(lazylock): use `LazyLock::force` to init cache * fix(cache): remove unnecessary async * chore(config): make default functions const
Fixes #1810
Migration Guide
To move from
opentelemetry_otlp::new_exporter()
, andopentelemetry_otlp::new_pipeline().{tracing,metrics,logging}()
, you will need to select theExporter
, andProvider
for the signal you are using.Below there is a guide with details about Exporters and Providers. There are also Examples for each type of signal.
Exporter Guide
The following are the available exporters:
The exporter interface should have the same options as with the old method. For example, a tonic grpc exporter being configured old vs new:
Provider Guide
The following are the available providers:
The provider interface should be similar to the old method. For example, a
TracerProvider
being configured old vs new:Signal Examples
Trace Example
Metric Example
Log Example
Changes
Started to replace the
OTLPPipeline
pattern in theopentelemetry-otlp
crate.Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes