Skip to content

Commit d8daf5b

Browse files
committed
Update opentelemetry
1 parent f8299f1 commit d8daf5b

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

crates/telemetry-subscribers/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ crossterm.workspace = true
1717
futures.workspace = true
1818
once_cell.workspace = true
1919
opentelemetry = "0.24"
20-
opentelemetry-otlp = { version = "0.17", features = ["grpc-tonic"] }
21-
opentelemetry-proto = "0.7"
22-
opentelemetry_sdk = { version = "0.24", features = ["rt-tokio"] }
20+
opentelemetry-otlp = { version = "0.25", features = ["grpc-tonic"] }
21+
opentelemetry-proto = "0.25"
22+
opentelemetry_sdk = { version = "0.25", features = ["rt-tokio"] }
2323
prometheus.workspace = true
2424
prost.workspace = true
2525
thiserror.workspace = true
2626
tokio = { workspace = true, features = ["full"] }
2727
tonic.workspace = true
2828
tracing.workspace = true
2929
tracing-appender = "0.2.2"
30-
tracing-opentelemetry = "0.25"
30+
tracing-opentelemetry = "0.26"
3131
tracing-subscriber.workspace = true
3232

3333
[features]

crates/telemetry-subscribers/src/file_exporter.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -80,29 +80,27 @@ impl CachedOpenFile {
8080
#[derive(Debug)]
8181
pub(crate) struct FileExporter {
8282
pub cached_open_file: CachedOpenFile,
83+
resource: ResourceAttributesWithSchema,
8384
}
8485

8586
impl FileExporter {
8687
pub fn new(file_path: Option<PathBuf>) -> std::io::Result<Self> {
8788
Ok(Self {
8889
cached_open_file: CachedOpenFile::new(file_path)?,
90+
resource: ResourceAttributesWithSchema::default(),
8991
})
9092
}
9193
}
9294

9395
impl SpanExporter for FileExporter {
9496
fn export(&mut self, batch: Vec<SpanData>) -> BoxFuture<'static, ExportResult> {
9597
let cached_open_file = self.cached_open_file.clone();
98+
let resource_spans = group_spans_by_resource_and_scope(batch, &self.resource);
9699
async move {
97100
cached_open_file
98101
.with_file(|maybe_file| {
99102
if let Some(file) = maybe_file {
100-
let request = ExportTraceServiceRequest {
101-
resource_spans: group_spans_by_resource_and_scope(
102-
batch,
103-
&ResourceAttributesWithSchema::default(),
104-
),
105-
};
103+
let request = ExportTraceServiceRequest { resource_spans };
106104

107105
let buf = request.encode_length_delimited_to_vec();
108106

crates/telemetry-subscribers/src/lib.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use opentelemetry::{
2020
};
2121
use opentelemetry_otlp::WithExportConfig;
2222
use opentelemetry_sdk::{
23-
Resource,
23+
Resource, runtime,
2424
trace::{BatchSpanProcessor, Sampler, ShouldSample, TracerProvider},
2525
};
2626
use span_latency_prom::PrometheusSpanLatencyLayer;
@@ -425,18 +425,20 @@ impl TelemetryConfig {
425425
let endpoint = env::var("OTLP_ENDPOINT")
426426
.unwrap_or_else(|_| "http://localhost:4317".to_string());
427427

428-
let tracer = opentelemetry_otlp::new_pipeline()
428+
let p = opentelemetry_otlp::new_pipeline()
429429
.tracing()
430430
.with_exporter(
431431
opentelemetry_otlp::new_exporter()
432432
.tonic()
433433
.with_endpoint(endpoint),
434434
)
435435
.with_trace_config(config)
436-
.install_batch(opentelemetry_sdk::runtime::Tokio)
436+
.install_batch(runtime::Tokio)
437437
.expect("Could not create async Tracer")
438438
.tracer("iota-node");
439439

440+
let tracer = p.tracer(service_name);
441+
440442
tracing_opentelemetry::layer().with_tracer(tracer)
441443
};
442444

@@ -486,15 +488,12 @@ impl TelemetryConfig {
486488
// too early then no output will appear!
487489
let guards = TelemetryGuards::new(config_clone, worker_guard, provider);
488490

489-
(
490-
guards,
491-
TracingHandle {
492-
log: log_filter_handle,
493-
trace: trace_filter_handle,
494-
file_output,
495-
sampler,
496-
},
497-
)
491+
(guards, TracingHandle {
492+
log: log_filter_handle,
493+
trace: trace_filter_handle,
494+
file_output,
495+
sampler,
496+
})
498497
}
499498
}
500499

0 commit comments

Comments
 (0)