Skip to content

Commit 9e69778

Browse files
committed
Make sending traces to Tempo less confusing
1 parent 7d3a3cd commit 9e69778

File tree

11 files changed

+128
-201
lines changed

11 files changed

+128
-201
lines changed

CLI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Client implementation and command-line tool for the Linera blockchain
150150
Default value: `10`
151151
* `--chrome-trace-exporter` — Enable OpenTelemetry Chrome JSON exporter for trace data analysis
152152
* `--otel-trace-file <OTEL_TRACE_FILE>` — Output file path for Chrome trace JSON format. Can be visualized in chrome://tracing or Perfetto UI
153-
* `--otel-exporter-otlp-endpoint <OTEL_EXPORTER_OTLP_ENDPOINT>` — OpenTelemetry OTLP exporter endpoint (requires tempo feature)
153+
* `--otel-exporter-otlp-endpoint <OTEL_EXPORTER_OTLP_ENDPOINT>` — OpenTelemetry OTLP exporter endpoint (requires otel feature)
154154
* `--wait-for-outgoing-messages` — Whether to wait until a quorum of validators has confirmed that all sent cross-chain messages have been delivered
155155
* `--long-lived-services` — (EXPERIMENTAL) Whether application services can persist in some cases between queries
156156
* `--blanket-message-policy <BLANKET_MESSAGE_POLICY>` — The policy for handling incoming messages

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ARG binaries=
2525
ARG copy=${binaries:+_copy}
2626
ARG build_flag=--release
2727
ARG build_folder=release
28-
ARG build_features=scylladb,metrics,memory-profiling,tempo
28+
ARG build_features=scylladb,metrics,memory-profiling,otel
2929
ARG rustflags="-C force-frame-pointers=yes"
3030

3131
FROM rust:1.74-slim-bookworm AS builder

