Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the AFE server timing checks into standalone helper functions in common.ts and updates the Spanner client and metrics tracer to use them. It also ensures that 0ms latency values are correctly recorded by checking for numeric types instead of truthiness. The review feedback identifies critical potential TypeError crashes in MetricInterceptor when metricsTracer is undefined (e.g., when metrics are disabled) and suggests guarding the metadata and status handling blocks to prevent runtime errors.
f9df8a2 to
e48d6fc
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the AFE server timing check functions out of the Spanner class into common.ts and updates the metrics interceptor and tracer to use them. It also refines how GFE and AFE latency metrics are recorded, including handling cases where latency is 0ms and adding safety checks when the metrics tracer is null. The review feedback highlights two critical issues in MetricsTracer where recordGfeLatency and recordAfeLatency log an error when latency is null or undefined but still proceed to record the invalid value, suggesting early returns to prevent potential runtime exceptions.
Hoist isAFEServerTimingEnabled check to MetricInterceptor to completely bypass AFE header parsing and metric recording when AFE server-timing is disabled. Also guard MetricsTracer record methods to avoid attribute allocation when instruments are uninitialized.
e48d6fc to
c04bb43
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the AFE server timing check by moving isAFEServerTimingEnabled from the Spanner class to a standalone function in common.ts and updates the metrics interceptor and tracer to respect this setting. It also improves robustness by checking for null/undefined tracers and allowing 0 as a valid latency value, backed by new unit tests. The review feedback correctly identifies that recordGfeLatency and recordAfeLatency in MetricsTracer should return early when their respective latency values are null or undefined to prevent passing invalid arguments to the recording instruments.
Hoist isAFEServerTimingEnabled check to MetricInterceptor to completely bypass AFE header parsing and metric recording when AFE server-timing is disabled. Also guard MetricsTracer record methods to avoid attribute allocation when instruments are uninitialized.