telemetry

package
v1.10.4 Latest Latest
Warning

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

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

Documentation

Overview

Package telemetry holds the tracing and metrics helpers the engine and the message bus share. It lives in the root module, so it uses only OpenTelemetry and go-utils and never forge: a Forge app installs the global tracer provider and hands the engine its metrics, and a host without Forge gets no-op spans and no metrics until it does the same.

Index

Constants

View Source
const LogInterval = time.Minute

LogInterval is how often one log site may write a line. Failures in between are counted and reported on the next line, so a store that is down fails every step and every run, and the log gets one line a minute per site rather than one per step.

View Source
const ScopeName = "github.com/xraph/cortex"

ScopeName is the instrumentation scope every cortex span carries.

Variables

View Source
var ErrPanic = errors.New("cortex: panic")

ErrPanic stands in for a call that panicked. A deferred end records it, as the class "panic", while the panic carries on unwinding.

Functions

func Detach

func Detach(ctx context.Context) context.Context

Detach strips ctx's span and remembers it as a link target. The next run span started from the result is a new root that links back to the span ctx carried, instead of a child that outlives its parent.

func ErrorType

func ErrorType(err error) string

ErrorType names err for a span: a known sentinel by its name, anything else by the Go type of the innermost error in its wrap chain.

func Fail

func Fail(span trace.Span, err error)

Fail marks span as failed. The description is a short class, never the error's text: provider, driver and tool messages quote prompts, arguments and stored values. The exception event carries only the error's type.

func Links(scs ...trace.SpanContext) []trace.Link

Links turns span contexts into span links, skipping invalid ones and repeats.

func StripSpan

func StripSpan(ctx context.Context) context.Context

StripSpan keeps ctx's values and cancellation but drops its span, so work started from it begins a trace of its own. A loop started from a Forge start hook or a request needs this: context.WithoutCancel and WithCancel keep the span, and every query an idle tick made would land in a trace that ended long ago.

TakeLink returns the link target Detach recorded, and a ctx that no longer carries it, so a span nested under the new root is an ordinary child.

func Tracer

func Tracer() trace.Tracer

Tracer returns the cortex tracer from the global provider. It is looked up per call rather than cached, so a provider installed after the engine was built (Forge installs its own at start) is still the one that records.

Types

type CounterVec

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

CounterVec is a labelled counter. A nil *CounterVec records nothing, which is what a nil metrics sink gives you.

func NewCounterVec

func NewCounterVec(m gometrics.Metrics, name, help string, keys ...string) *CounterVec

NewCounterVec declares a counter on m, or returns nil when m is nil.

func (*CounterVec) Inc

func (c *CounterVec) Inc(values ...string)

Inc adds one to the series named by values, given in key order.

type GaugeVec

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

GaugeVec is a labelled gauge. A nil *GaugeVec records nothing.

func NewGaugeVec

func NewGaugeVec(m gometrics.Metrics, name, help string, keys ...string) *GaugeVec

NewGaugeVec declares a gauge on m, or returns nil when m is nil.

func (*GaugeVec) Set

func (g *GaugeVec) Set(v float64, values ...string)

Set sets the series named by values, given in key order.

type HistogramVec

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

HistogramVec is a labelled histogram. A nil *HistogramVec records nothing.

func NewHistogramVec

func NewHistogramVec(m gometrics.Metrics, name, help, unit string, buckets []float64, keys ...string) *HistogramVec

NewHistogramVec declares a histogram on m, or returns nil when m is nil.

func (*HistogramVec) Observe

func (h *HistogramVec) Observe(v float64, values ...string)

Observe records v in the series named by values, given in key order.

type Throttle

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

Throttle limits log lines per key. Keys must come from a bounded set (a call site's message, or a hook and the name of a registered extension), which is what bounds the map. The zero value is ready to use and safe for concurrent use.

func (*Throttle) Allow

func (t *Throttle) Allow(key string, now time.Time) (ok bool, suppressed int)

Allow reports whether key may log at now, and how many lines it skipped since the last one it wrote.

Directories

Path Synopsis
Package telemetrytest is a recording metrics sink for cortex's own tests.
Package telemetrytest is a recording metrics sink for cortex's own tests.

Jump to

Keyboard shortcuts

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