linera-base/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ workspace = true
1818
metrics = ["prometheus"]
1919
reqwest = ["dep:reqwest"]
2020
revm = []
21-
tempo = ["opentelemetry-otlp"]
21+
otel = ["opentelemetry-otlp"]
2222
test = ["test-strategy", "proptest"]
2323
web = [
2424
"getrandom/js",

linera-base/src/tracing_otel.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
// Copyright (c) Zefchain Labs, Inc.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
//! OpenTelemetry integration for tracing with OTLP export to Tempo and Chrome trace export.
4+
//! OpenTelemetry integration for tracing with OTLP export and Chrome trace export.
55
66
use tracing_chrome::ChromeLayerBuilder;
77
use tracing_subscriber::{layer::SubscriberExt as _, util::SubscriberInitExt as _};
8-
#[cfg(feature = "tempo")]
8+
#[cfg(feature = "otel")]
99
use {
1010
opentelemetry::{global, trace::TracerProvider},
1111
opentelemetry_otlp::{SpanExporter, WithExportConfig},
1212
opentelemetry_sdk::{trace::SdkTracerProvider, Resource},
1313
tracing_opentelemetry::OpenTelemetryLayer,
14-
tracing_subscriber::{
15-
filter::{filter_fn, FilterExt as _},
16-
layer::Layer,
17-
},
14+
tracing_subscriber::{filter::filter_fn, layer::Layer},
1815
};
1916

20-
/// Initializes tracing with OpenTelemetry OTLP exporter to Tempo.
17+
/// Initializes tracing with OpenTelemetry OTLP exporter.
2118
///
22-
/// Exports traces to Tempo using the OTLP protocol. Requires the `tempo` feature.
19+
/// Exports traces using the OTLP protocol to any OpenTelemetry-compatible backend.
20+
/// Requires the `otel` feature.
2321
/// Only enables OpenTelemetry if OTEL_EXPORTER_OTLP_ENDPOINT env var is set.
2422
/// This prevents DNS errors in environments where OpenTelemetry is not deployed.
25-
#[cfg(feature = "tempo")]
23+
#[cfg(feature = "otel")]
2624
pub fn init_with_opentelemetry(log_name: &str, otlp_endpoint: Option<&str>) {
2725
// Check if OpenTelemetry endpoint is configured via parameter or env var
2826
let endpoint = match otlp_endpoint {
@@ -59,15 +57,17 @@ pub fn init_with_opentelemetry(log_name: &str, otlp_endpoint: Option<&str>) {
5957
global::set_tracer_provider(tracer_provider.clone());
6058
let tracer = tracer_provider.tracer("linera");
6159

62-
let telemetry_only_filter =
63-
filter_fn(|metadata| metadata.is_span() && metadata.target() == "telemetry_only");
60+
let otel_filter = filter_fn(|metadata| {
61+
if !metadata.is_span() {
62+
return false;
63+
}
64+
metadata
65+
.fields()
66+
.field("otel.skip")
67+
.is_none()
68+
});
6469

65-
let otel_env_filter = tracing_subscriber::EnvFilter::builder()
66-
.with_default_directive(tracing_subscriber::filter::LevelFilter::INFO.into())
67-
.from_env_lossy();
68-
69-
let opentelemetry_filter = otel_env_filter.or(telemetry_only_filter);
70-
let opentelemetry_layer = OpenTelemetryLayer::new(tracer).with_filter(opentelemetry_filter);
70+
let opentelemetry_layer = OpenTelemetryLayer::new(tracer).with_filter(otel_filter);
7171

7272
let config = crate::tracing::get_env_config(log_name);
7373
let maybe_log_file_layer = config.maybe_log_file_layer();
@@ -81,11 +81,11 @@ pub fn init_with_opentelemetry(log_name: &str, otlp_endpoint: Option<&str>) {
8181
.init();
8282
}
8383

84-
/// Fallback when tempo feature is not enabled.
85-
#[cfg(not(feature = "tempo"))]
84+
/// Fallback when otel feature is not enabled.
85+
#[cfg(not(feature = "otel"))]
8686
pub fn init_with_opentelemetry(log_name: &str, _otlp_endpoint: Option<&str>) {
8787
eprintln!(
88-
"OTLP export requires the 'tempo' feature to be enabled! Falling back to default tracing initialization."
88+
"OTLP export requires the 'otel' feature to be enabled! Falling back to default tracing initialization."
8989
);
9090
crate::tracing::init(log_name);
9191
}

linera-chain/src/block_tracker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'resources, 'blobs> BlockExecutionTracker<'resources, 'blobs> {
101101
}
102102

103103
/// Executes a transaction in the context of the block.
104-
#[instrument(target = "telemetry_only", skip_all, fields(
104+
#[instrument(skip_all, fields(
105105
chain_id = %self.chain_id,
106106
block_height = %self.block_height,
107107
))]

linera-chain/src/chain.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ where
390390
self.context().extra().chain_id()
391391
}
392392

393-
#[instrument(target = "telemetry_only", skip_all, fields(
393+
#[instrument(skip_all, fields(
394394
chain_id = %self.chain_id(),
395395
))]
396396
pub async fn query_application(
@@ -410,7 +410,7 @@ where
410410
.with_execution_context(ChainExecutionContext::Query)
411411
}
412412

413-
#[instrument(target = "telemetry_only", skip_all, fields(
413+
#[instrument(skip_all, fields(
414414
chain_id = %self.chain_id(),
415415
application_id = %application_id
416416
))]
@@ -425,7 +425,7 @@ where
425425
.with_execution_context(ChainExecutionContext::DescribeApplication)
426426
}
427427

428-
#[instrument(target = "telemetry_only", skip_all, fields(
428+
#[instrument(skip_all, fields(
429429
chain_id = %self.chain_id(),
430430
target = %target,
431431
height = %height
@@ -556,7 +556,7 @@ where
556556
/// round timeouts.
557557
///
558558
/// Returns `true` if incoming `Subscribe` messages created new outbox entries.
559-
#[instrument(target = "telemetry_only", skip_all, fields(
559+
#[instrument(skip_all, fields(
560560
chain_id = %self.chain_id(),
561561
origin = %origin,
562562
bundle_height = %bundle.height
@@ -659,7 +659,7 @@ where
659659
/// If `must_be_present` is `true`, an error is returned if any of the bundles have not been
660660
/// added to the inbox yet. So this should be `true` if the bundles are in a block _proposal_,
661661
/// and `false` if the block is already confirmed.
662-
#[instrument(target = "telemetry_only", skip_all, fields(
662+
#[instrument(skip_all, fields(
663663
chain_id = %self.chain_id(),
664664
))]
665665
pub async fn remove_bundles_from_inboxes(
@@ -762,7 +762,7 @@ where
762762

763763
/// Executes a block: first the incoming messages, then the main operation.
764764
/// Does not update chain state other than the execution state.
765-
#[instrument(target = "telemetry_only", skip_all, fields(
765+
#[instrument(skip_all, fields(
766766
chain_id = %block.chain_id,
767767
block_height = %block.height
768768
))]
@@ -887,7 +887,7 @@ where
887887

