Skip to content

ntpstats.otlp

OpenTelemetry export of monitor/watch metrics (OTLP/HTTP, JSON encoding, standard library only).

ntpstats monitor time.example --otlp http://collector:4318 pushes the same metrics as the Prometheus endpoint (:mod:ntpstats.metrics) to an OpenTelemetry Collector (or any OTLP/HTTP receiver) every --otlp-interval seconds. Names use the OpenTelemetry style (ntpstats.offset with unit s). The usual environment variables are honoured: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES.

Pusher

Bases: Thread

Background exporter: pushes every interval seconds until :meth:stop.

to_otlp(registry, resource=None, start_ns=None, now_ns=None)

ExportMetricsServiceRequest (OTLP JSON) for the registry's current state.

metrics_url(endpoint=None)

Resolve the OTLP/HTTP metrics URL from an explicit endpoint or the standard environment variables.

push(registry, url, headers=None, timeout=10.0, **kw)

POST one export; returns the HTTP status (raises OSError on network errors).