@@ -57,7 +57,6 @@ pub(crate) fn run_server(
5757/// Handler for OTLP HTTP requests
5858#[ derive( Clone , Debug ) ]
5959struct OtlpHttpHandler {
60- labels : Vec < ( String , String ) > ,
6160 metrics_labels : Vec < ( String , String ) > ,
6261 traces_labels : Vec < ( String , String ) > ,
6362 logs_labels : Vec < ( String , String ) > ,
@@ -92,7 +91,6 @@ impl OtlpHttpHandler {
9291 . expect ( "application/x-protobuf is a valid MIME type" ) ;
9392
9493 Self {
95- labels : labels. to_vec ( ) ,
9694 metrics_labels,
9795 traces_labels,
9896 logs_labels,
@@ -130,8 +128,6 @@ impl OtlpHttpHandler {
130128 self ,
131129 req : Request < hyper:: body:: Incoming > ,
132130 ) -> Result < Response < BoxBody < Bytes , hyper:: Error > > , hyper:: Error > {
133- counter ! ( "requests_received" , & self . labels) . increment ( 1 ) ;
134-
135131 // Fast-path for invalid paths
136132 let path_ref = req. uri ( ) . path ( ) ;
137133 if path_ref != "/v1/metrics" && path_ref != "/v1/traces" && path_ref != "/v1/logs" {
@@ -142,18 +138,28 @@ impl OtlpHttpHandler {
142138 . expect ( "Creating HTTP response should not fail" ) ) ;
143139 }
144140
141+ // Determine signal-specific labels based on path
142+ let signal_labels = match path_ref {
143+ "/v1/metrics" => & self . metrics_labels ,
144+ "/v1/traces" => & self . traces_labels ,
145+ "/v1/logs" => & self . logs_labels ,
146+ _ => unreachable ! ( ) , // checked earlier
147+ } ;
148+
149+ counter ! ( "requests_received" , signal_labels) . increment ( 1 ) ;
150+
145151 // Check for empty bodies using Content-Length when available
146152 if let Some ( content_length) = req. headers ( ) . get ( hyper:: header:: CONTENT_LENGTH ) {
147153 if let Ok ( length) = content_length. to_str ( ) {
148154 if let Ok ( length) = length. parse :: < u64 > ( ) {
149155 if length == 0 {
150- counter ! ( "bytes_received" , & self . labels ) . increment ( 0 ) ;
156+ counter ! ( "bytes_received" , signal_labels ) . increment ( 0 ) ;
151157
152158 let response_bytes = match path_ref {
153159 "/v1/metrics" => self . empty_metrics_response . clone ( ) ,
154160 "/v1/traces" => self . empty_traces_response . clone ( ) ,
155161 "/v1/logs" => self . empty_logs_response . clone ( ) ,
156- _ => unreachable ! ( ) , // We checked earlier
162+ _ => unreachable ! ( ) , // checked earlier
157163 } ;
158164
159165 return self . build_response ( response_bytes) . await ;
@@ -168,11 +174,11 @@ impl OtlpHttpHandler {
168174
169175 let body_bytes = body. collect ( ) . await ?. to_bytes ( ) ;
170176
171- counter ! ( "bytes_received" , & self . labels ) . increment ( body_bytes. len ( ) as u64 ) ;
177+ counter ! ( "bytes_received" , signal_labels ) . increment ( body_bytes. len ( ) as u64 ) ;
172178 let response_bytes =
173179 match crate :: codec:: decode ( content_encoding. as_ref ( ) , body_bytes. clone ( ) ) {
174180 Ok ( decoded) => {
175- counter ! ( "decoded_bytes_received" , & self . labels )
181+ counter ! ( "decoded_bytes_received" , signal_labels )
176182 . increment ( decoded. len ( ) as u64 ) ;
177183
178184 match path. as_str ( ) {
0 commit comments