888888
/// Executes a block: first the incoming messages, then the main operation.
889889
/// Does not update chain state other than the execution state.
890-
#[instrument(target = "telemetry_only", skip_all, fields(
890+
#[instrument(skip_all, fields(
891891
chain_id = %self.chain_id(),
892892
block_height = %block.height
893893
))]
@@ -951,7 +951,7 @@ where
951951
/// Applies an execution outcome to the chain, updating the outboxes, state hash and chain
952952
/// manager. This does not touch the execution state itself, which must be updated separately.
953953
/// Returns the set of event streams that were updated as a result of applying the block.
954-
#[instrument(target = "telemetry_only", skip_all, fields(
954+
#[instrument(skip_all, fields(
955955
chain_id = %self.chain_id(),
956956
block_height = %block.inner().inner().header.height
957957
))]
@@ -989,7 +989,7 @@ where
989989

990990
/// Adds a block to `preprocessed_blocks`, and updates the outboxes where possible.
991991
/// Returns the set of streams that were updated as a result of preprocessing the block.
992-
#[instrument(target = "telemetry_only", skip_all, fields(
992+
#[instrument(skip_all, fields(
993993
chain_id = %self.chain_id(),
994994
block_height = %block.inner().inner().header.height
995995
))]
@@ -1019,7 +1019,7 @@ where
10191019
}
10201020

10211021
/// Verifies that the block is valid according to the chain's application permission settings.
1022-
#[instrument(target = "telemetry_only", skip_all, fields(
1022+
#[instrument(skip_all, fields(
10231023
block_height = %block.height,
10241024
num_transactions = %block.transactions.len()
10251025
))]
@@ -1065,7 +1065,7 @@ where
10651065
}
10661066

10671067
/// Returns the hashes of all blocks we have in the given range.
1068-
#[instrument(target = "telemetry_only", skip_all, fields(
1068+
#[instrument(skip_all, fields(
10691069
chain_id = %self.chain_id(),
10701070
next_block_height = %self.tip_state.get().next_block_height,
10711071
start_height = ?range.start_bound(),
@@ -1123,7 +1123,7 @@ where
11231123
/// Updates the outboxes with the messages sent in the block.
11241124
///
11251125
/// Returns the set of all recipients.
1126-
#[instrument(target = "telemetry_only", skip_all, fields(
1126+
#[instrument(skip_all, fields(
11271127
chain_id = %self.chain_id(),
11281128
block_height = %block.header.height
11291129
))]
@@ -1218,7 +1218,7 @@ where
12181218
/// Updates the event streams with events emitted by the block if they form a contiguous
12191219
/// sequence (might not be the case when preprocessing a block).
12201220
/// Returns the set of updated event streams.
1221-
#[instrument(target = "telemetry_only", skip_all, fields(
1221+
#[instrument(skip_all, fields(
12221222
chain_id = %self.chain_id(),
12231223
block_height = %block.header.height
12241224
))]

linera-client/src/client_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub struct ClientContextOptions {
112112
#[arg(long, env = "LINERA_OTEL_TRACE_FILE")]
113113
pub otel_trace_file: Option<String>,
114114

115-
/// OpenTelemetry OTLP exporter endpoint (requires tempo feature).
115+
/// OpenTelemetry OTLP exporter endpoint (requires otel feature).
116116
#[arg(long, env = "LINERA_OTEL_EXPORTER_OTLP_ENDPOINT")]
117117
pub otel_exporter_otlp_endpoint: Option<String>,
118118

0 commit comments

Comments
 (0)