Skip to content

Commit 7f06500

Browse files
authored
Implement custom OpenTelemetry sampler to filter uninstrumented traces (#8647)
Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>
1 parent 21cabba commit 7f06500

File tree

24 files changed

+139
-157
lines changed

24 files changed

+139
-157
lines changed

Cargo.lock

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ members = [
1111
"beacon_node/http_api",
1212
"beacon_node/http_metrics",
1313
"beacon_node/lighthouse_network",
14-
"beacon_node/lighthouse_tracing",
1514
"beacon_node/network",
1615
"beacon_node/operation_pool",
1716
"beacon_node/store",
@@ -44,6 +43,7 @@ members = [
4443
"common/target_check",
4544
"common/task_executor",
4645
"common/test_random_derive",
46+
"common/tracing_samplers",
4747
"common/validator_dir",
4848
"common/warp_utils",
4949
"common/workspace_members",
@@ -182,7 +182,6 @@ libp2p = { git = "https://github.com/libp2p/rust-libp2p.git", default-features =
182182
] }
183183
libsecp256k1 = "0.7"
184184
lighthouse_network = { path = "beacon_node/lighthouse_network" }
185-
lighthouse_tracing = { path = "beacon_node/lighthouse_tracing" }
186185
lighthouse_validator_store = { path = "validator_client/lighthouse_validator_store" }
187186
lighthouse_version = { path = "common/lighthouse_version" }
188187
lockfile = { path = "common/lockfile" }
@@ -269,6 +268,7 @@ tracing-core = "0.1"
269268
tracing-log = "0.2"
270269
tracing-opentelemetry = "0.31.0"
271270
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
271+
tracing_samplers = { path = "common/tracing_samplers" }
272272
tree_hash = "0.12.0"
273273
tree_hash_derive = "0.12.0"
274274
typenum = "1"

beacon_node/beacon_chain/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ hex = { workspace = true }
3434
int_to_bytes = { workspace = true }
3535
itertools = { workspace = true }
3636
kzg = { workspace = true }
37-
lighthouse_tracing = { workspace = true }
3837
lighthouse_version = { workspace = true }
3938
logging = { workspace = true }
4039
lru = { workspace = true }

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ use futures::channel::mpsc::Sender;
9191
use itertools::Itertools;
9292
use itertools::process_results;
9393
use kzg::Kzg;
94-
use lighthouse_tracing::SPAN_PRODUCE_UNAGGREGATED_ATTESTATION;
9594
use logging::crit;
9695
use operation_pool::{
9796
CompactAttestationRef, OperationPool, PersistedOperationPool, ReceivedPreCapella,
@@ -1843,7 +1842,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
18431842
/// ## Errors
18441843
///
18451844
/// May return an error if the `request_slot` is too far behind the head state.
1846-
#[instrument(name = SPAN_PRODUCE_UNAGGREGATED_ATTESTATION, skip_all, fields(%request_slot, %request_index), level = "debug")]
1845+
#[instrument(name = "lh_produce_unaggregated_attestation", skip_all, fields(%request_slot, %request_index), level = "debug")]
18471846
pub fn produce_unaggregated_attestation(
18481847
&self,
18491848
request_slot: Slot,

beacon_node/beacon_chain/src/canonical_head.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use fork_choice::{
4747
ResetPayloadStatuses,
4848
};
4949
use itertools::process_results;
50-
use lighthouse_tracing::SPAN_RECOMPUTE_HEAD;
50+
5151
use logging::crit;
5252
use parking_lot::{Mutex, RwLock, RwLockReadGuard, RwLockUpgradableReadGuard, RwLockWriteGuard};
5353
use slot_clock::SlotClock;
@@ -514,7 +514,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
514514
/// can't abort block import because an error is returned here.
515515
pub async fn recompute_head_at_slot(self: &Arc<Self>, current_slot: Slot) {
516516
let span = info_span!(
517-
SPAN_RECOMPUTE_HEAD,
517+
"lh_recompute_head_at_slot",
518518
slot = %current_slot
519519
);
520520

beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::block_verification_types::{
99
use crate::data_availability_checker::{Availability, AvailabilityCheckError};
1010
use crate::data_column_verification::KzgVerifiedCustodyDataColumn;
1111
use crate::{BeaconChainTypes, BlockProcessStatus};
12-
use lighthouse_tracing::SPAN_PENDING_COMPONENTS;
1312
use lru::LruCache;
1413
use parking_lot::{MappedRwLockReadGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
1514
use ssz_types::{RuntimeFixedVector, RuntimeVariableList};
@@ -334,7 +333,7 @@ impl<E: EthSpec> PendingComponents<E> {
334333

335334
/// Returns an empty `PendingComponents` object with the given block root.
336335
pub fn empty(block_root: Hash256, max_len: usize) -> Self {
337-
let span = debug_span!(parent: None, SPAN_PENDING_COMPONENTS, %block_root);
336+
let span = debug_span!(parent: None, "lh_pending_components", %block_root);
338337
let _guard = span.clone().entered();
339338
Self {
340339
block_root,

beacon_node/http_api/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ futures = { workspace = true }
2323
health_metrics = { workspace = true }
2424
hex = { workspace = true }
2525
lighthouse_network = { workspace = true }
26-
lighthouse_tracing = { workspace = true }
2726
lighthouse_version = { workspace = true }
2827
logging = { workspace = true }
2928
lru = { workspace = true }

beacon_node/http_api/src/produce_block.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use beacon_chain::{
1212
};
1313
use eth2::beacon_response::ForkVersionedResponse;
1414
use eth2::types::{self as api_types, ProduceBlockV3Metadata, SkipRandaoVerification};
15-
use lighthouse_tracing::{SPAN_PRODUCE_BLOCK_V2, SPAN_PRODUCE_BLOCK_V3};
1615
use ssz::Encode;
1716
use std::sync::Arc;
1817
use tracing::instrument;
@@ -45,7 +44,7 @@ pub fn get_randao_verification(
4544
}
4645

4746
#[instrument(
48-
name = SPAN_PRODUCE_BLOCK_V3,
47+
name = "lh_produce_block_v3",
4948
skip_all,
5049
fields(%slot)
5150
)]
@@ -169,7 +168,7 @@ pub async fn produce_blinded_block_v2<T: BeaconChainTypes>(
169168
}
170169

171170
#[instrument(
172-
name = SPAN_PRODUCE_BLOCK_V2,
171+
name = "lh_produce_block_v2",
173172
skip_all,
174173
fields(%slot)
175174
)]

beacon_node/http_api/src/publish_blocks.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use eth2::{
1919
use execution_layer::{ProvenancedPayload, SubmitBlindedBlockResponse};
2020
use futures::TryFutureExt;
2121
use lighthouse_network::PubsubMessage;
22-
use lighthouse_tracing::SPAN_PUBLISH_BLOCK;
2322
use network::NetworkMessage;
2423
use rand::prelude::SliceRandom;
2524
use slot_clock::SlotClock;
@@ -79,7 +78,7 @@ impl<T: BeaconChainTypes> ProvenancedBlock<T, Arc<SignedBeaconBlock<T::EthSpec>>
7978
/// Handles a request from the HTTP API for full blocks.
8079
#[allow(clippy::too_many_arguments)]
8180
#[instrument(
82-
name = SPAN_PUBLISH_BLOCK,
81+
name = "lh_publish_block",
8382
level = "info",
8483
skip_all,
8584
fields(block_root = field::Empty, ?validation_level, block_slot = field::Empty, provenance = field::Empty)

beacon_node/lighthouse_tracing/Cargo.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)