Documentation ¶
Index ¶
- func NewTracer(tr opentracing.Tracer) opentracing.Tracer
- func StartSpanFromContext(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)
- func StartSpanFromContextWithTracer(ctx context.Context, tracer opentracing.Tracer, operationName string, ...) (opentracing.Span, context.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTracer ¶
func NewTracer(tr opentracing.Tracer) opentracing.Tracer
NewTracer creates a new opentracing.Tracer with the span profiler integrated.
For efficiency, the tracer selectively records profiles for _root_ spans — the initial _local_ span in a process — since a trace may encompass thousands of spans. All stack trace samples accumulated during the execution of their child spans contribute to the root span's profile. In practical terms, this signifies that, for instance, an HTTP request results in a singular profile, irrespective of the numerous spans within the trace. It's important to note that these profiles don't extend beyond the boundaries of a single process.
The limitation of this approach is that only spans created within the same goroutine, or its children, as the parent are taken into account. Consequently, in scenarios involving asynchronous execution, where the parent span context is passed to another goroutine, explicit profiling becomes necessary using `spanprofiler.StartSpanFromContext`.
func StartSpanFromContext ¶ added in v1.2.1
func StartSpanFromContext(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)
StartSpanFromContext starts and returns a Span with `operationName`, using any Span found within `ctx` as a ChildOfRef. If no such parent could be found, StartSpanFromContext creates a root (parentless) Span.
The call sets `operationName` as `span_name` pprof label, and the new span identifier as `span_id` pprof label, if the trace is sampled.
The second return value is a context.Context object built around the returned Span.
Example usage:
SomeFunction(ctx context.Context, ...) { sp, ctx := opentracing.StartSpanFromContext(ctx, "SomeFunction") defer sp.Finish() ... }
func StartSpanFromContextWithTracer ¶ added in v1.2.1
func StartSpanFromContextWithTracer(ctx context.Context, tracer opentracing.Tracer, operationName string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)
StartSpanFromContextWithTracer starts and returns a span with `operationName` using a span found within the context as a ChildOfRef. If that doesn't exist it creates a root span. It also returns a context.Context object built around the returned span.
The call sets `operationName` as `span_name` pprof label, and the new span identifier as `span_id` pprof label, if the trace is sampled.
It's behavior is identical to StartSpanFromContext except that it takes an explicit tracer as opposed to using the global tracer.
Types ¶
This section is empty.