monarch_hyperactor/
metrics.rs1use hyperactor::id::Label;
14use hyperactor_telemetry::declare_static_counter;
15use hyperactor_telemetry::declare_static_histogram;
16use opentelemetry::KeyValue;
17
18pub(crate) const UNKNOWN: &str = "unknown";
20
21pub(crate) struct EndpointAttrs([KeyValue; 2]);
27
28impl EndpointAttrs {
29 pub(crate) fn new(method: &str, actor: Option<&Label>) -> Self {
30 let actor = actor.map_or_else(|| UNKNOWN.to_owned(), |actor| actor.as_str().to_owned());
31 Self([
32 KeyValue::new("method", method.to_owned()),
33 KeyValue::new("actor", actor),
34 ])
35 }
36
37 pub(crate) fn as_slice(&self) -> &[KeyValue] {
38 &self.0
39 }
40}
41
42declare_static_histogram!(ENDPOINT_MESSAGE_SIZE_HISTOGRAM, "endpoint_message_size");
45declare_static_histogram!(
47 ENDPOINT_CALL_LATENCY_US_HISTOGRAM,
48 "endpoint_call_latency_us_histogram"
49);
50declare_static_histogram!(
52 ENDPOINT_CALL_ONE_LATENCY_US_HISTOGRAM,
53 "endpoint_call_one_latency_us_histogram"
54);
55declare_static_histogram!(
57 ENDPOINT_CHOOSE_LATENCY_US_HISTOGRAM,
58 "endpoint_choose_latency_us_histogram"
59);
60declare_static_counter!(ENDPOINT_CALL_ERROR, "endpoint_call_error");
62declare_static_counter!(ENDPOINT_CALL_ONE_ERROR, "endpoint_call_one_error");
64declare_static_counter!(ENDPOINT_CHOOSE_ERROR, "endpoint_choose_error");
66declare_static_counter!(ENDPOINT_CALL_THROUGHPUT, "endpoint_call_throughput");
68declare_static_counter!(ENDPOINT_CALL_ONE_THROUGHPUT, "endpoint_call_one_throughput");
70declare_static_counter!(ENDPOINT_CHOOSE_THROUGHPUT, "endpoint_choose_throughput");
72declare_static_histogram!(
74 ENDPOINT_STREAM_LATENCY_US_HISTOGRAM,
75 "endpoint_stream_latency_us_histogram"
76);
77declare_static_counter!(ENDPOINT_STREAM_ERROR, "endpoint_stream_error");
79declare_static_counter!(ENDPOINT_STREAM_THROUGHPUT, "endpoint_stream_throughput");
81declare_static_counter!(
83 ENDPOINT_BROADCAST_THROUGHPUT,
84 "endpoint_broadcast_throughput"
85);
86declare_static_counter!(ENDPOINT_BROADCAST_ERROR, "endpoint_broadcast_error");