metrics.rs

Overview

This file defines the RoutingMetrics struct, which encapsulates telemetry metrics related to routing operations in the system. It provides a structured way to record and report different types of metrics, including histograms for measuring durations and counters for event counts. The metrics are designed to be used with an OpenTelemetry meter, enabling detailed monitoring of routing performance and request handling.

RoutingMetrics Struct

Description

RoutingMetrics holds several OpenTelemetry metric instruments used to track routing-related metrics:

The struct is marked Clone to allow duplication of metric handles.

Fields

Field

Type

Description

ext_msg_delivery_duration

Histogram<u64>

Histogram for external message delivery durations.

ext_msg_processing_duration

Histogram<u64>

Histogram for external message processing durations, with buckets.

boc_by_address_response

Histogram<u64>

Histogram for "BOC by address" response durations, with buckets.

state_request

Counter<u64>

Counter for counting state requests received.

Methods

new(meter: &Meter) -> RoutingMetrics

Creates and initializes a new RoutingMetrics instance using the provided OpenTelemetry Meter.

report_ext_msg_delivery_duration(&self, value: u64)

Records a single measurement of external message delivery duration.

report_ext_msg_processing_duration(&self, value: u64, http_code: u16)

Records the duration of processing an external message, with an associated HTTP response code label.

report_boc_by_address_response(&self, value: u64, http_code: u16)

Records the duration of "BOC by address" response times, tagged with HTTP status code.

report_state_request(&self)

Increments the counter for received state requests by one.

Implementation Details

Interaction With Other Components

Visual Diagram

classDiagram
class RoutingMetrics {
+ext_msg_delivery_duration: Histogram<u64>
+ext_msg_processing_duration: Histogram<u64>
+boc_by_address_response: Histogram<u64>
+state_request: Counter<u64>
+new(meter: &Meter) RoutingMetrics
+report_ext_msg_delivery_duration(value: u64)
+report_ext_msg_processing_duration(value: u64, http_code: u16)
+report_boc_by_address_response(value: u64, http_code: u16)
+report_state_request()
}
RoutingMetrics ..> Meter : uses to create metrics
RoutingMetrics ..> Histogram : contains
RoutingMetrics ..> Counter : contains
RoutingMetrics ..> "telemetry_utils::out_of_bounds_guard!" : uses