Add X-Incognia-Latency header with previous request latency#100
Add X-Incognia-Latency header with previous request latency#100alangalvino wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds client-side tracking of the previous API call latency and sends it on subsequent Incognia API requests via the X-Incognia-Latency header.
Changes:
- Introduces latency measurement/state in
IncogniaAPIand injectsX-Incognia-Latencyon requests after the first successful call. - Routes existing API POST calls through a new internal
__postwrapper to centralize header injection + timing. - Adds unit tests for first-call/second-call and cross-endpoint sequencing, resetting the singleton per test.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
incognia/api.py |
Adds latency tracking and a centralized POST wrapper that conditionally adds X-Incognia-Latency. |
tests/test_api.py |
Adds tests asserting presence/absence of the latency header across request flows and resets singleton state in setUp. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
figueredo
left a comment
There was a problem hiding this comment.
Deixando aprovado, mas vale ver as sugestão do Copilot
There was a problem hiding this comment.
Pull request overview
Adds client-side tracking of the last successful request duration and sends it on subsequent API calls via the X-Incognia-Latency header, with tests validating cross-endpoint flows and ensuring the first call omits the header.
Changes:
- Introduce a latency-tracking
__postwrapper inIncogniaAPIthat injectsX-Incognia-Latencyfrom the previous successful call. - Route existing API methods through
__post(including consistently passingparams=Nonewhere applicable). - Add unit tests for first-call behavior and for latency propagation across signup/payment/feedback sequences.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
incognia/api.py |
Adds latency state + mutex and wraps POST requests to attach X-Incognia-Latency based on the previous call. |
tests/test_api.py |
Adds tests asserting header absence on first call and presence on subsequent calls; updates expectations to include params=None. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
01f4511 to
af33dd5
Compare
Summary
X-Incognia-Latencyon API calls using the latency from the previous successful request