o11yusage

package
v0.119.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

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

Aggregator batches per-tenant, per-kind byte counts and flushes them on an interval, the same pattern as analytics.Aggregator. Add is the non-blocking hot path. A nil FlushFunc disables the ticker.

func NewAggregator

func NewAggregator(l *zerolog.Logger, interval time.Duration, fn FlushFunc) *Aggregator

NewAggregator returns an aggregator. If fn is nil, Start is a no-op.

func (*Aggregator) Add

func (a *Aggregator) Add(tenantID uuid.UUID, kind Kind, n int64)

Add increments the tenant's counter for kind. Safe on a nil receiver.

func (*Aggregator) AddLogs

func (a *Aggregator) AddLogs(tenantID uuid.UUID, n int64)

AddLogs increments the tenant's log-ingest counter. Safe on a nil receiver.

func (*Aggregator) AddOtel

func (a *Aggregator) AddOtel(tenantID uuid.UUID, n int64)

AddOtel increments the tenant's OTLP-ingest counter. Safe on a nil receiver.

func (*Aggregator) AddStreamDelivered added in v0.118.0

func (a *Aggregator) AddStreamDelivered(tenantID uuid.UUID, n int64)

AddStreamDelivered increments the tenant's stream payload bytes sent to subscribers. Safe on a nil receiver.

func (*Aggregator) AddStreamPublished added in v0.118.0

func (a *Aggregator) AddStreamPublished(tenantID uuid.UUID, n int64)

AddStreamPublished increments the tenant's stored stream payload bytes. Safe on a nil receiver.

func (*Aggregator) Shutdown

func (a *Aggregator) Shutdown() error

Shutdown stops the ticker and flushes remaining counters once.

func (*Aggregator) Start

func (a *Aggregator) Start()

Start runs the flush ticker. Safe on a nil receiver or when no flush func is set.

type FlushFunc

type FlushFunc func(tenants map[uuid.UUID]TenantBytes) error

FlushFunc receives a snapshot of tenant → bytes since the last flush. A non-nil error is logged and the snapshot is dropped (best-effort undercount).

type Kind

type Kind string

Kind is a separately buffered billable byte count. All kinds flush together but stay distinct through to Autumn event names.

const (
	KindLogs Kind = "logs"
	KindOtel Kind = "otel"
	// payload bytes of stored durable stream messages
	KindStreamPublished Kind = "streamPublished"
	// payload bytes sent to durable stream subscribers, once per subscriber
	KindStreamDelivered Kind = "streamDelivered"
)

type TenantBytes

type TenantBytes struct {
	Logs            int64 `json:"logs,omitempty"`
	Otel            int64 `json:"otel,omitempty"`
	StreamPublished int64 `json:"streamPublished,omitempty"`
	StreamDelivered int64 `json:"streamDelivered,omitempty"`
}

TenantBytes is one tenant's buffered bytes since the last flush.

Jump to

Keyboard shortcuts

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