Skip to content

Commit 6598199

Browse files
committed
Make sending traces to Tempo less confusing
1 parent 264b7ec commit 6598199

File tree

7 files changed

+101
-183
lines changed

7 files changed

+101
-183
lines changed

linera-base/src/tracing_otel.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ use {
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

2017
/// Initializes tracing with OpenTelemetry OTLP exporter to Tempo.
@@ -43,15 +40,9 @@ pub fn init_with_opentelemetry(log_name: &str, otlp_endpoint: Option<&str>) {
4340
global::set_tracer_provider(tracer_provider.clone());
4441
let tracer = tracer_provider.tracer("linera");
4542

46-
let telemetry_only_filter =
47-
filter_fn(|metadata| metadata.is_span() && metadata.target() == "telemetry_only");
43+
let tempo_filter = filter_fn(|metadata| metadata.is_span() && metadata.target() != "no_tempo");
4844

49-
let otel_env_filter = tracing_subscriber::EnvFilter::builder()
50-
.with_default_directive(tracing_subscriber::filter::LevelFilter::INFO.into())
51-
.from_env_lossy();
52-
53-
let opentelemetry_filter = otel_env_filter.or(telemetry_only_filter);
54-
let opentelemetry_layer = OpenTelemetryLayer::new(tracer).with_filter(opentelemetry_filter);
45+
let opentelemetry_layer = OpenTelemetryLayer::new(tracer).with_filter(tempo_filter);
5546

5647
let config = crate::tracing::get_env_config(log_name);
5748
let maybe_log_file_layer = config.maybe_log_file_layer();

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: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ where
392392
self.context().extra().chain_id()
393393
}
394394

395-
#[instrument(target = "telemetry_only", skip_all, fields(
395+
#[instrument(skip_all, fields(
396396
chain_id = %self.chain_id(),
397397
))]
398398
pub async fn query_application(
@@ -412,7 +412,7 @@ where
412412
.with_execution_context(ChainExecutionContext::Query)
413413
}
414414

415-
#[instrument(target = "telemetry_only", skip_all, fields(
415+
#[instrument(skip_all, fields(
416416
chain_id = %self.chain_id(),
417417
application_id = %application_id
418418
))]
@@ -427,7 +427,7 @@ where
427427
.with_execution_context(ChainExecutionContext::DescribeApplication)
428428
}
429429

430-
#[instrument(target = "telemetry_only", skip_all, fields(
430+
#[instrument(skip_all, fields(
431431
chain_id = %self.chain_id(),
432432
target = %target,
433433
height = %height
@@ -519,7 +519,7 @@ where
519519

520520
/// Verifies that this chain is up-to-date and all the messages executed ahead of time
521521
/// have been properly received by now.
522-
#[instrument(target = "telemetry_only", skip_all, fields(
522+
#[instrument(skip_all, fields(
523523
chain_id = %self.chain_id()
524524
))]
525525
pub async fn validate_incoming_bundles(&self) -> Result<(), ChainError> {
@@ -544,7 +544,7 @@ where
544544

545545
/// Collects all missing sender blocks from removed bundles across all inboxes.
546546
/// Returns a map of origin chain IDs to their respective missing block heights.
547-
#[instrument(target = "telemetry_only", skip_all, fields(
547+
#[instrument(skip_all, fields(
548548
chain_id = %self.chain_id()
549549
))]
550550
pub async fn collect_missing_sender_blocks(
@@ -610,7 +610,7 @@ where
610610
/// round timeouts.
611611
///
612612
/// Returns `true` if incoming `Subscribe` messages created new outbox entries.
613-
#[instrument(target = "telemetry_only", skip_all, fields(
613+
#[instrument(skip_all, fields(
614614
chain_id = %self.chain_id(),
615615
origin = %origin,
616616
bundle_height = %bundle.height
@@ -709,7 +709,7 @@ where
709709
}
710710

711711
/// Removes the incoming message bundles in the block from the inboxes.
712-
#[instrument(target = "telemetry_only", skip_all, fields(
712+
#[instrument(skip_all, fields(
713713
chain_id = %self.chain_id(),
714714
))]
715715
pub async fn remove_bundles_from_inboxes(
@@ -801,7 +801,7 @@ where
801801

802802
/// Executes a block: first the incoming messages, then the main operation.
803803
/// Does not update chain state other than the execution state.
804-
#[instrument(target = "telemetry_only", skip_all, fields(
804+
#[instrument(skip_all, fields(
805805
chain_id = %block.chain_id,
806806
block_height = %block.height
807807
))]
@@ -914,7 +914,7 @@ where
914914

915915
/// Executes a block: first the incoming messages, then the main operation.
916916
/// Does not update chain state other than the execution state.
917-
#[instrument(target = "telemetry_only", skip_all, fields(
917+
#[instrument(skip_all, fields(
918918
chain_id = %self.chain_id(),
919919
block_height = %block.height
920920
))]
@@ -978,7 +978,7 @@ where
978978
/// Applies an execution outcome to the chain, updating the outboxes, state hash and chain
979979
/// manager. This does not touch the execution state itself, which must be updated separately.
980980
/// Returns the set of event streams that were updated as a result of applying the block.
981-
#[instrument(target = "telemetry_only", skip_all, fields(
981+
#[instrument(skip_all, fields(
982982
chain_id = %self.chain_id(),
983983
block_height = %block.inner().inner().header.height
984984
))]
@@ -1016,7 +1016,7 @@ where
10161016

10171017
/// Adds a block to `preprocessed_blocks`, and updates the outboxes where possible.
10181018
/// Returns the set of streams that were updated as a result of preprocessing the block.
1019-
#[instrument(target = "telemetry_only", skip_all, fields(
1019+
#[instrument(skip_all, fields(
10201020
chain_id = %self.chain_id(),
10211021
block_height = %block.inner().inner().header.height
10221022
))]
@@ -1046,7 +1046,7 @@ where
10461046
}
10471047

10481048
/// Verifies that the block is valid according to the chain's application permission settings.
1049-
#[instrument(target = "telemetry_only", skip_all, fields(
1049+
#[instrument(skip_all, fields(
10501050
block_height = %block.height,
10511051
num_transactions = %block.transactions.len()
10521052
))]
@@ -1092,7 +1092,7 @@ where
10921092
}
10931093

10941094
/// Returns the hashes of all blocks we have in the given range.
1095-
#[instrument(target = "telemetry_only", skip_all, fields(
1095+
#[instrument(skip_all, fields(
10961096
chain_id = %self.chain_id(),
10971097
next_block_height = %self.tip_state.get().next_block_height,
10981098
start_height = ?range.start_bound(),
@@ -1143,7 +1143,7 @@ where
11431143
/// Updates the outboxes with the messages sent in the block.
11441144
///
11451145
/// Returns the set of all recipients.
1146-
#[instrument(target = "telemetry_only", skip_all, fields(
1146+
#[instrument(skip_all, fields(
11471147
chain_id = %self.chain_id(),
11481148
block_height = %block.header.height
11491149
))]
@@ -1238,7 +1238,7 @@ where
12381238
/// Updates the event streams with events emitted by the block if they form a contiguous
12391239
/// sequence (might not be the case when preprocessing a block).
12401240
/// Returns the set of updated event streams.
1241-
#[instrument(target = "telemetry_only", skip_all, fields(
1241+
#[instrument(skip_all, fields(
12421242
chain_id = %self.chain_id(),
12431243
block_height = %block.header.height
12441244
))]

0 commit comments

Comments
 (0)