Skip to content

Commit

Permalink
another bash at this, and revert changes made in 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Fergus Dixon committed Jul 17, 2024
1 parent 229de5a commit 6c109a1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ axum = ["dep:axum", "dep:tokio", "dep:axum-tracing-opentelemetry"]

[dependencies]
axum = { version = "^0.6.10", optional = true }
axum-tracing-opentelemetry = { version = "^0.14.1", optional = true }
axum-tracing-opentelemetry = { version = "0.18.0", optional = true }
chrono = "^0.4.24"
opentelemetry = { version = "^0.20.0", features = ["rt-tokio"] }
opentelemetry-datadog = "^0.8.0"
opentelemetry-otlp = { version = "^0.13.0" }
opentelemetry = { version = "0.22.0" }
opentelemetry-datadog = "0.10.0"
opentelemetry-otlp = { version = "0.15.0" , features = ["tls-roots"]}
opentelemetry_sdk = { version = "0.22.0", features = ["rt-tokio"] }
serde = { version = "^1.0.156", features = ["derive"] }
serde_json = "^1.0.95"
tokio = { version = "^1.26.0", features = ["signal"], optional = true }
tracing = "^0.1.37"
tracing-opentelemetry = "^0.21.0"
tracing-opentelemetry = "0.23.0"
tracing-serde = "^0.1.3"
tracing-subscriber = { version = "^0.3.16", features = ["env-filter", "json"] }
3 changes: 2 additions & 1 deletion src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use std::io;

use chrono::Utc;
use opentelemetry::trace::TraceContextExt;
use opentelemetry::trace::{SpanId, TraceId};
use serde::ser::{SerializeMap, Serializer as _};
use serde::Serialize;
Expand Down Expand Up @@ -45,7 +46,7 @@ where
S: Subscriber + for<'a> LookupSpan<'a>,
{
span_ref.extensions().get::<OtelData>().map(|o| TraceInfo {
trace_id: o.builder.trace_id.unwrap_or(TraceId::INVALID).into(),
trace_id: o.parent_cx.span().span_context().trace_id().into(),
span_id: o.builder.span_id.unwrap_or(SpanId::INVALID).into(),
})
}
Expand Down
7 changes: 3 additions & 4 deletions src/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
//! to send traces to the Datadog agent in batches over gRPC.
//!
//! It also contains a convenience function to build a layer with the tracer.
use opentelemetry::sdk::trace::{RandomIdGenerator, Sampler, Tracer};
use opentelemetry::sdk::{trace, Resource};
pub use opentelemetry::trace::{TraceError, TraceResult};
use opentelemetry::KeyValue;
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::trace::{RandomIdGenerator, Sampler, Tracer};
use opentelemetry_sdk::{trace, Resource};
use std::time::Duration;
use tracing::Subscriber;
use tracing_opentelemetry::{OpenTelemetryLayer, PreSampledTracer};
Expand All @@ -18,7 +18,6 @@ pub fn build_tracer(service_name: &str) -> TraceResult<Tracer> {
let exporter = opentelemetry_otlp::new_exporter()
.tonic()
.with_timeout(Duration::from_secs(3));

opentelemetry_otlp::new_pipeline()
.tracing()
.with_trace_config(
Expand All @@ -31,7 +30,7 @@ pub fn build_tracer(service_name: &str) -> TraceResult<Tracer> {
.with_id_generator(RandomIdGenerator::default()),
)
.with_exporter(exporter)
.install_batch(opentelemetry::runtime::Tokio)
.install_batch(opentelemetry_sdk::runtime::Tokio)
}

pub fn build_layer<S>(service_name: &str) -> TraceResult<OpenTelemetryLayer<S, Tracer>>
Expand Down

0 comments on commit 6c109a1

Please sign in to comment.