metrics

Generated by tinox doc

Manual instrumentation API on top of the runtime's built-in metrics registry: counters, histograms, gauges, a Prometheus text-format exporter (MetricsRegistry), and a simple elapsed-time stopwatch (MetricsStopwatch). Complements the @Timed/@Counted annotations for cases where you want to record a metric from application logic directly.

Counters and stopwatch

import tinox.core.metrics;

class Main
{
    fnc main() -> Int32
    {
        let m: MetricsRegistry = MetricsRegistry { };
        m.incCounter("requests_total");
        m.setGauge("queue_depth", 3);

        let sw: MetricsStopwatch = MetricsStopwatch::start();
        // ... do some work ...
        MetricsStopwatch::recordTo(sw, "work_duration_ns");

        println(m.prometheusFormat());
        return 0;
    }
}

class MetricsRegistry

Methods

fn incCounter(name: String) → Nothing
fn recordDuration(name: String, durationNs: Int64) → Nothing
fn setGauge(name: String, value: Int64) → Nothing
fn prometheusFormat() → String

class MetricsStopwatch

Fields

startNsInt64

Methods

fn start() → MetricsStopwatch
fn elapsedNs(sw: MetricsStopwatch) → Int64
fn recordTo(sw: MetricsStopwatch, metricName: String) → Nothing