Write usage logs when diverting to spanner - #2075
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the V2 observation handler to support query diversion to a dispatcher, propagates context through the remote client to forward surface metadata headers, and extracts query type determination into a reusable helper function with accompanying tests. The review feedback suggests simplifying the V2 observation handler by consolidating redundant calls to util.GetMetadata(ctx) at the beginning of the function.
…ixer into usage-logs-dispatcher
gmechali
left a comment
There was a problem hiding this comment.
Thanks for fixing this!
Curious, were you abnle to run this local, or deploy this image, and confirm the logs all showed up as expevted?
Thanks for the review! Tested locally that responses are getting logged - there's one diff where we aren't returning place types for containedInPlace requests in the spanner response, so it's not showing up in the log entry, but this is unrelated to the logger itself (is a diff in the response), so will address as a followup |
Summary
Enables consistent usage logging (WriteUsageLog), x-response-id header generation, and request metadata propagation (X-Surface HTTP header) across both default and dispatcher execution paths for V2 Observation queries.
Key Changes
Unified Usage Logging & Header Generation (handler_v2.go):
Standalone GetQueryType Helper (v2/observation/observation.go):
Context Propagation & X-Surface Forwarding (remote/client.go & remote/datasource.go):
Test Coverage: