From bc831a62c68c6748eeff16a9cdf0b16571f148b4 Mon Sep 17 00:00:00 2001 From: Jan Kuehle Date: Thu, 9 May 2024 23:16:35 +0200 Subject: [PATCH] Report link in attributes example --- examples/attributes.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/attributes.rs b/examples/attributes.rs index 9ce4a3b..87b60c6 100644 --- a/examples/attributes.rs +++ b/examples/attributes.rs @@ -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, }; @@ -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); + }) } } }