startSpanWithContext method
APISpan
startSpanWithContext({
- required String name,
- required Context context,
- SpanKind kind = SpanKind.internal,
- Attributes? attributes,
Starts a span with the given context instead of the current context Sets the current span in the given context
Implementation
APISpan startSpanWithContext({
required String name,
required Context context,
SpanKind kind = SpanKind.internal,
Attributes? attributes,
}) {
final span = startSpan(
name,
context: context,
kind: kind,
attributes: attributes,
);
// Set the span in the context we were given
final updatedContext = context.setCurrentSpan(span);
// Also update the current global context if needed
if (Context.current == context) {
Context.current = updatedContext;
}
return span;
}