Documentation
¶
Index ¶
- func AddAttributes(ctx context.Context, attrs map[string]interface{})
- func AddEvent(ctx context.Context, name string, attrs map[string]interface{})
- func AddSpanAttributes(ctx context.Context, attrs ...attribute.KeyValue)
- func AddSpanEvent(ctx context.Context, name string, attrs ...attribute.KeyValue)
- func DecrementHTTPRequestsInFlight(service string)
- func ExtractContext(ctx context.Context, headers map[string]string) context.Context
- func FiberMiddleware(serviceName string) fiber.Handler
- func GetSpanID(ctx context.Context) string
- func GetTraceID(ctx context.Context) string
- func HTTPMiddleware(serviceName string) func(http.Handler) http.Handler
- func Handler() http.Handler
- func IncrementHTTPRequestsInFlight(service string)
- func InitMetrics(cfg *MetricsConfig)
- func InitTracing(cfg *TraceConfig) error
- func InjectContext(ctx context.Context) map[string]string
- func IsInitialized() bool
- func IsMetricsEnabled() bool
- func IsRecording(ctx context.Context) bool
- func RecordAIRequest(service, model string, success bool, duration time.Duration)
- func RecordCacheHit(service, cache string)
- func RecordCacheMiss(service, cache string)
- func RecordDBQuery(service, operation string, success bool, duration time.Duration)
- func RecordError(ctx context.Context, err error, opts ...trace.EventOption)
- func RecordExternalAPICall(service, provider, endpoint string, success bool, duration time.Duration)
- func RecordGRPCRequest(service, method, status string, duration time.Duration)
- func RecordHTTPRequest(service, method, endpoint string, statusCode int, duration time.Duration)
- func RecordTokenSync(service string, success bool, duration time.Duration)
- func SetDBConnections(service string, count float64)
- func SetSpanStatus(ctx context.Context, code codes.Code, description string)
- func ShutdownTracing(ctx context.Context) error
- func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- func StartSpanWithAttributes(ctx context.Context, name string, attrs map[string]interface{}) (context.Context, trace.Span)
- func TraceGRPCMiddleware(serviceName string) grpc.UnaryServerInterceptor
- func TraceHTTPMiddleware(serviceName string) func(http.Handler) http.Handler
- func Tracer() trace.Tracer
- func WithComponent(ctx context.Context, component string) context.Context
- func WithOperation(ctx context.Context, operation string) context.Context
- func WithRequestID(ctx context.Context, requestID string) context.Context
- func WithSpan(ctx context.Context, name string, fn func(context.Context) error) error
- func WithUserID(ctx context.Context, userID string) context.Context
- type ExporterType
- type MetricsConfig
- type TraceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAttributes ¶ added in v0.1.2
AddAttributes adds attributes to the current span in the context
func AddSpanAttributes ¶
AddSpanAttributes adds attributes to the current span
func AddSpanEvent ¶
AddSpanEvent adds an event to the current span
func DecrementHTTPRequestsInFlight ¶
func DecrementHTTPRequestsInFlight(service string)
DecrementHTTPRequestsInFlight decrements the in-flight HTTP requests gauge
func ExtractContext ¶ added in v0.1.2
ExtractContext extracts trace context from a map
func FiberMiddleware ¶
FiberMiddleware returns Fiber middleware that records HTTP request metrics
func GetTraceID ¶
GetTraceID returns the trace ID from the context if available
func HTTPMiddleware ¶
HTTPMiddleware returns middleware that records HTTP request metrics
func IncrementHTTPRequestsInFlight ¶
func IncrementHTTPRequestsInFlight(service string)
IncrementHTTPRequestsInFlight increments the in-flight HTTP requests gauge
func InitMetrics ¶ added in v0.1.2
func InitMetrics(cfg *MetricsConfig)
InitMetrics initializes the metrics with custom configuration
func InitTracing ¶
func InitTracing(cfg *TraceConfig) error
InitTracing initializes the OpenTelemetry tracing
func InjectContext ¶ added in v0.1.2
InjectContext injects trace context into a map for propagation
func IsInitialized ¶
func IsInitialized() bool
IsInitialized returns whether tracing has been initialized
func IsMetricsEnabled ¶ added in v0.1.2
func IsMetricsEnabled() bool
IsMetricsEnabled returns whether metrics are enabled
func IsRecording ¶ added in v0.1.2
IsRecording returns whether the current span is recording
func RecordAIRequest ¶
RecordAIRequest records an AI request
func RecordCacheMiss ¶
func RecordCacheMiss(service, cache string)
RecordCacheMiss records a cache miss
func RecordDBQuery ¶
RecordDBQuery records a database query
func RecordError ¶
func RecordError(ctx context.Context, err error, opts ...trace.EventOption)
RecordError records an error on the current span
func RecordExternalAPICall ¶
func RecordExternalAPICall(service, provider, endpoint string, success bool, duration time.Duration)
RecordExternalAPICall records an external API call
func RecordGRPCRequest ¶
RecordGRPCRequest records a gRPC request
func RecordHTTPRequest ¶
RecordHTTPRequest records an HTTP request
func RecordTokenSync ¶
RecordTokenSync records a token sync operation
func SetDBConnections ¶
SetDBConnections sets the number of active database connections
func SetSpanStatus ¶
SetSpanStatus sets the status of the current span
func ShutdownTracing ¶
ShutdownTracing shuts down the trace provider and flushes remaining spans
func StartSpan ¶
func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
StartSpan starts a new span with the given name
func StartSpanWithAttributes ¶ added in v0.1.2
func StartSpanWithAttributes(ctx context.Context, name string, attrs map[string]interface{}) (context.Context, trace.Span)
StartSpanWithAttributes creates a new span with attributes
func TraceGRPCMiddleware ¶ added in v0.1.2
func TraceGRPCMiddleware(serviceName string) grpc.UnaryServerInterceptor
TraceGRPCMiddleware returns a gRPC unary interceptor that traces RPC calls
func TraceHTTPMiddleware ¶ added in v0.1.2
TraceHTTPMiddleware returns a middleware that traces HTTP requests
func WithComponent ¶ added in v0.1.2
WithComponent returns a context with a component name attribute
func WithOperation ¶ added in v0.1.2
WithOperation returns a context with an operation name attribute
func WithRequestID ¶ added in v0.1.2
WithRequestID returns a context with a request ID attribute
Types ¶
type ExporterType ¶
type ExporterType string
ExporterType defines the type of trace exporter
const ( ExporterNone ExporterType = "none" ExporterStdout ExporterType = "stdout" ExporterOTLP ExporterType = "otlp" )
type MetricsConfig ¶ added in v0.1.2
MetricsConfig holds configuration for metrics
func DefaultMetricsConfig ¶ added in v0.1.2
func DefaultMetricsConfig(serviceName string) *MetricsConfig
DefaultMetricsConfig returns default metrics configuration
type TraceConfig ¶
type TraceConfig struct {
ServiceName string
ServiceVersion string
Environment string
Exporter ExporterType
OTLPEndpoint string
SampleRate float64
TLSEnabled bool
TLSConfig *tls.Config
}
TraceConfig holds configuration for tracing
func DefaultConfig ¶
func DefaultConfig(serviceName string) *TraceConfig
DefaultConfig returns a default trace configuration