obsv

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SpanNameRun             = "yfin.run"
	SpanNameIngestFetch     = "ingest.fetch"
	SpanNameIngestDecode    = "ingest.decode"
	SpanNameIngestNormalize = "ingest.normalize"
	SpanNameEmitProto       = "emit.proto"
	SpanNamePublishBus      = "publish.bus"
	SpanNameFXRates         = "fx.rates"
)

Span names for different operations

Variables

This section is empty.

Functions

func CommonLogAttrs

func CommonLogAttrs(runID, symbol, mic, endpoint string) []any

Common log attributes for yfinance-go

func Init

func Init(ctx context.Context, config *Config) error

Init initializes the observability system using ampy-observability

func LogWithTrace

func LogWithTrace(ctx context.Context, attrs ...any) []any

LogWithTrace adds trace context to log attributes

func Logger

func Logger() *slog.Logger

Logger returns the ampy-observability logger

func RecordBackoff

func RecordBackoff(endpoint, reason string)

func RecordBackoffSleep

func RecordBackoffSleep(endpoint string, duration time.Duration)

func RecordBatchBytes

func RecordBatchBytes(batchType string, bytes int64)

func RecordCBOpen

func RecordCBOpen(scope string)

func RecordDecodeFail

func RecordDecodeFail(reason string)

func RecordPublish

func RecordPublish(publishType, outcome string)

func RecordPublishLatency

func RecordPublishLatency(publishType string, duration time.Duration)

func RecordRequest

func RecordRequest(endpoint, outcome, code string)

func RecordRequestLatency

func RecordRequestLatency(endpoint string, duration time.Duration)

func RecordRetry

func RecordRetry(endpoint, reason string)

func RecordSessionEject

func RecordSessionEject()

func RecordSpanError

func RecordSpanError(span trace.Span, err error)

RecordSpanError records an error in a span

func Reset

func Reset()

Reset resets the global observability state (for testing)

func SetCBState

func SetCBState(scope string, state int)

func SetInflightRequests

func SetInflightRequests(endpoint string, count int)

func Shutdown

func Shutdown(ctx context.Context) error

Shutdown shuts down the observability system

func StartEmitProtoSpan

func StartEmitProtoSpan(ctx context.Context, messageType, symbol string) (context.Context, trace.Span)

StartEmitProtoSpan creates a span for protobuf emission

func StartFXRatesSpan

func StartFXRatesSpan(ctx context.Context, fromCurrency, toCurrency string) (context.Context, trace.Span)

StartFXRatesSpan creates a span for FX rate operations

func StartIngestDecodeSpan

func StartIngestDecodeSpan(ctx context.Context, endpoint, symbol string) (context.Context, trace.Span)

StartIngestDecodeSpan creates a span for decode operations

func StartIngestFetchSpan

func StartIngestFetchSpan(ctx context.Context, endpoint, symbol, mic, url string, attempt int) (context.Context, trace.Span)

StartIngestFetchSpan creates a span for HTTP fetch operations

func StartIngestNormalizeSpan

func StartIngestNormalizeSpan(ctx context.Context, endpoint, symbol, mic string) (context.Context, trace.Span)

StartIngestNormalizeSpan creates a span for normalization operations

func StartPublishBusSpan

func StartPublishBusSpan(ctx context.Context, topic, partitionKey string, chunkIndex int, bytes int64) (context.Context, trace.Span)

StartPublishBusSpan creates a span for bus publishing

func StartRunSpan

func StartRunSpan(ctx context.Context, runID, env string, args []string) (context.Context, trace.Span)

StartRunSpan creates the root span for a yfin run

func StartSpan

func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

StartSpan creates a new span using ampy-observability

func Tracer

func Tracer() trace.Tracer

Tracer returns the ampy-observability tracer

func UpdateIngestFetchSpan

func UpdateIngestFetchSpan(span trace.Span, status int, bytes int64, elapsed time.Duration)

UpdateIngestFetchSpan updates the fetch span with response details

Types

type Config

type Config struct {
	ServiceName       string
	ServiceVersion    string
	Environment       string
	CollectorEndpoint string
	TraceProtocol     string
	SampleRatio       float64
	LogLevel          string
	MetricsAddr       string
	MetricsEnabled    bool
	TracingEnabled    bool
}

Config represents observability configuration

type Observability

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

Observability represents the main observability interface

type PrometheusConfig

type PrometheusConfig struct {
	Enabled bool
	Addr    string
}

PrometheusConfig for Prometheus exporter

Jump to

Keyboard shortcuts

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