Skip to content

feat(observability): send X-Source header and real SDK version - #82

Merged
abhishekmishragithub merged 4 commits into
mainfrom
feat/sdk-source-header
Aug 5, 2026
Merged

abhishekmishragithub merged 4 commits into
mainfrom
feat/sdk-source-header

Conversation

@abhishekmishragithub

Copy link
Copy Markdown
Collaborator

Why

The backend attributes traffic by the X-Source header (a captured ClickHouse channel dimension; other clients like pipecat send X-Source: pipecat). SDK requests carried no such header, so SDK usage was invisible on that dashboard. Two related gaps in the released 5.4.1 wheel:

  • X-Fern-SDK-Version is hardcoded to 0.0.0 on every request, so you can tell an SDK called but not which version.
  • import smallestai; smallestai.__version__ raises ImportErrorversion.py looks up dist name smallest-ai, but the published distribution is smallestai.

What

  • Add X-Source: smallest-python-sdk to every request (language-tagged so python/ts/go SDKs are distinguishable). User-supplied headers still win, so it's overridable.
  • X-Fern-SDK-Version now sources the installed package version.
  • Fix version.py to look up smallestai, with a source-checkout fallback.
  • core/client_wrapper.py and version.py added to .fernignore (hand-maintained, with re-sync notes in each file) so the customizations survive regeneration.
  • Unit tests asserting both headers, override precedence, and version import.
  • Bumps to 5.4.2.

Verification

Clean editable install (equivalent to a release wheel):

smallestai.__version__ = 5.4.2
X-Source            = smallest-python-sdk
X-Fern-SDK-Version  = 5.4.2   (was 0.0.0)
X-Fern-SDK-Name     = smallest-ai

tests/custom/test_source_headers.py — 4/4 pass. (The repo's WireMock suite needs Docker and wasn't run locally; CI covers it.)

Once merged, SDK traffic shows up in the existing X-Source dashboard with no backend change.

🤖 Generated with Claude Code

Every request now carries source-attribution headers so SDK-originated
traffic is measurable in the backend (X-Source is a captured channel
dimension, same convention other clients use):

- Add `X-Source: smallest-python-sdk` to every request. User-supplied
  headers still take precedence, so it can be overridden.
- `X-Fern-SDK-Version` now reports the installed package version instead of
  the generator's hardcoded `0.0.0`, so version adoption is trackable.
- Fix `smallestai.__version__`: version.py looked up the wrong distribution
  name (`smallest-ai`) and raised PackageNotFoundError; the dist is
  `smallestai`. Now resolves, with a source-checkout fallback.

client_wrapper.py and version.py are hand-maintained (added to .fernignore)
to preserve these customizations across regeneration. Adds unit tests
asserting both headers and version import.

Bumps version to 5.4.2.
abhishekmishragithub and others added 3 commits August 5, 2026 18:43
Avoids reintroducing the 0.0.0 placeholder in X-Fern-SDK-Version when running
from a checkout, so the backend can tell checkout traffic from a real install.
…LI, the SMALLEST_BASE_URL payment fix, and the waves method-name doc fix
@abhishekmishragithub
abhishekmishragithub merged commit b6336eb into main Aug 5, 2026
3 checks passed
@abhishekmishragithub
abhishekmishragithub deleted the feat/sdk-source-header branch August 5, 2026 14:15
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.

1 participant