Documentation
¶
Index ¶
- func AddAttribute(ctx context.Context, key string, value interface{})
- func AddEvent(ctx context.Context, name string, attributes ...attribute.KeyValue)
- func Configure(serviceName string)
- func RecordError(ctx context.Context, err error)
- func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- func TraceMiddleware(serviceName string) func(http.Handler) http.Handler
- type ContextKey
- type Logger
- func (l *Logger) Debug(msg string, fields ...map[string]interface{})
- func (l *Logger) Error(msg string, err error, fields ...map[string]interface{})
- func (l *Logger) Fatal(msg string, err error, fields ...map[string]interface{})
- func (l *Logger) Info(msg string, fields ...map[string]interface{})
- func (l *Logger) Warn(msg string, fields ...map[string]interface{})
- func (l *Logger) WithContext(ctx context.Context) *Logger
- func (l *Logger) WithFields(fields map[string]interface{}) *Logger
- type MetricsServer
- func (ms *MetricsServer) Middleware(serviceName string) func(http.Handler) http.Handler
- func (ms *MetricsServer) NewCounter(name, help string, labels ...string) prometheus.Counter
- func (ms *MetricsServer) NewGauge(name, help string, labels ...string) prometheus.Gauge
- func (ms *MetricsServer) NewHistogram(name, help string, buckets []float64, labels ...string) prometheus.Histogram
- func (ms *MetricsServer) NewSummary(name, help string, objectives map[float64]float64, labels ...string) prometheus.Summary
- func (ms *MetricsServer) Start() error
- func (ms *MetricsServer) Stop() error
- type Timer
- type TracingProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAttribute ¶
AddAttribute adds an attribute to the current span
func RecordError ¶
RecordError records an error in the current span
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey is a type for context keys
const ( RequestIDKey ContextKey = "request_id" UserIDKey ContextKey = "user_id" ServiceKey ContextKey = "service" )
Context keys
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a structured logger
func (*Logger) WithContext ¶
WithContext returns a logger with context values
func (*Logger) WithFields ¶
WithFields returns a logger with additional fields
type MetricsServer ¶
type MetricsServer struct {
Counters map[string]prometheus.Counter
Gauges map[string]prometheus.Gauge
Histograms map[string]prometheus.Histogram
Summaries map[string]prometheus.Summary
// contains filtered or unexported fields
}
MetricsServer provides prometheus metrics functionality
func NewMetricsServer ¶
func NewMetricsServer(serviceName string, port int) *MetricsServer
NewMetricsServer creates a new metrics server
func (*MetricsServer) Middleware ¶
Middleware creates a middleware for recording HTTP request metrics
func (*MetricsServer) NewCounter ¶
func (ms *MetricsServer) NewCounter(name, help string, labels ...string) prometheus.Counter
NewCounter creates a new counter metric
func (*MetricsServer) NewGauge ¶
func (ms *MetricsServer) NewGauge(name, help string, labels ...string) prometheus.Gauge
NewGauge creates a new gauge metric
func (*MetricsServer) NewHistogram ¶
func (ms *MetricsServer) NewHistogram(name, help string, buckets []float64, labels ...string) prometheus.Histogram
NewHistogram creates a new histogram metric
func (*MetricsServer) NewSummary ¶
func (ms *MetricsServer) NewSummary(name, help string, objectives map[float64]float64, labels ...string) prometheus.Summary
NewSummary creates a new summary metric
func (*MetricsServer) Start ¶
func (ms *MetricsServer) Start() error
Start starts the metrics server
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer is a utility for timing code execution
func (*Timer) ObserveDuration ¶
func (t *Timer) ObserveDuration()
ObserveDuration records the duration
type TracingProvider ¶
type TracingProvider struct {
// contains filtered or unexported fields
}
TracingProvider manages the OpenTelemetry tracing configuration
func NewTracingProvider ¶
func NewTracingProvider(serviceName string) (*TracingProvider, error)
NewTracingProvider creates a new tracing provider