Send previous request latency via X-Incognia-Latency#43
Send previous request latency via X-Incognia-Latency#43alangalvino wants to merge 1 commit intomainfrom
Conversation
21ff6c9 to
67d2f2b
Compare
There was a problem hiding this comment.
Pull request overview
Adds client-side tracking of the previous successful request latency and forwards it on subsequent requests via the X-Incognia-Latency header, with accompanying specs to validate omission on first call and propagation/override behavior.
Changes:
- Introduce
X-Incognia-Latencyheader injection based on the prior successful request’s measured latency. - Add thread-safe storage of the last request latency in the singleton client.
- Add RSpec coverage for first-call omission, cross-endpoint propagation, and overriding caller-provided latency.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| lib/incognia_api/client.rb | Track/store last request latency and inject it into subsequent request headers. |
| spec/client_spec.rb | Add specs validating latency header behavior across calls/endpoints and override semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
67d2f2b to
1a3fb5b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Track the latency of the last successful API call in the shared client and send it in the X-Incognia-Latency header on subsequent requests. This aligns the Ruby SDK with the new metrics contract without changing request bodies, and adds specs covering first-call omission and propagation across requests. ▄
1a3fb5b to
0d0e637
Compare
|
|
||
| if (latency = last_latency_ms) | ||
| request_headers[LATENCY_HEADER] = latency.to_s | ||
| end |
There was a problem hiding this comment.
Wdyt?
| if (latency = last_latency_ms) | |
| request_headers[LATENCY_HEADER] = latency.to_s | |
| end | |
| request_headers[LATENCY_HEADER] = last_latency_ms&.to_s |
And when sending the request, use a compact
response = connection.send(method, endpoint, json_data, request_headers.compact)
Summary
X-Incognia-Latencyheader on subsequent requests without changing request bodies