tracing

package
v0.54.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package tracing defines the tracing interfaces used by the mcp-go client and server. Concrete implementations live in adapter modules; an OpenTelemetry adapter ships at github.com/mark3labs/mcp-go/otel.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithSpan

func ContextWithSpan(ctx context.Context, span Span) context.Context

ContextWithSpan returns ctx annotated with span so SpanFromContext can later retrieve it.

Types

type Attribute

type Attribute struct {
	Key, Value string
}

Attribute is a string key/value pair attached to a span.

func String

func String(key, value string) Attribute

String returns an Attribute with the given key and value.

type Propagator

type Propagator interface {
	Inject(ctx context.Context, headers http.Header)
	Extract(ctx context.Context, headers http.Header) context.Context
}

Propagator carries tracing context across HTTP requests.

func NoopPropagator

func NoopPropagator() Propagator

NoopPropagator returns a Propagator whose methods are no-ops.

type Span

type Span interface {
	SetAttributes(attrs ...Attribute)
	RecordError(err error)
	SetStatus(code StatusCode, description string)
	End()
}

Span is an in-flight tracing span. End must be called exactly once.

func SpanFromContext

func SpanFromContext(ctx context.Context) Span

SpanFromContext returns the active Span, or a non-recording noop if none is present.

type SpanKind

type SpanKind int

SpanKind identifies the role of a span in a trace.

const (
	SpanKindUnspecified SpanKind = iota
	SpanKindServer
	SpanKindClient
	SpanKindInternal
)

type StatusCode

type StatusCode int

StatusCode describes the final outcome status of a span.

const (
	StatusUnset StatusCode = iota
	StatusOK
	StatusError
)

type Tracer

type Tracer interface {
	Start(ctx context.Context, name string, kind SpanKind, attrs ...Attribute) (context.Context, Span)
}

Tracer starts spans. Start returns a context carrying the new span and the span itself.

func NoopTracer

func NoopTracer() Tracer

NoopTracer returns a Tracer that records nothing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL