Skip to content

Commit d9163ed

Browse files
committed
add diff spans to see if it works
1 parent e1fe885 commit d9163ed

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

crates/common/src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,17 @@ pub fn init_tracing(
1717
_service_version: String,
1818
otlp_endpoint: String,
1919
_log_level: String,
20-
otlp_port: u16,
20+
_otlp_port: u16,
2121
) -> anyhow::Result<(Targets, SdkTracer)> {
2222
global::set_text_map_propagator(TraceContextPropagator::new());
2323

2424
info!(
2525
message = "OTLP endpoint",
2626
endpoint = %otlp_endpoint
2727
);
28-
let h = format!(
29-
"http://{}:{}",
30-
std::env::var("DD_AGENT_HOST").unwrap_or_else(|_| "localhost".to_string()),
31-
otlp_port
32-
);
3328
let otlp_exporter = SpanExporter::builder()
3429
.with_tonic()
35-
.with_endpoint(h)
30+
.with_endpoint(otlp_endpoint)
3631
.build()
3732
.context("Failed to create OTLP exporter")?;
3833

crates/ingress-rpc/src/main.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,17 @@ async fn main() -> anyhow::Result<()> {
9898
};
9999

100100
if config.tracing_enabled {
101+
let h = format!(
102+
"http://{}:{}",
103+
std::env::var("DD_AGENT_HOST").unwrap_or_else(|_| "localhost".to_string()),
104+
config.tracing_otlp_port
105+
);
101106
let (trace_filter, tracer) = init_tracing(
102107
env!("CARGO_PKG_NAME").to_string(),
103108
env!("CARGO_PKG_VERSION").to_string(),
104-
config.tracing_otlp_endpoint,
109+
h.clone(),
105110
log_level.to_string(),
106-
config.tracing_otlp_port,
111+
4317,
107112
)?;
108113

109114
let log_filter = Targets::new()
@@ -132,6 +137,10 @@ async fn main() -> anyhow::Result<()> {
132137
config.tracing_otlp_endpoint,
133138
log_level.to_string(),
134139
)?;*/
140+
info!(
141+
message = "Tracing initialized",
142+
endpoint = %h,
143+
);
135144
}
136145
info!(
137146
message = "Starting ingress service",

crates/ingress-rpc/src/service.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use op_alloy_consensus::OpTxEnvelope;
1111
use op_alloy_network::Optimism;
1212
use reth_rpc_eth_types::EthApiError;
1313
use std::time::{SystemTime, UNIX_EPOCH};
14-
use tracing::{info, trace, warn};
14+
use tracing::{Instrument, info, span, trace, warn};
1515

1616
use crate::queue::QueuePublisher;
1717

@@ -97,12 +97,17 @@ where
9797
trace!(message = "Validating transaction", account = %transaction.signer(), transaction = %transaction.tx_hash());
9898
validate_tx(account, &transaction, &data, &mut l1_block_info).await?;
9999

100+
let span = span!(tracing::Level::INFO, "span_expiry", transaction = %transaction.tx_hash());
101+
let _enter = span.enter();
100102
let expiry_timestamp = SystemTime::now()
101103
.duration_since(UNIX_EPOCH)
102104
.unwrap()
103105
.as_secs()
104106
+ self.send_transaction_default_lifetime_seconds;
107+
drop(_enter);
105108

109+
let span = span!(tracing::Level::INFO, "span_send_raw_transaction", transaction = %transaction.tx_hash());
110+
let _enter = span.enter();
106111
let bundle = EthSendBundle {
107112
txs: vec![data.clone()],
108113
block_number: 0,
@@ -111,11 +116,14 @@ where
111116
reverting_tx_hashes: vec![transaction.tx_hash()],
112117
..Default::default()
113118
};
119+
drop(_enter);
114120

115121
// queue the bundle
116122
trace!(message = "Queueing bundle", bundle = ?bundle);
117123
let sender = transaction.signer();
118-
if let Err(e) = self.queue.publish(&bundle, sender).await {
124+
let span =
125+
span!(tracing::Level::INFO, "span_publish", transaction = %transaction.tx_hash());
126+
if let Err(e) = self.queue.publish(&bundle, sender).instrument(span).await {
119127
warn!(message = "Failed to publish Queue::enqueue_bundle", sender = %sender, error = %e);
120128
}
121129

0 commit comments

Comments
 (0)