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

Fix opentelemetry examples #134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions examples/custom-root-span/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ opentelemetry = "0.27"
opentelemetry-otlp = "0.27"
opentelemetry_sdk = { version = "0.27", features = ["rt-tokio-current-thread"] }
opentelemetry-semantic-conventions = "0.27"
tracing-opentelemetry = { version = "0.28" }
tracing-opentelemetry = "0.28"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
tracing-bunyan-formatter = "0.3"
tracing-actix-web = { path = "../..", features = ["opentelemetry_0_27"] }
tracing-bunyan-formatter = "0.3"
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
20 changes: 9 additions & 11 deletions examples/custom-root-span/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,16 @@ fn init_telemetry() {
// Start a new otlp trace pipeline.
// Spans are exported in batch - recommended setup for a production application.
global::set_text_map_propagator(TraceContextPropagator::new());
let tracer = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(
opentelemetry_otlp::new_exporter()
.tonic()
.with_endpoint("http://localhost:4317"),
)
.with_trace_config(Config::default().with_resource(RESOURCE.clone()))
.install_batch(TokioCurrentThread)
.expect("Failed to install OpenTelemetry tracer.")
.tracer_builder(APP_NAME)
let otlp_exporter = opentelemetry_otlp::SpanExporter::builder()
.with_tonic()
.with_endpoint("http://localhost:4317")
.build()
.expect("Failed to build the span exporter");
let provier = opentelemetry_sdk::trace::TracerProvider::builder()
.with_batch_exporter(otlp_exporter, TokioCurrentThread)
.with_config(Config::default().with_resource(RESOURCE.clone()))
.build();
let tracer = provier.tracer(APP_NAME);

// Filter based on level - trace, debug, info, warn, error
// Tunable via `RUST_LOG` env variable
Expand Down
8 changes: 4 additions & 4 deletions examples/opentelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ license = "MIT/Apache-2.0"
[dependencies]
actix-web = "4"
opentelemetry = "0.27"
opentelemetry_sdk = { version = "0.27", features = ["rt-tokio-current-thread"] }
opentelemetry-otlp = "0.27"
opentelemetry_sdk = { version = "0.27", features = ["rt-tokio-current-thread"] }
opentelemetry-semantic-conventions = "0.27"
tracing = "0.1"
tracing-actix-web = { path = "../..", features = ["opentelemetry_0_27"] }
tracing-bunyan-formatter = "0.3"
tracing-opentelemetry = "0.28"
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
tracing-bunyan-formatter = "0.3"
tracing-actix-web = { path = "../..", features = ["opentelemetry_0_27"] }
tracing = "0.1.40"
20 changes: 9 additions & 11 deletions examples/opentelemetry/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@ fn init_telemetry() {
// Start a new otlp trace pipeline.
// Spans are exported in batch - recommended setup for a production application.
global::set_text_map_propagator(TraceContextPropagator::new());
let tracer = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(
opentelemetry_otlp::new_exporter()
.tonic()
.with_endpoint("http://localhost:4317"),
)
.with_trace_config(Config::default().with_resource(RESOURCE.clone()))
.install_batch(TokioCurrentThread)
.expect("Failed to install OpenTelemetry tracer.")
.tracer_builder(APP_NAME)
let otlp_exporter = opentelemetry_otlp::SpanExporter::builder()
.with_tonic()
.with_endpoint("http://localhost:4317")
.build()
.expect("Failed to build the span exporter");
let provier = opentelemetry_sdk::trace::TracerProvider::builder()
.with_batch_exporter(otlp_exporter, TokioCurrentThread)
.with_config(Config::default().with_resource(RESOURCE.clone()))
.build();
let tracer = provier.tracer(APP_NAME);

// Filter based on level - trace, debug, info, warn, error
// Tunable via `RUST_LOG` env variable
Expand Down