meldotel

package
v0.1.0-alpha.14 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Meldbase OpenTelemetry metrics

meldotel bridges the latest immutable admin.Sampler snapshot to the stable OpenTelemetry Go Metrics API. It accepts an application-owned MeterProvider; it never constructs an SDK/exporter, uses the global provider, opens a network connection, starts a goroutine or calls DB.Stats() from an OTel callback.

sampler, err := admin.NewSampler(db, admin.SamplerOptions{
    Interval: time.Second,
    Server:   handler, // optional aggregate server/RPC/Worker metrics
})
if err != nil {
    log.Fatal(err)
}
defer sampler.Close()

adapter, err := meldotel.New(sampler, meldotel.Options{
    MeterProvider:          applicationMeterProvider,
    InstrumentationVersion: "0.1.0",
})
if err != nil {
    log.Fatal(err)
}
defer adapter.Close()

SchemaVersion and Instruments() expose the fixed contract. Instrument names start with meldbase. and have no attributes containing database paths, collection/index names, query text, document IDs, errors, actors or workspaces. Server instruments are simply not observed when the sampler has no server source. Values above the OTel API's signed int64 range saturate monotonically; Adapter.Stats() reports that condition.

Contract version 7 includes the aggregate meldbase.index.build.retention_lease.active and meldbase.index.build.retention.pressure gauges. They carry no dynamic attributes; the latter is set only when the build watermark is the binding Commit Log retention boundary, distinguishing normal online-build lag from a budget that needs operator attention.

Contract version 8 adds physical-generation and external rollback-anchor sequence/generation, lag, failure, timeout and synchronous-latency instruments. These remain fixed-cardinality engine aggregates and expose no database or anchor-service identity.

These are embedded-engine aggregates, so the adapter deliberately does not emit db.client.*. The OpenTelemetry database semantic conventions describe calls as observed by a database client, while this adapter observes the engine itself.

The package targets OpenTelemetry Go Metrics API v1.38, the newest stable release in the supported Go 1.23 toolchain line. Applications own SDK, reader, exporter, resource and collection interval choices.

Documentation

Overview

Package meldotel exports sampled Meldbase statistics through OpenTelemetry metrics.

It never calls DB.Stats directly and does not create an SDK, exporter, goroutine, network connection, or global state.

Index

Constants

View Source
const SchemaVersion uint32 = 12

SchemaVersion identifies the fixed set of exported metrics and their meanings.

It is independent of the admin JSON schema and OpenTelemetry API version.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter exports the latest admin sample through registered OpenTelemetry instruments.

func New

func New(source SampleSource, options Options) (*Adapter, error)

New registers the fixed metric set and a callback that reads the supplied sample source.

func (*Adapter) Close

func (adapter *Adapter) Close() error

Close unregisters the collection callback once and returns any unregister error.

func (*Adapter) Stats

func (adapter *Adapter) Stats() AdapterStats

Stats returns the adapter counters and closed state.

type AdapterStats

type AdapterStats struct {
	Collections           uint64
	UnavailableSamples    uint64
	SaturatedMeasurements uint64
	Closed                bool
}

AdapterStats reports collection attempts, unavailable samples, and clamped measurements.

type InstrumentDescriptor

type InstrumentDescriptor struct {
	Name        string
	Description string
	Unit        string
	Kind        InstrumentKind
	Number      string
}

InstrumentDescriptor describes a metric name, meaning, unit, and numeric kind.

func Instruments

func Instruments() []InstrumentDescriptor

Instruments returns a fresh copy of the exported metric definitions.

Definitions never contain application, collection, query, document, actor, or workspace data.

type InstrumentKind

type InstrumentKind string

InstrumentKind distinguishes gauges from cumulative counters.

const (
	// InstrumentGauge identifies a measurement of the current state.
	InstrumentGauge InstrumentKind = "gauge"
	// InstrumentCounter identifies a cumulative measurement.
	InstrumentCounter InstrumentKind = "counter"
)

type Options

type Options struct {
	MeterProvider          metric.MeterProvider
	InstrumentationVersion string
}

Options selects the meter provider and optional instrumentation version.

type SampleSource

type SampleSource interface {
	Latest() (admin.Sample, bool)
}

SampleSource supplies the latest stored admin sample for metric collection.

*admin.Sampler implements this interface. The adapter reads its latest immutable sample without entering a database lock from a collection callback.

Jump to

Keyboard shortcuts

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