meldotel

package
v0.1.0-alpha.13 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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 Meldbase's bounded admin snapshots through the stable OpenTelemetry Metrics API. 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 aggregate instrument contract. 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
}

func New

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

func (*Adapter) Close

func (adapter *Adapter) Close() error

func (*Adapter) Stats

func (adapter *Adapter) Stats() AdapterStats

type AdapterStats

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

type InstrumentDescriptor

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

func Instruments

func Instruments() []InstrumentDescriptor

Instruments returns a fresh, caller-owned copy of the fixed schema. It never contains application, collection, query, document, actor, or workspace data.

type InstrumentKind

type InstrumentKind string
const (
	InstrumentGauge   InstrumentKind = "gauge"
	InstrumentCounter InstrumentKind = "counter"
)

type Options

type Options struct {
	MeterProvider          metric.MeterProvider
	InstrumentationVersion string
}

type SampleSource

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

SampleSource is implemented by *admin.Sampler. The adapter deliberately consumes its latest immutable sample instead of entering a database lock from an OpenTelemetry collection callback.

Jump to

Keyboard shortcuts

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