observability

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONLogger

type JSONLogger struct {
	// contains filtered or unexported fields
}

JSONLogger implements structured logging in JSON format

func NewJSONLogger

func NewJSONLogger() *JSONLogger

NewJSONLogger creates a new JSON logger

func (*JSONLogger) Debug

func (l *JSONLogger) Debug(ctx context.Context, message string, fields map[string]interface{})

Debug logs a debug message

func (*JSONLogger) Error

func (l *JSONLogger) Error(ctx context.Context, message string, err error, fields map[string]interface{})

Error logs an error message

func (*JSONLogger) Info

func (l *JSONLogger) Info(ctx context.Context, message string, fields map[string]interface{})

Info logs an info message

func (*JSONLogger) Warn

func (l *JSONLogger) Warn(ctx context.Context, message string, fields map[string]interface{})

Warn logs a warning message

type Logger

type Logger interface {
	// Info logs an info message
	Info(ctx context.Context, message string, fields map[string]interface{})
	// Error logs an error message
	Error(ctx context.Context, message string, err error, fields map[string]interface{})
	// Debug logs a debug message
	Debug(ctx context.Context, message string, fields map[string]interface{})
	// Warn logs a warning message
	Warn(ctx context.Context, message string, fields map[string]interface{})
}

Logger defines the interface for structured logging

type Metrics

type Metrics interface {
	// RecordQueryLatency records the latency of a query
	RecordQueryLatency(ctx context.Context, duration time.Duration)
	// RecordIndexLatency records the latency of an index operation
	RecordIndexLatency(ctx context.Context, duration time.Duration)
	// RecordQueryCount records the number of queries
	RecordQueryCount(ctx context.Context, status string)
	// RecordIndexCount records the number of index operations
	RecordIndexCount(ctx context.Context, status string)
	// RecordErrorCount records the number of errors
	RecordErrorCount(ctx context.Context, errorType string)
	// Register registers the metrics with Prometheus
	Register() error
}

Metrics defines the interface for metrics collection

type NoopSpan

type NoopSpan struct{}

NoopSpan implements a no-op span

func (*NoopSpan) End

func (s *NoopSpan) End()

End ends the span

func (*NoopSpan) SetAttribute

func (s *NoopSpan) SetAttribute(key string, value interface{})

SetAttribute sets an attribute on the span

func (*NoopSpan) SetError

func (s *NoopSpan) SetError(err error)

SetError sets an error on the span

type NoopTracer

type NoopTracer struct{}

NoopTracer implements a no-op tracer

func NewNoopTracer

func NewNoopTracer() *NoopTracer

NewNoopTracer creates a new no-op tracer

func (*NoopTracer) Extract

func (t *NoopTracer) Extract(ctx context.Context) (Span, bool)

Extract extracts a span from a context

func (*NoopTracer) StartSpan

func (t *NoopTracer) StartSpan(ctx context.Context, name string) (context.Context, Span)

StartSpan starts a new span

type PrometheusMetrics

type PrometheusMetrics struct {
	// contains filtered or unexported fields
}

PrometheusMetrics implements metrics collection using Prometheus

func NewPrometheusMetrics

func NewPrometheusMetrics() *PrometheusMetrics

NewPrometheusMetrics creates a new Prometheus metrics collector

func (*PrometheusMetrics) RecordErrorCount

func (m *PrometheusMetrics) RecordErrorCount(ctx context.Context, errorType string)

RecordErrorCount records the number of errors

func (*PrometheusMetrics) RecordIndexCount

func (m *PrometheusMetrics) RecordIndexCount(ctx context.Context, status string)

RecordIndexCount records the number of index operations

func (*PrometheusMetrics) RecordIndexLatency

func (m *PrometheusMetrics) RecordIndexLatency(ctx context.Context, duration time.Duration)

RecordIndexLatency records the latency of an index operation

func (*PrometheusMetrics) RecordQueryCount

func (m *PrometheusMetrics) RecordQueryCount(ctx context.Context, status string)

RecordQueryCount records the number of queries

func (*PrometheusMetrics) RecordQueryLatency

func (m *PrometheusMetrics) RecordQueryLatency(ctx context.Context, duration time.Duration)

RecordQueryLatency records the latency of a query

func (*PrometheusMetrics) Register

func (m *PrometheusMetrics) Register() error

Register registers the metrics with Prometheus

type Span

type Span interface {
	// End ends the span
	End()
	// SetAttribute sets an attribute on the span
	SetAttribute(key string, value interface{})
	// SetError sets an error on the span
	SetError(err error)
}

Span defines the interface for a tracing span

type SpanContext

type SpanContext struct {
	TraceID string
	SpanID  string
}

SpanContext represents the context of a span

type Tracer

type Tracer interface {
	// StartSpan starts a new span
	StartSpan(ctx context.Context, name string) (context.Context, Span)
	// Extract extracts a span from a context
	Extract(ctx context.Context) (Span, bool)
}

Tracer defines the interface for distributed tracing

Jump to

Keyboard shortcuts

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