Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support OpenTelemetry sampling on az.namespace attribute #42548

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.util.function.BiConsumer;
import java.util.function.Function;

import static java.util.Collections.singletonMap;

/**
* Basic tracing implementation class for use with REST and AMQP Service Clients to create {@link Span} and in-process
* context propagation. Singleton OpenTelemetry tracer capable of starting and exporting spans.
Expand Down Expand Up @@ -150,16 +152,15 @@ public Context start(String spanName, StartSpanOptions options, Context context)
spanBuilder.setStartTimestamp(options.getStartTimestamp());
}

Span span = spanBuilder.startSpan();
if (span.isRecording()) {
// If span is sampled in, add additional attributes

String tracingNamespace = getAzNamespace(context);
if (tracingNamespace != null) {
OpenTelemetryUtils.addAttribute(span, AZ_TRACING_NAMESPACE_KEY, tracingNamespace);
}
String tracingNamespace = getAzNamespace(context);
if (tracingNamespace != null) {
Attributes attributes
= OpenTelemetryUtils.convert(singletonMap(AZ_TRACING_NAMESPACE_KEY, tracingNamespace));
spanBuilder.setAllAttributes(attributes);
}

Span span = spanBuilder.startSpan();

return context.addData(PARENT_TRACE_CONTEXT_KEY,
(traceContext != null ? traceContext : io.opentelemetry.context.Context.current()).with(span));
}
Expand Down
Loading