telemetry

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package telemetry provides OpenTelemetry instrumentation for Tikr, including metric definitions for ingestion throughput, aggregation flushes, query latency, and storage usage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter = metric.Int64Counter

Counter is a convenience alias for the OTel Int64Counter instrument.

type Metrics

type Metrics struct {

	// Ingest metrics
	TicksTotal Counter                 // tikr.ingest.ticks_total
	BatchSize  metric.Float64Histogram // tikr.ingest.batch_size

	// Aggregation metrics
	BarsFlushedTotal Counter // tikr.agg.bars_flushed_total

	// Output metrics
	KafkaWritesTotal Counter // tikr.output.kafka_writes_total
	KafkaDropsTotal  Counter // tikr.output.kafka_drops_total

	// Query metrics
	QueryRequestsTotal Counter                 // tikr.query.requests_total (use "type" attr)
	QueryLatencyMs     metric.Float64Histogram // tikr.query.latency_ms
	// contains filtered or unexported fields
}

Metrics holds all OTel instruments for the Tikr service. The underlying MeterProvider can be configured with any OTel exporter (Prometheus, OTLP/gRPC, OTLP/HTTP, stdout, Kafka, etc.).

func NewMetrics

func NewMetrics(serviceName string, opts ...Option) (*Metrics, error)

NewMetrics creates a Metrics instance with the given OTel readers/exporters. If no readers are provided, metrics are collected but not exported (useful for tests).

func (*Metrics) Shutdown

func (m *Metrics) Shutdown(ctx context.Context) error

Shutdown flushes pending metrics and releases resources. It is safe to call when m.provider is nil, but NOT idempotent: the underlying OTel MeterProvider.Shutdown returns an error on the second call. Callers should ensure Shutdown is called exactly once.

type Option

type Option func(*options)

Option configures the Metrics setup.

func WithReader

func WithReader(r sdkmetric.Reader) Option

WithReader adds an OTel metric reader (e.g., Prometheus exporter, OTLP exporter, periodic reader).

Jump to

Keyboard shortcuts

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