Expand description
Measurements the pipeline takes for a host that exports metrics.
The engine is shared with hosts that have no metrics pipeline – a
Cloudflare Worker, a test – and builds for wasm32, so it does not depend on
OpenTelemetry or any other metrics crate. Instead a host that does export
metrics installs an Observer once, at start-up, and the pipeline calls
it with what it measured.
§What it costs when nothing is installed
One load of an initialised-or-not flag per measurement point, and nothing else: the clock is not even read unless an observer is there to be told. That is the point of doing it this way rather than always timing and throwing the result away – a request that nobody is measuring pays for nothing it does not use.
§Why a process-wide hook
Metrics are process-wide anyway: an OpenTelemetry meter provider and a
Prometheus registry are each one per process, and so is the endpoint a
scraper reads. Threading an observer through State would
give every host a method to implement for something only one of them uses.
Traits§
- Observer
- What a host wants to be told about. Every method has a default that ignores the measurement, so an observer names only what it records, and a measurement added here later breaks no host’s build.
Functions§
- set_
observer - Install the observer, once per process.