Crate iota_metrics

Source

Re-exports§

pub use scopeguard;

Modules§

hardware_metrics
histogram
metered_channel
metrics_network
monitored_mpsc
Provides wrappers to tokio mpsc channels, with metrics on total items sent, received and inflight.
thread_stall_monitor

Macros§

forward_server_timing_and_spawn
monitored_future
spawn_logged_monitored_task
spawn_monitored_task

Structs§

CancelMonitor
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.
GaugeGuard
Increments gauge when acquired, decrements when guard drops
GaugeGuardFuture
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.
Metrics
MonitoredScopeFuture
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.
MonitoredScopeGuard
RegistryService
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.

Constants§

LATENCY_SEC_BUCKETS
METRICS_ROUTE
TX_TYPE_SHARED_OBJ_TX
TX_TYPE_SINGLE_WRITER_TX

Traits§

GaugeGuardFutureExt
MonitorCancellation
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.
MonitoredFutureExt
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.

Functions§

add_server_timing
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.
get_metrics
Retrieves the global METRICS instance if it has been initialized.
get_server_timing
Get the currently active ServerTiming context. Only intended for use by macros within this module.
init_metrics
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.
is_running_in_docker
metrics
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.
monitored_scope
This function creates a named scoped object, that keeps track of
server_timing_middleware
start_prometheus_server
uptime_metric
Create a metric that measures the uptime from when this metric was constructed. The metric is labeled with:
with_new_server_timing
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.
with_server_timing
Create a new task-local ServerTiming context and run the provided future within it. Only intended for use by macros within this module.

Type Aliases§

RegistryID