Skip to content

Commit

Permalink
Report link in attributes example
Browse files Browse the repository at this point in the history
  • Loading branch information
frigus02 committed May 15, 2024
1 parent b713bba commit bc831a6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion examples/attributes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use opentelemetry::{
trace::{
get_active_span, mark_span_as_active, SpanKind, TraceContextExt, Tracer, TracerProvider,
get_active_span, mark_span_as_active, Link, SpanKind, TraceContextExt, Tracer,
TracerProvider,
},
Context, KeyValue,
};
Expand Down Expand Up @@ -110,6 +111,14 @@ fn main() {
log();
custom();
exception();

get_active_span(|span| {
let builder = server_tracer
.span_builder("async operation")
.with_links(vec![Link::new(span.span_context().clone(), Vec::new())]);
let new_context = Context::new();
let _span = server_tracer.build_with_context(builder, &new_context);
})
}
}
}

0 comments on commit bc831a6

Please sign in to comment.