Help us shape the future of Go! Take the 2026 Go Developer Survey

telemetry

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGlobalLogger

func SetGlobalLogger(l *Logger)

Types

type Counter

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

func NewCounter

func NewCounter(name string) *Counter

func (*Counter) Add

func (c *Counter) Add(n int64)

func (*Counter) Inc

func (c *Counter) Inc()

func (*Counter) Value

func (c *Counter) Value() int64

type Histogram

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

func NewHistogram

func NewHistogram(buckets []int64) *Histogram

func (*Histogram) Record

func (h *Histogram) Record(value int64)

type LogExporter

type LogExporter struct{}

func (*LogExporter) Export

func (e *LogExporter) Export(_ *Span) error

func (*LogExporter) Shutdown

func (e *LogExporter) Shutdown() error

type LogLevel

type LogLevel int
const (
	LevelDebug LogLevel = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
)

func ParseLevel

func ParseLevel(s string) (LogLevel, error)

func (LogLevel) String

func (l LogLevel) String() string

type Logger

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

func InitLogging

func InitLogging(level, format string) *Logger

func NewLogger

func NewLogger(opts ...LoggerOption) *Logger

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...any)

func (*Logger) Error

func (l *Logger) Error(msg string, args ...any)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, args ...any)

func (*Logger) Info

func (l *Logger) Info(msg string, args ...any)

func (*Logger) Warn

func (l *Logger) Warn(msg string, args ...any)

func (*Logger) WithAttrs

func (l *Logger) WithAttrs(attrs map[string]string) *Logger

type LoggerOption

type LoggerOption func(*Logger)

func WithAttr

func WithAttr(key, value string) LoggerOption

func WithFormat

func WithFormat(format string) LoggerOption

func WithLevel

func WithLevel(level LogLevel) LoggerOption

func WithOutput

func WithOutput(w io.Writer) LoggerOption

type Metrics

type Metrics struct {
	RequestsTotal   int64
	RequestsActive  int64
	RequestsFailed  int64
	RequestDuration *Histogram
	CacheHits       int64
	CacheMisses     int64
	BackendErrors   *expvar.Map
	ToolCalls       *expvar.Map
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics() *Metrics

func (*Metrics) DecActive

func (m *Metrics) DecActive()

func (*Metrics) IncActive

func (m *Metrics) IncActive()

func (*Metrics) IncCacheHit

func (m *Metrics) IncCacheHit()

func (*Metrics) IncCacheMiss

func (m *Metrics) IncCacheMiss()

func (*Metrics) IncFailed

func (m *Metrics) IncFailed()

func (*Metrics) IncRequests

func (m *Metrics) IncRequests()

func (*Metrics) RecordBackendError

func (m *Metrics) RecordBackendError(backend string)

func (*Metrics) RecordDuration

func (m *Metrics) RecordDuration(d time.Duration)

func (*Metrics) RecordToolCall

func (m *Metrics) RecordToolCall(tool string)

func (*Metrics) Snapshot

func (m *Metrics) Snapshot() MetricsSnapshot

type MetricsSnapshot

type MetricsSnapshot struct {
	RequestsTotal  int64         `json:"requestsTotal"`
	RequestsActive int64         `json:"requestsActive"`
	RequestsFailed int64         `json:"requestsFailed"`
	CacheHits      int64         `json:"cacheHits"`
	CacheMisses    int64         `json:"cacheMisses"`
	Uptime         time.Duration `json:"uptime"`
}

type NoopExporter

type NoopExporter struct{}

func (*NoopExporter) Export

func (e *NoopExporter) Export(_ *Span) error

func (*NoopExporter) Shutdown

func (e *NoopExporter) Shutdown() error

type Span

type Span struct {
	Name       string
	Context    SpanContext
	Kind       SpanKind
	StartTime  time.Time
	EndTime    time.Time
	Attributes map[string]string
	Events     []SpanEvent
	Status     SpanStatus
}

func GetSpan

func GetSpan(ctx context.Context) *Span

type SpanContext

type SpanContext struct {
	TraceID string
	SpanID  string
}

type SpanEvent

type SpanEvent struct {
	Name       string
	Timestamp  time.Time
	Attributes map[string]string
}

type SpanKind

type SpanKind int
const (
	SpanKindInternal SpanKind = 0
	SpanKindClient   SpanKind = 1
	SpanKindServer   SpanKind = 2
)

type SpanStatus

type SpanStatus struct {
	Code    int
	Message string
}

type TraceExporter

type TraceExporter interface {
	Export(span *Span) error
	Shutdown() error
}

type Tracer

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

func NewTracer

func NewTracer() *Tracer

func (*Tracer) AddSpanEvent

func (t *Tracer) AddSpanEvent(span *Span, name string, attrs map[string]string)

func (*Tracer) EndSpan

func (t *Tracer) EndSpan(span *Span)

func (*Tracer) Flush

func (t *Tracer) Flush()

func (*Tracer) SetSpanAttribute

func (t *Tracer) SetSpanAttribute(span *Span, key, value string)

func (*Tracer) SetSpanStatus

func (t *Tracer) SetSpanStatus(span *Span, code int, message string)

func (*Tracer) StartSpan

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

Jump to

Keyboard shortcuts

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