func ContextWithSpan(ctx context.Context, s *Span) context.Context
ContextWithSpan returns a context with the Span included in the context.
func Propagators() propagation.TextMapPropagator
Propagators returns the recommended set of propagators.
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(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)
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(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(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 (s *Span) AddEvent(name string, attributes ...attribute.KeyValue)
AddEvent adds a point-in-time event with a name and attributes.
func (s *Span) End(logThreshold time.Duration)
End ends the span, and logs if the span duration is greater than the logThreshold.
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.
TracerProvider is an OpenTelemetry TracerProvider which can be shut down
type TracerProvider interface { oteltrace.TracerProvider Shutdown(context.Context) error }
func NewNoopTracerProvider() TracerProvider
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