feat(observability): send X-Source header and real SDK version - #82
Merged
Merged
Conversation
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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The backend attributes traffic by the
X-Sourceheader (a captured ClickHouse channel dimension; other clients like pipecat sendX-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-Versionis hardcoded to0.0.0on every request, so you can tell an SDK called but not which version.import smallestai; smallestai.__version__raisesImportError—version.pylooks up dist namesmallest-ai, but the published distribution issmallestai.What
X-Source: smallest-python-sdkto every request (language-tagged so python/ts/go SDKs are distinguishable). User-supplied headers still win, so it's overridable.X-Fern-SDK-Versionnow sources the installed package version.version.pyto look upsmallestai, with a source-checkout fallback.core/client_wrapper.pyandversion.pyadded to.fernignore(hand-maintained, with re-sync notes in each file) so the customizations survive regeneration.Verification
Clean editable install (equivalent to a release wheel):
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-Sourcedashboard with no backend change.🤖 Generated with Claude Code