Skip to content

Commit

Permalink
Bump the otel group with 4 updates and change builder functions
Browse files Browse the repository at this point in the history
Signed-off-by: Yeongju Kang <[email protected]>
  • Loading branch information
Yeongju Kang committed Dec 26, 2024
1 parent a22833d commit 00f1e7d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
25 changes: 13 additions & 12 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ serde_yaml = "0.9.25"
chrono = { version = "0.4.39", features = ["serde"] }
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["json", "env-filter"] }
tracing-opentelemetry = "0.27.0"
opentelemetry = { version = "0.26.0", features = ["trace"] }
opentelemetry-otlp = { version = "0.26.0", optional = true }
opentelemetry_sdk = { version = "0.26.0", features = ["rt-tokio"] }
tracing-opentelemetry = "0.28.0"
opentelemetry = { version = "0.27.1", features = ["trace"] }
opentelemetry-otlp = { version = "0.27.0", optional = true }
opentelemetry_sdk = { version = "0.27.1", features = ["rt-tokio"] }
thiserror = "2.0.9"
anyhow = "1.0.95"
prometheus-client = "0.22.2"
Expand Down
13 changes: 6 additions & 7 deletions src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use opentelemetry::trace::{TraceId, TracerProvider};
use opentelemetry_sdk::{runtime, trace as sdktrace, trace::Config, Resource};
use tracing_subscriber::{prelude::*, EnvFilter, Registry};
use opentelemetry_otlp::{SpanExporter, WithExportConfig};

/// Fetch an opentelemetry::trace::TraceId as hex through the full tracing stack
pub fn get_trace_id() -> TraceId {
Expand All @@ -27,14 +28,12 @@ fn resource() -> Resource {
fn init_tracer() -> sdktrace::Tracer {
use opentelemetry_otlp::WithExportConfig;
let endpoint = std::env::var("OPENTELEMETRY_ENDPOINT_URL").expect("Needs an otel collector");
let exporter = opentelemetry_otlp::new_exporter().tonic().with_endpoint(endpoint);
let exporter = SpanExporter::builder().with_tonic().with_endpoint(endpoint).build().unwrap();

let provider = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(exporter)
.with_trace_config(Config::default().with_resource(resource()))
.install_batch(runtime::Tokio)
.expect("valid tracer");
let provider = sdktrace::TracerProvider::builder()
.with_batch_exporter(exporter, runtime::Tokio)
.with_config(Config::default().with_resource(resource()))
.build();

opentelemetry::global::set_tracer_provider(provider.clone());
provider.tracer("tracing-otel-subscriber")
Expand Down

0 comments on commit 00f1e7d

Please sign in to comment.