@@ -4,6 +4,7 @@ use metrics::{
4
4
log_counter,
5
5
log_counter_with_labels,
6
6
log_distribution,
7
+ log_distribution_with_labels,
7
8
register_convex_counter,
8
9
register_convex_histogram,
9
10
StaticMetricLabel ,
@@ -32,9 +33,9 @@ pub fn connect_timer() -> StatusTimer {
32
33
register_convex_histogram ! (
33
34
SYNC_HANDLE_MESSAGE_SECONDS ,
34
35
"Time to handle a websocket message" ,
35
- & [ "status" , "endpoint" ]
36
+ & [ "status" , "endpoint" , "instance_name" ]
36
37
) ;
37
- pub fn handle_message_timer ( message : & ClientMessage ) -> StatusTimer {
38
+ pub fn handle_message_timer ( message : & ClientMessage , instance_name : String ) -> StatusTimer {
38
39
let mut timer = StatusTimer :: new ( & SYNC_HANDLE_MESSAGE_SECONDS ) ;
39
40
let request_name = match message {
40
41
ClientMessage :: Authenticate { .. } => "Authenticate" ,
@@ -45,25 +46,30 @@ pub fn handle_message_timer(message: &ClientMessage) -> StatusTimer {
45
46
ClientMessage :: Event { .. } => "Event" ,
46
47
} ;
47
48
timer. add_label ( StaticMetricLabel :: new ( "endpoint" , request_name. to_owned ( ) ) ) ;
49
+ timer. add_label ( StaticMetricLabel :: new ( "instance_name" , instance_name) ) ;
48
50
timer
49
51
}
50
52
51
53
register_convex_histogram ! (
52
54
SYNC_UPDATE_QUERIES_SECONDS ,
53
55
"Time to update queries" ,
54
- & STATUS_LABEL
56
+ & [ STATUS_LABEL [ 0 ] , "instance_name" ]
55
57
) ;
56
- pub fn update_queries_timer ( ) -> StatusTimer {
57
- StatusTimer :: new ( & SYNC_UPDATE_QUERIES_SECONDS )
58
+ pub fn update_queries_timer ( instance_name : String ) -> StatusTimer {
59
+ let mut timer = StatusTimer :: new ( & SYNC_UPDATE_QUERIES_SECONDS ) ;
60
+ timer. add_label ( StaticMetricLabel :: new ( "instance_name" , instance_name) ) ;
61
+ timer
58
62
}
59
63
60
64
register_convex_histogram ! (
61
65
SYNC_MUTATION_QUEUE_SECONDS ,
62
66
"Time between a mutation entering and exiting the single threaded sync worker queue" ,
63
- & STATUS_LABEL
67
+ & [ STATUS_LABEL [ 0 ] , "instance_name" ]
64
68
) ;
65
- pub fn mutation_queue_timer ( ) -> StatusTimer {
66
- StatusTimer :: new ( & SYNC_MUTATION_QUEUE_SECONDS )
69
+ pub fn mutation_queue_timer ( instance_name : String ) -> StatusTimer {
70
+ let mut timer = StatusTimer :: new ( & SYNC_MUTATION_QUEUE_SECONDS ) ;
71
+ timer. add_label ( StaticMetricLabel :: new ( "instance_name" , instance_name) ) ;
72
+ timer
67
73
}
68
74
69
75
register_convex_counter ! ( SYNC_QUERY_FAILED_TOTAL , "Number of query failures" ) ;
@@ -108,17 +114,27 @@ pub fn log_connect(last_close_reason: String, connection_count: u32) {
108
114
register_convex_histogram ! (
109
115
SYNC_LINEARIZABILITY_DELAY_SECONDS ,
110
116
"How far behind the current backend is behind what the client has observed" ,
117
+ & [ "instance_name" ]
111
118
) ;
112
- pub fn log_linearizability_violation ( delay_secs : f64 ) {
113
- log_distribution ( & SYNC_LINEARIZABILITY_DELAY_SECONDS , delay_secs) ;
119
+ pub fn log_linearizability_violation ( delay_secs : f64 , instance_name : String ) {
120
+ log_distribution_with_labels (
121
+ & SYNC_LINEARIZABILITY_DELAY_SECONDS ,
122
+ delay_secs,
123
+ vec ! [ StaticMetricLabel :: new( "instance_name" , instance_name) ] ,
124
+ ) ;
114
125
}
115
126
116
127
register_convex_histogram ! (
117
128
SYNC_PROCESS_CLIENT_MESSAGE_SECONDS ,
118
129
"Delay between receiving a client message over the web socket and processing it" ,
130
+ & [ "instance_name" ]
119
131
) ;
120
- pub fn log_process_client_message_delay ( delay : Duration ) {
121
- log_distribution ( & SYNC_PROCESS_CLIENT_MESSAGE_SECONDS , delay. as_secs_f64 ( ) ) ;
132
+ pub fn log_process_client_message_delay ( delay : Duration , instance_name : String ) {
133
+ log_distribution_with_labels (
134
+ & SYNC_PROCESS_CLIENT_MESSAGE_SECONDS ,
135
+ delay. as_secs_f64 ( ) ,
136
+ vec ! [ StaticMetricLabel :: new( "instance_name" , instance_name) ] ,
137
+ ) ;
122
138
}
123
139
124
140
register_convex_histogram ! (
0 commit comments