Skip to content

fix(telemetry): send X-SDK-Language and X-Client-Type headers#40

Merged
karlwaldman merged 1 commit into
mainfrom
sprint-loop/issue-4
Jun 22, 2026
Merged

fix(telemetry): send X-SDK-Language and X-Client-Type headers#40
karlwaldman merged 1 commit into
mainfrom
sprint-loop/issue-4

Conversation

@karlwaldman

Copy link
Copy Markdown
Member

Closes #4

What

The sync (OilPriceAPI) and async (AsyncOilPriceAPI) clients already sent X-SDK-Name and X-SDK-Version, but omitted the two telemetry headers the API uses to distinguish SDK traffic from raw python-httpx/python-requests calls. As reported in #4, 0/166 recent Python requests carried X-SDK-Language and X-Client-Type.

This adds the two missing headers to both clients (additive, 4 lines):

X-SDK-Language: python
X-Client-Type: sdk

X-SDK-Version was already present and is retained.

How (strict TDD: red → green → refactor)

  1. RED — Added tests/test_telemetry_headers.py encoding the issue's acceptance criteria for both sync and async clients: headers are configured AND actually transmitted on the wire (via httpx.MockTransport capturing the outbound request). 6 of 8 assertions failed against the unpatched clients.
  2. GREEN — Added X-SDK-Language: python and X-Client-Type: sdk to the header dict in client.py and async_client.py. All 8 new tests pass.
  3. REFACTOR — None needed; change is minimal and already clean.

Test evidence

tests/test_telemetry_headers.py ........  [100%]
8 passed

# Full CI gate
ruff check oilpriceapi/        -> All checks passed!
pytest tests/ (not slow)       -> 328 passed (was 320 + 8 new)
mypy oilpriceapi/client.py oilpriceapi/async_client.py --ignore-missing-imports -> Success: no issues found

Note: a full-tree mypy oilpriceapi/ run in this local env errors only inside the third-party numpy/__init__.pyi stub under Python 3.14 (type statement support); this failure is identical on the unmodified baseline and is unrelated to this change. The changed files type-check cleanly, and CI runs on the supported Python 3.8–3.12 targets.

Scope

Additive only. No migrations, Stripe, auth, routes, or customer-facing copy touched.

🤖 Generated with Claude Code

Every SDK request must identify itself to the API for adoption tracking.
The sync and async clients already sent X-SDK-Name and X-SDK-Version but
omitted X-SDK-Language and X-Client-Type, so 0/166 recent requests could be
attributed to the Python SDK vs raw python-httpx/python-requests calls.

Add the two missing telemetry headers to both OilPriceAPI (sync) and
AsyncOilPriceAPI clients:

    X-SDK-Language: python
    X-Client-Type: sdk

Change is additive (4 lines) and does not alter existing behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@karlwaldman, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 38 minutes and 50 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6cdc1269-fb62-4e55-905b-cf738c328f8b

📥 Commits

Reviewing files that changed from the base of the PR and between 7c7b777 and 8efeeab.

📒 Files selected for processing (3)
  • oilpriceapi/async_client.py
  • oilpriceapi/client.py
  • tests/test_telemetry_headers.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sprint-loop/issue-4

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@karlwaldman karlwaldman merged commit 210058e into main Jun 22, 2026
6 checks passed
@karlwaldman karlwaldman deleted the sprint-loop/issue-4 branch June 22, 2026 11:26
karlwaldman added a commit that referenced this pull request Jul 3, 2026
Every SDK request must identify itself to the API for adoption tracking.
The sync and async clients already sent X-SDK-Name and X-SDK-Version but
omitted X-SDK-Language and X-Client-Type, so 0/166 recent requests could be
attributed to the Python SDK vs raw python-httpx/python-requests calls.

Add the two missing telemetry headers to both OilPriceAPI (sync) and
AsyncOilPriceAPI clients:

    X-SDK-Language: python
    X-Client-Type: sdk

Change is additive (4 lines) and does not alter existing behavior.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P0: SDK Telemetry Headers Not Being Sent

1 participant