A future that runs within a monitored scope. This struct wraps a pinned
future and holds an optional MonitoredScopeGuard to measure and monitor
the execution of the future. It forwards polling operations
to the underlying future while maintaining the monitoring scope.
A struct that wraps a future (f) with a GaugeGuard. The
GaugeGuardFuture is used to manage the lifecycle of a future while
ensuring the associated GaugeGuard properly tracks the resource usage
during the future’s execution. The guard increments the gauge
when the future starts and decrements it when the GaugeGuardFuture is
dropped.
A future that runs within a monitored scope. This struct wraps a pinned
future and holds an optional MonitoredScopeGuard to measure and monitor
the execution of the future. It forwards polling operations
to the underlying future while maintaining the monitoring scope.
A service to manage the prometheus registries. This service allow us to
create a new Registry on demand and keep it accessible for
processing/polling. The service can be freely cloned/shared across threads.
MonitorCancellation records a cancelled = true span attribute if the future
it is decorating is dropped before completion. The cancelled attribute must
be added at span creation, as you cannot add new attributes after the span
is created.
A trait extension for Future to allow monitoring the execution of the
future within a specific scope. Provides the in_monitored_scope method to
wrap the future in a MonitoredScopeFuture, which tracks the future’s
execution using a MonitoredScopeGuard for monitoring purposes.
Add a new entry to the ServerTiming header.
If the caller is not currently in a ServerTiming context (created with
with_new_server_timing), an error is logged.
Initializes the global METRICS instance by setting it to a new Metrics
object registered with the provided Registry. If METRICS is already set,
a warning is logged indicating that the metrics registry was overwritten.
This function is intended to be called once during initialization to set up
metrics collection.
Handles a request to retrieve metrics, using the provided RegistryService
to gather all registered metric families. The metrics are then encoded to a
text format for easy consumption by monitoring systems. If successful, it
returns the metrics string with an OK status. If an error occurs during
encoding, it returns an INTERNAL_SERVER_ERROR status along with an error
message. Returns a tuple containing the status code and either the metrics
data or an error description.
Create a new task-local ServerTiming context and run the provided future
within it. Should be used at the top-most level of a request handler. Can be
added to an axum router as a layer by using
iota_service::server_timing_middleware.