Documentation
¶
Index ¶
- Constants
- func HealthHandler(cfg HealthConfig, roomCount, peerCount, sessionCount func() int) http.HandlerFunc
- func MetricsHandler(cfg MetricsConfig, metrics *Metrics, ...) http.HandlerFunc
- func RecordError(span trace.Span, err error)
- type AsyncHandler
- type HealthConfig
- type LogLevel
- type LogOutput
- type Logger
- func (l *Logger) Debug(format string, args ...interface{})
- func (l *Logger) Error(format string, args ...interface{})
- func (l *Logger) GetLevel() LogLevel
- func (l *Logger) Info(format string, args ...interface{})
- func (l *Logger) SetLevel(level LogLevel)
- func (l *Logger) Warn(format string, args ...interface{})
- func (l *Logger) WithComponent(name string) *Logger
- func (l *Logger) WithFields(f map[string]interface{}) *Logger
- func (l *Logger) WithPrefix(p string) *Logger
- func (l *Logger) WithRequest(id string) *Logger
- type MemoryExporter
- type Metrics
- func (m *Metrics) AddBytesReceived(n int64)
- func (m *Metrics) AddBytesSent(n int64)
- func (m *Metrics) DecConnections()
- func (m *Metrics) IncConnections()
- func (m *Metrics) IncMessageErrors()
- func (m *Metrics) IncMessages()
- func (m *Metrics) PrometheusText() string
- func (m *Metrics) Snapshot() map[string]int64
- func (m *Metrics) UpdateCalls(count int64)
- func (m *Metrics) UpdatePeerConnections(count int64)
- func (m *Metrics) UpdateRooms(count int64)
- type MetricsConfig
- type SpanSnapshot
- type Tracing
- func (t *Tracing) HTTPMiddleware(next http.Handler) http.Handler
- func (t *Tracing) Handler() http.HandlerFunc
- func (t *Tracing) Shutdown(ctx context.Context) error
- func (t *Tracing) StartSpan(ctx context.Context, name string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
- func (t *Tracing) Tracer(name string) trace.Tracer
- type TracingConfig
Constants ¶
const ( LevelDebug = slog.LevelDebug LevelInfo = slog.LevelInfo LevelWarn = slog.LevelWarn LevelError = slog.LevelError )
Variables ¶
This section is empty.
Functions ¶
func HealthHandler ¶
func HealthHandler(cfg HealthConfig, roomCount, peerCount, sessionCount func() int) http.HandlerFunc
HealthHandler returns an HTTP handler for /health.
func MetricsHandler ¶
func MetricsHandler(cfg MetricsConfig, metrics *Metrics, roomCount, peerCount, callCount func() int64) http.HandlerFunc
MetricsHandler returns an HTTP handler for /metrics.
func RecordError ¶
Types ¶
type AsyncHandler ¶
type AsyncHandler struct {
// contains filtered or unexported fields
}
AsyncHandler wraps a slog.Handler to provide non-blocking logging.
func NewAsyncHandler ¶
func NewAsyncHandler(next slog.Handler, bufferSize int) *AsyncHandler
type HealthConfig ¶
HealthConfig holds configuration for the health endpoint.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a production-grade structured logger wrapping slog. It supports asynchronous, non-blocking logging and automatic format detection.
func NewLoggerWithOutput ¶
NewLoggerWithOutput creates a Logger with a specific output format.
func (*Logger) WithComponent ¶
WithComponent returns a new Logger scoped to a named component.
func (*Logger) WithFields ¶
WithFields returns a new Logger with the given fields attached.
func (*Logger) WithPrefix ¶
WithPrefix returns a new Logger with a component-style prefix.
func (*Logger) WithRequest ¶
WithRequest returns a new Logger with a request ID attached.
type MemoryExporter ¶
type MemoryExporter struct {
// contains filtered or unexported fields
}
MemoryExporter stores recent spans so they can be inspected over HTTP.
func (*MemoryExporter) ExportSpans ¶
func (e *MemoryExporter) ExportSpans(_ context.Context, spans []sdktrace.ReadOnlySpan) error
func (*MemoryExporter) Spans ¶
func (e *MemoryExporter) Spans() []SpanSnapshot
type Metrics ¶
type Metrics struct {
ConnectionsTotal int64
ConnectionsActive int64
MessagesTotal int64
MessagesErrors int64
RoomsActive int64
CallsActive int64
PeerConnectionsActive int64
BytesSent int64
BytesReceived int64
// contains filtered or unexported fields
}
func NewMetrics ¶
func NewMetrics() *Metrics
func (*Metrics) AddBytesReceived ¶
func (*Metrics) AddBytesSent ¶
func (*Metrics) DecConnections ¶
func (m *Metrics) DecConnections()
func (*Metrics) IncConnections ¶
func (m *Metrics) IncConnections()
func (*Metrics) IncMessageErrors ¶
func (m *Metrics) IncMessageErrors()
func (*Metrics) IncMessages ¶
func (m *Metrics) IncMessages()
func (*Metrics) PrometheusText ¶
func (*Metrics) UpdateCalls ¶
func (*Metrics) UpdatePeerConnections ¶
func (*Metrics) UpdateRooms ¶
type MetricsConfig ¶
MetricsConfig holds configuration for the metrics endpoint.
type SpanSnapshot ¶
type SpanSnapshot struct {
Name string `json:"name"`
TraceID string `json:"trace_id"`
SpanID string `json:"span_id"`
ParentSpanID string `json:"parent_span_id,omitempty"`
Kind string `json:"kind"`
Status string `json:"status"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
Attributes map[string]string `json:"attributes,omitempty"`
}
SpanSnapshot is a lightweight JSON-safe record of an exported span.
type Tracing ¶
type Tracing struct {
// contains filtered or unexported fields
}
Tracing manages the OpenTelemetry provider and in-memory exporter.
func NewTracing ¶
func NewTracing(cfg TracingConfig) (*Tracing, error)
func (*Tracing) Handler ¶
func (t *Tracing) Handler() http.HandlerFunc