@@ -175,8 +175,15 @@ def on_operation_complete(self, op: CompletedOperationMetric) -> None:
175175 is_streaming = str (op .is_streaming )
176176
177177 self .otel .operation_latencies .record (
178- op .duration_ms , {"streaming" : is_streaming , ** labels }
178+ op .duration_ns / 1e6 , {"streaming" : is_streaming , ** labels }
179179 )
180+ if (
181+ op .op_type == OperationType .READ_ROWS
182+ and op .first_response_latency_ns is not None
183+ ):
184+ self .otel .first_response_latencies .record (
185+ op .first_response_latency_ns / 1e6 , labels
186+ )
180187 # only record completed attempts if there were retries
181188 if op .completed_attempts :
182189 self .otel .retry_count .add (len (op .completed_attempts ) - 1 , labels )
@@ -203,26 +210,19 @@ def on_attempt_complete(
203210 is_streaming = str (op .is_streaming )
204211
205212 self .otel .attempt_latencies .record (
206- attempt .duration_ms , {"streaming" : is_streaming , "status" : status , ** labels }
213+ attempt .duration_ns , {"streaming" : is_streaming , "status" : status , ** labels }
207214 )
208- combined_throttling = attempt .grpc_throttling_time_ms
215+ combined_throttling = attempt .grpc_throttling_time_ns / 1e6
209216 if not op .completed_attempts :
210217 # add flow control latency to first attempt's throttling latency
211- combined_throttling += op .flow_throttling_time_ms
218+ combined_throttling += ( op .flow_throttling_time_ns / 1e6 if op . flow_throttling_time_ns else 0 )
212219 self .otel .throttling_latencies .record (combined_throttling , labels )
213220 self .otel .application_latencies .record (
214- attempt .application_blocking_time_ms + attempt .backoff_before_attempt_ms , labels
221+ ( attempt .application_blocking_time_ns + attempt .backoff_before_attempt_ns ) / 1e6 , labels
215222 )
216- if (
217- op .op_type == OperationType .READ_ROWS
218- and attempt .first_response_latency_ms is not None
219- ):
220- self .otel .first_response_latencies .record (
221- attempt .first_response_latency_ms , {"status" : status , ** labels }
222- )
223- if attempt .gfe_latency_ms is not None :
223+ if attempt .gfe_latency_ns is not None :
224224 self .otel .server_latencies .record (
225- attempt .gfe_latency_ms ,
225+ attempt .gfe_latency_ns / 1e6 ,
226226 {"streaming" : is_streaming , "status" : status , ** labels },
227227 )
228228 else :
0 commit comments