Skip to main content

NewSpan

NewSpan creates a new span with the given service name and span name.

def NewSpan(
ctx: context.Context,
serviceName: string,
spanName: string
) - > tuple[context.Context, rawtrace.Span]

Creates a new span with the given service name and span name. This function is used to initiate a new tracing span within a specific service context, allowing for detailed performance monitoring and distributed tracing.

Parameters

NameTypeDescription
ctxcontext.ContextThe context object, potentially containing existing trace information or log fields that will be added as attributes to the new span.
serviceNamestringThe name of the service associated with this span, used to identify the source of the trace.
spanNamestringThe name of the span, providing a descriptive label for the operation being traced.

Returns

TypeDescription
tuple[context.Context, rawtrace.Span]A tuple containing the updated context with the new span and the rawtrace.Span object itself.