-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6343b0f
commit 6f99bd2
Showing
2 changed files
with
24 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
use opentelemetry::trace::{SpanContext, SpanId, TraceFlags, TraceId, TraceState}; | ||
use opentelemetry::{ | ||
global, | ||
trace::{Span, SpanContext, SpanId, TraceContextExt, TraceFlags, TraceId, TraceState, Tracer}, | ||
Context, | ||
}; | ||
|
||
pub fn trace_from_message_attributes(trace_id: &str, span_id: &str) -> eyre::Result<SpanContext> { | ||
tracing::info!( | ||
"Creating span context from message attributes. trace id: {}, span id: {}", | ||
trace_id, | ||
span_id | ||
); | ||
|
||
// Create and set the span parent context | ||
let parent_ctx = SpanContext::new( | ||
let parent_span_ctx = SpanContext::new( | ||
TraceId::from(trace_id.parse::<u128>()?), | ||
SpanId::from(span_id.parse::<u64>()?), | ||
TraceFlags::default(), | ||
true, | ||
TraceState::default(), | ||
); | ||
|
||
Ok(parent_ctx) | ||
let parent_ctx = Context::new().with_remote_span_context(parent_span_ctx); | ||
let tracer = global::tracer("mpcv2-batch-tracer"); | ||
let mut span = tracer | ||
.span_builder("mpcv2-batch-item") | ||
.start_with_context(&tracer, &parent_ctx); | ||
span.add_event("Created batch span item", vec![]); | ||
Ok(span.span_context().clone()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters