Documentation
¶
Index ¶
- Constants
- func AdaptToolHandler(th ToolHandler) server.ToolHandlerFunc
- func AddEvent(span trace.Span, name string, attrs ...attribute.KeyValue)
- func ExtractHTTPHeaders(ctx context.Context) map[string]string
- func ExtractTraceInfo(ctx context.Context) (traceID, spanID string)
- func HTTPMiddleware(next http.Handler) http.Handler
- func RecordError(span trace.Span, err error, message string)
- func RecordSuccess(span trace.Span, message string)
- func SetupOTelSDK(ctx context.Context) error
- func StartSpan(ctx context.Context, operationName string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
- type Config
- type Telemetry
- type ToolHandler
Constants ¶
const ( HTTPHeadersKey contextKey = "http_headers" TraceIDKey contextKey = "trace_id" SpanIDKey contextKey = "span_id" )
const ( // Service identification OtelServiceName = "OTEL_SERVICE_NAME" OtelServiceVersion = "OTEL_SERVICE_VERSION" OtelEnvironment = "OTEL_ENVIRONMENT" // Custom extension, not in official spec // OTLP Exporter configuration OtelExporterOtlpEndpoint = "OTEL_EXPORTER_OTLP_ENDPOINT" OtelExporterOtlpProtocol = "OTEL_EXPORTER_OTLP_PROTOCOL" OtelExporterOtlpHeaders = "OTEL_EXPORTER_OTLP_HEADERS" // Trace-specific OTLP configuration OtelExporterOtlpTracesInsecure = "OTEL_EXPORTER_OTLP_TRACES_INSECURE" // Sampling configuration OtelTracesSamplerArg = "OTEL_TRACES_SAMPLER_ARG" // SDK control OtelSdkDisabled = "OTEL_SDK_DISABLED" )
Standard OpenTelemetry environment variable names These follow the official OTLP specification
const ( ProtocolGRPC = "grpc" ProtocolHTTP = "http/protobuf" ProtocolAuto = "auto" // Custom extension for automatic protocol detection )
OTLP Protocol constants
const ( DefaultOtlpGrpcPort = "4317" // Standard OTLP/gRPC port DefaultOtlpHttpPort = "4318" // Standard OTLP/HTTP port )
Standard OTLP port numbers These are the official OTLP default ports as per OpenTelemetry specification
const (
DefaultHttpTracesPath = "/v1/traces"
)
Default endpoint paths
Variables ¶
This section is empty.
Functions ¶
func AdaptToolHandler ¶
func AdaptToolHandler(th ToolHandler) server.ToolHandlerFunc
AdaptToolHandler adapts a telemetry.ToolHandler to a server.ToolHandlerFunc.
func ExtractHTTPHeaders ¶
ExtractHTTPHeaders retrieves HTTP headers from context
func ExtractTraceInfo ¶
ExtractTraceInfo retrieves trace information from context
func HTTPMiddleware ¶
HTTPMiddleware wraps an HTTP handler to extract headers and propagate context
func RecordSuccess ¶
func SetupOTelSDK ¶
SetupOTelSDK initializes the OpenTelemetry SDK
Types ¶
type Config ¶
type Config struct {
Telemetry Telemetry
}
Config holds all application configuration.
func LoadOtelCfg ¶
func LoadOtelCfg() *Config
LoadOtelCfg initializes and returns the application configuration.
type Telemetry ¶
type Telemetry struct {
ServiceName string
ServiceVersion string
Environment string
Endpoint string
Protocol string
SamplingRatio float64
Insecure bool
Disabled bool
}
Telemetry holds all telemetry-related configuration.
type ToolHandler ¶
type ToolHandler func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)
func WithTracing ¶
func WithTracing(toolName string, handler ToolHandler) ToolHandler