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

support zipkin b3 propagation #5

Merged
merged 2 commits into from
Apr 17, 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
42 changes: 42 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ of requests across services.
To enable tracing you must:

- use the SDK option `--otlp-endpoint` e.g. `http://localhost:4317`,
- set the SDK environment variable `OTLP_ENDPOINT`, or
- set the SDK environment variable `OTEL_EXPORTER_OTLP_ENDPOINT`, or
- set the `tracing` environment variable `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`.

For additional service information you can:
Expand Down
1 change: 1 addition & 0 deletions crates/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ opentelemetry-http = "0.11.0"
opentelemetry-otlp = { version = "0.15.0", features = ["reqwest-client"] }
opentelemetry-semantic-conventions = "0.14.0"
opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio"] }
opentelemetry-zipkin = "0.20.0"
prometheus = "0.13.3"
reqwest = "0.11.27"
serde = { version = "1.0.197", features = ["derive"] }
Expand Down
8 changes: 5 additions & 3 deletions crates/sdk/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::time::Duration;

use axum::body::{Body, BoxBody};
use http::{Request, Response};
use opentelemetry::propagation::composite::TextMapCompositePropagator;
use opentelemetry_otlp::WithExportConfig;
use tracing::Span;
use tracing_opentelemetry::OpenTelemetrySpanExt;
Expand All @@ -13,9 +14,10 @@ pub fn init_tracing(
service_name: Option<&str>,
otlp_endpoint: Option<&str>,
) -> Result<(), Box<dyn Error + Send + Sync>> {
opentelemetry::global::set_text_map_propagator(
opentelemetry_sdk::propagation::TraceContextPropagator::new(),
);
opentelemetry::global::set_text_map_propagator(TextMapCompositePropagator::new(vec![
Box::new(opentelemetry_sdk::propagation::TraceContextPropagator::new()),
Box::new(opentelemetry_zipkin::Propagator::new()),
Comment on lines +18 to +19
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the Zipkin one go first?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, that is confusing. Thanks for clarifying.

]));

let tracer = opentelemetry_otlp::new_pipeline()
.tracing()
Expand Down
Loading