telemetry

package
v1.9.0 Latest Latest
Warning

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

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

Documentation

Overview

Package telemetry is the tracing and metrics plumbing the engine and the plugin registry share. Spans go to the global OpenTelemetry tracer provider, which forge.New installs. Metrics go to a go-utils metrics.Metrics the caller hands over, and a nil one records nothing.

Index

Constants

View Source
const InstrumentationName = "github.com/xraph/ledger"

InstrumentationName is the tracer name on every span ledger starts.

Variables

This section is empty.

Functions

func Detach

func Detach(ctx context.Context) context.Context

Detach returns ctx with no span in it, keeping its values, deadline and cancellation. A worker started from a traced context uses it so that the queries it runs while idle hang off no trace.

func Fail

func Fail(span trace.Span, typ string)

Fail marks span as failed. The status description and the exception event carry only typ, the error's class, never its message: driver and provider messages quote the values they failed on.

func Start

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

Start starts an internal span.

func StartChild

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

StartChild starts an internal span only when ctx already carries one, so a hot call made outside any trace does not begin a trace of its own. Without a parent it returns ctx and a span that records nothing.

func StartRoot

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

StartRoot starts an internal span that begins its own trace, for background work whose context may still carry the span of whatever started the worker.

func Tracer

func Tracer() trace.Tracer

Tracer returns ledger's tracer from the global provider. It is looked up on every call rather than kept in a package variable, so a provider installed after this package loaded (forge.New, or a test) is the one that records.

func TypeOf

func TypeOf(err error) string

TypeOf names an error by the Go type of the innermost error in its chain. Where a chain branches (errors.Join, or fmt.Errorf with two %w verbs) it follows the first branch.

Types

type CounterVec

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

CounterVec is a labeled counter. A nil *CounterVec records nothing.

func NewCounterVec

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

NewCounterVec declares a counter on m. It returns nil when m is nil.

func (*CounterVec) Add

func (c *CounterVec) Add(n float64, values ...string)

Add adds n to the child named by values.

func (*CounterVec) Inc

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

Inc adds one to the child named by values.

type HistogramVec

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

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

func NewHistogramVec

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

NewHistogramVec declares a histogram in seconds on m. It returns nil when m is nil.

func (*HistogramVec) ObserveSince

func (h *HistogramVec) ObserveSince(start time.Time, values ...string)

ObserveSince records the seconds since start on the child named by values.

Jump to

Keyboard shortcuts

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