observability

package
v0.0.0-...-6abae91 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceName = "fdb"

Variables

View Source
var ServiceStateCounter metric.Int64Counter

ServiceStateCounter is a counter for service state changes.

Functions

func InitMetrics

func InitMetrics(ctx context.Context, nodeId string, cfg config.MetricsConfig, logger logger.Logger) (metric.Meter, error)

InitMetrics initializes OpenTelemetry metrics.

func InitTracer

func InitTracer(ctx context.Context, nodeId string, cfg config.TracingConfig, logger logger.Logger) (trace.Tracer, *sdktrace.TracerProvider, error)

InitTracer initializes OpenTelemetry tracing.

func InitializeMetricsInObservability

func InitializeMetricsInObservability(ctx context.Context, meter metric.Meter, logger logger.Logger) error

InitializeMetricsInObservability initializes any additional metrics instruments.

Types

type NoopObserver

type NoopObserver struct{}

NoopObserver is a no-operation implementation of the Observer interface

func (*NoopObserver) StartSpan

func (n *NoopObserver) StartSpan(ctx context.Context, _ string) (context.Context, trace.Span)

StartSpan implements the Observer interface but does nothing

type Observability

type Observability struct {
	Logger         logger.Logger
	Meter          metric.Meter
	Tracer         trace.Tracer
	TracerProvider *sdktrace.TracerProvider
	ServiceName    string
}

Observability encapsulates metrics, tracing, and logging.

func G

func G() *Observability

func Initialize

func Initialize(ctx context.Context, cfg config.Config, logger logger.Logger) (*Observability, error)

func New

func New(ctx context.Context, cfg config.Config, logger logger.Logger) (*Observability, error)

New initializes all observability components based on the provided configuration.

func (*Observability) EmitServiceStateChangeTrace

func (o *Observability) EmitServiceStateChangeTrace(ctx context.Context, serviceType, previousState, newState string)

EmitServiceStateChangeTrace emits a trace when a service state changes.

func (*Observability) RecordServiceStateChange

func (o *Observability) RecordServiceStateChange(ctx context.Context, serviceType, state string)

RecordServiceStateChange records a service state change event.

func (*Observability) Shutdown

func (o *Observability) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the observability providers.

func (*Observability) StartSpan

func (o *Observability) StartSpan(ctx context.Context, name string) (context.Context, trace.Span)

StartSpan starts a new span and returns the new context and span

type Observer

type Observer interface {
	// StartSpan starts a new span and returns the new context and span
	StartSpan(ctx context.Context, name string) (context.Context, trace.Span)
}

Observer defines the interface for observability capabilities

func NewNoopObserver

func NewNoopObserver() Observer

NewNoopObserver creates a new no-operation observer

Jump to

Keyboard shortcuts

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