guiqi695/moon-prometheus-sdk/registry does not have a README file

    CollectorError

    pub(all) suberror CollectorError {
    Failed(String)
    } derive(Eq,
    Debug
    )

    A structured failure returned by a framework-neutral custom collector.

    CollectorAdapter deliberately uses an explicit Result rather than a trait object. MoonBit packages can therefore register heterogeneous collectors on every supported target without relying on runtime trait object dispatch.

    GatherError

    pub(all) suberror GatherError {
    CollectorFailed(token~ : Int, message~ : String)
    UndeclaredFamily(String)
    FamilyMetadataMismatch(name~ : String, field~ : String)
    InvalidFamilySamples(String)
    InvalidLabels(String)
    DuplicateSample(String)
    InvalidHistogram(String)
    } derive(Eq,
    Debug
    )

    Errors raised when a registry cannot produce one internally consistent snapshot. Gather is fail-closed: it never returns a partial exposition.

    RegistryError

    pub(all) suberror RegistryError {
    DuplicateMetric(String)
    MetricNotFound(String)
    InvalidCollector(String)
    DescriptorConflict(name~ : String, field~ : String)
    } derive(Eq,
    Debug
    )

    CollectorAdapter

    pub struct CollectorAdapter {
    descriptors : Array[
    Descriptor
    ]
    collect : () -> Result[Array[FamilySnapshot], CollectorError]
    }

    A custom collector represented by immutable descriptors and a collection callback. The callback may produce zero or more samples for each descriptor, but may not introduce an undeclared family.

    CollectorAdapter::new

    Construct a framework-neutral custom collector adapter.

    Descriptor uniqueness and all cross-registry conflict checks happen in Registry::register_collector, where they can be checked atomically.

    CollectorEntry

    type CollectorEntry

    FamilySnapshot

    pub(all) struct FamilySnapshot {
    name : String
    help : String
    unit : String?
    family_type : FamilyType
    scalar_samples : Array[ScalarSampleSnapshot]
    histogram_samples : Array[HistogramSampleSnapshot]
    } derive(Eq,
    Debug
    )

    A complete, detached metric family. Exactly one of the sample arrays is non-empty for a non-empty family: scalar for counter/gauge, histogram for histogram. Empty families are valid for custom collectors.

    FamilySnapshot::histogram

    fn FamilySnapshot::histogram(name : String, help : String, samples : Array[HistogramSampleSnapshot], unit : String?) -> FamilySnapshot

    FamilySnapshot::scalar

    fn FamilySnapshot::scalar(name : String, help : String, family_type : FamilyType, samples : Array[ScalarSampleSnapshot], unit : String?) -> FamilySnapshot

    FamilyType

    pub(all) enum FamilyType {
    CounterFamily
    GaugeFamily
    HistogramFamily
    } derive(Eq,
    Debug
    )

    Metric family kinds used by immutable gather/export contracts.

    GatherSnapshot

    pub(all) struct GatherSnapshot {
    families : Array[FamilySnapshot]
    } derive(Eq,
    Debug
    )

    Exporters consume this detached value rather than mutable metric objects.

    GatherSnapshot::families

    HistogramSampleSnapshot

    One detached histogram sample.

    Registration

    pub struct Registration {
    token : Int
    } derive(Eq,
    Debug
    )

    An opaque identity returned by a successful registry registration.

    A registration is scoped to one Registry. It is intentionally not a metric name: an old handle must never unregister a newer metric family that reused the same name.

    Registration::token

    fn Registration::token(self : Registration) -> Int

    Return the registry-local token for diagnostics and test assertions.

    The token alone is not accepted by unregister; callers must retain the Registration value returned by this registry.

    Registry

    pub struct Registry {
    entries : Array[CollectorEntry]
    next_token : Int
    lock :
    Mutex

    }

    Registry owns collector registrations and creates deterministic detached snapshots. Native builds protect its entry table with storage's pthread mutex; portable targets keep the same copy-and-release protocol as no-op.

    Registry::counters

    Return a copy of currently registered Counter references. This is a compatibility view; exporters should consume gather() instead.

    Registry::gather

    fn Registry::gather(self : Registry) -> GatherSnapshot raise GatherError

    Collect every registered family into a deeply detached, deterministic snapshot. Collection is fail-closed: no partial result is returned when a custom collector fails or violates its descriptor contract.

    Registry::gauges

    Return a copy of currently registered Gauge references. This is a compatibility view; exporters should consume gather() instead.

    Registry::histograms

    Return a copy of currently registered Histogram references. This is a compatibility view; exporters should consume gather() instead.

    Registry::new

    fn Registry::new() -> Registry

    Registry::register_collector

    fn Registry::register_collector(self : Registry, collector : CollectorAdapter) -> Registration raise RegistryError

    Register a framework-neutral custom collector adapter.

    Registry::register_counter

    fn Registry::register_counter(self : Registry, metric :
    Counter
    ) -> Unit raise RegistryError

    Backwards-compatible Counter registration. Prefer register_counter_with_handle when lifecycle management is needed.

    Registry::register_counter_vec

    fn Registry::register_counter_vec(self : Registry, vector :
    CounterVec
    ) -> Unit raise RegistryError

    Backwards-compatible CounterVec registration. Prefer the handle-returning form when the vector must later be unregistered.

    Registry::register_counter_vec_with_handle

    fn Registry::register_counter_vec_with_handle(self : Registry, vector :
    CounterVec
    ) -> Registration raise RegistryError

    Register a CounterVec as one dynamic metric family.

    Children are read at gather time, so adding or deleting a label set changes the next snapshot without requiring another registry registration.

    Registry::register_counter_with_handle

    fn Registry::register_counter_with_handle(self : Registry, metric :
    Counter
    ) -> Registration raise RegistryError

    Register a Counter and return a handle for identity-safe unregistration.

    Registry::register_gauge

    fn Registry::register_gauge(self : Registry, metric :
    Gauge
    ) -> Unit raise RegistryError

    Backwards-compatible Gauge registration. Prefer register_gauge_with_handle when lifecycle management is needed.

    Registry::register_gauge_vec

    fn Registry::register_gauge_vec(self : Registry, vector :
    GaugeVec
    ) -> Unit raise RegistryError

    Backwards-compatible GaugeVec registration. Prefer the handle-returning form when the vector must later be unregistered.

    Registry::register_gauge_vec_with_handle

    fn Registry::register_gauge_vec_with_handle(self : Registry, vector :
    GaugeVec
    ) -> Registration raise RegistryError

    Register a GaugeVec as one dynamic metric family.

    Registry::register_gauge_with_handle

    fn Registry::register_gauge_with_handle(self : Registry, metric :
    Gauge
    ) -> Registration raise RegistryError

    Register a Gauge and return a handle for identity-safe unregistration.

    Registry::register_histogram

    fn Registry::register_histogram(self : Registry, metric :
    Histogram
    ) -> Unit raise RegistryError

    Backwards-compatible Histogram registration. Prefer register_histogram_with_handle when lifecycle management is needed.

    Registry::register_histogram_vec

    fn Registry::register_histogram_vec(self : Registry, vector :
    HistogramVec
    ) -> Unit raise RegistryError

    Backwards-compatible HistogramVec registration. Prefer the handle-returning form when the vector must later be unregistered.

    Registry::register_histogram_vec_with_handle

    fn Registry::register_histogram_vec_with_handle(self : Registry, vector :
    HistogramVec
    ) -> Registration raise RegistryError

    Register a HistogramVec as one dynamic metric family.

    Registry::register_histogram_with_handle

    fn Registry::register_histogram_with_handle(self : Registry, metric :
    Histogram
    ) -> Registration raise RegistryError

    Register a Histogram and return a handle for identity-safe unregistration.

    Registry::registered_count

    fn Registry::registered_count(self : Registry) -> Int

    Registry::unregister

    fn Registry::unregister(self : Registry, registration : Registration) -> Bool

    Remove exactly the registration represented by registration.

    Returning false for a stale or already removed handle is intentional; the method never removes a newer family with the same descriptor name.

    ScalarSampleSnapshot

    pub(all) struct ScalarSampleSnapshot {
    labels : Array[
    Label
    ]
    value : Double
    } derive(Eq,
    Debug
    )

    One detached scalar sample. Label order is canonicalized by Registry::gather before an exporter receives the snapshot.

    default_registry

    fn default_registry() -> Registry

    Return the process-wide convenience registry.

    Values registered here remain present until they are explicitly unregistered. Callers that need cleanup should use a register_*_with_handle method and retain the returned Registration.

    scalar_sample

    fn scalar_sample(labels : Array[
    Label
    ], value : Double) -> ScalarSampleSnapshot