...

Package tracing

import "k8s.io/component-base/tracing"
Overview
Index
Subdirectories

Overview ▾

func ContextWithSpan

func ContextWithSpan(ctx context.Context, s *Span) context.Context

ContextWithSpan returns a context with the Span included in the context.

func Propagators

func Propagators() propagation.TextMapPropagator

Propagators returns the recommended set of propagators.

func WithTracing

func WithTracing(handler http.Handler, tp oteltrace.TracerProvider, spanName string) http.Handler

WithTracing adds tracing to requests if the incoming request is sampled

func WrapperFor

func WrapperFor(tp oteltrace.TracerProvider) transport.WrapperFunc

WrapperFor can be used to add tracing to a *rest.Config. Example usage: tp := NewProvider(...) config, _ := rest.InClusterConfig() config.Wrap(WrapperFor(tp)) kubeclient, _ := clientset.NewForConfig(config)

type Span

Span is a component part of a trace. It represents a single named and timed operation of a workflow being observed. This Span is a combination of an OpenTelemetry and k8s.io/utils/trace span to facilitate the migration to OpenTelemetry.

type Span struct {
    // contains filtered or unexported fields
}

func SpanFromContext

func SpanFromContext(ctx context.Context) *Span

SpanFromContext returns the *Span from the current context. It is composed of the active OpenTelemetry and k8s.io/utils/trace spans.

func Start

func Start(ctx context.Context, name string, attributes ...attribute.KeyValue) (context.Context, *Span)

Start creates spans using both OpenTelemetry, and the k8s.io/utils/trace package. It only creates an OpenTelemetry span if the incoming context already includes a span.

func (*Span) AddEvent

func (s *Span) AddEvent(name string, attributes ...attribute.KeyValue)

AddEvent adds a point-in-time event with a name and attributes.

func (*Span) End

func (s *Span) End(logThreshold time.Duration)

End ends the span, and logs if the span duration is greater than the logThreshold.

func (*Span) RecordError

func (s *Span) RecordError(err error, attributes ...attribute.KeyValue)

RecordError will record err as an exception span event for this span. If this span is not being recorded or err is nil then this method does nothing.

type TracerProvider

TracerProvider is an OpenTelemetry TracerProvider which can be shut down

type TracerProvider interface {
    oteltrace.TracerProvider
    Shutdown(context.Context) error
}

func NewNoopTracerProvider

func NewNoopTracerProvider() TracerProvider

func NewProvider

func NewProvider(ctx context.Context,
    tracingConfig *v1.TracingConfiguration,
    addedOpts []otlptracegrpc.Option,
    resourceOpts []resource.Option,
) (TracerProvider, error)

NewProvider creates a TracerProvider in a component, and enforces recommended tracing behavior

Subdirectories

Name Synopsis
..
api
v1