Skip to main content

NewSpan

Creates a new span with the given service name and span name, incorporating log fields from the context as span attributes.

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. This helps in organizing and filtering traces by the originating service.
spanNamestringThe name of the span, describing the specific operation or activity being traced. This name should be descriptive and unique within the context of the service.

Returns

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