Repository navigation
Add user agent to query client - #1875
Merged
Merged
Conversation
Deploying logfire-docs with
|
| Latest commit: |
cec1d6a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ff82c0b6.logfire-docs.pages.dev |
| Branch Preview URL: | https://vp-query-client-ua.logfire-docs.pages.dev |
3 tasks done
adriangb
added a commit
that referenced
this pull request
May 5, 2026
This reverts commit ff5c802. With X-Logfire-Telemetry now carrying SDK version, Python version, implementation and OS, the custom User-Agent on the query client is duplicate plumbing for the same product analytics question. Letting httpx send its default UA again, and the next commit adds the telemetry header here. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
adriangb
added a commit
that referenced
this pull request
May 13, 2026
This reverts commit ff5c802. With X-Logfire-Telemetry now carrying SDK version, Python version, implementation and OS, the custom User-Agent on the query client is duplicate plumbing for the same product analytics question. Letting httpx send its default UA again, and the next commit adds the telemetry header here. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
adriangb
added a commit
that referenced
this pull request
May 13, 2026
Adds an `X-Logfire-Telemetry: key=val,...` header to every request the SDK sends (OTLP exports, token validation, CRUD calls, variable provider, CLI), carrying the SDK version and a curated set of non-sensitive `_LogfireConfigData` fields so the backend can drive product analytics and deprecation decisions. Tokens, API keys, service name, environment, etc. are explicitly excluded. Also installs a response hook on every Logfire SDK session that surfaces `X-Logfire-Warning` headers via `warnings.warn` (deduplicated by Python's default filter) and raises `LogfireServerError` on `X-Logfire-Error` headers, so the server can deprecate endpoints or signal hard failures out-of-band. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> trim telemetry pairs, add service.instance.id, document rationale per field * Limit `_LogfireConfigData`-derived pairs to `code_source_set`, `variables_set`, and `token_count` — the only ones with a concrete product question they answer. Each remaining field now has an inline comment explaining why we send it. * Carry the resolved `service.instance.id` (UUID generated inside `_initialize`, shared with OTLP resource attributes) so the backend can correlate the header on non-OTLP requests with the spans this SDK instance exports. * Drop the `None` branch of `_format_value` and the idempotency guard in `install_logfire_response_hook` — both were unreachable, which was tripping the coverage gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> move service_instance_id into _config_telemetry_pairs It only ships when a LogfireConfig is available, so it belongs in the config-derived group rather than the always-sent base group. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Revert "Add user agent to query client (#1875)" This reverts commit ff5c802. With X-Logfire-Telemetry now carrying SDK version, Python version, implementation and OS, the custom User-Agent on the query client is duplicate plumbing for the same product analytics question. Letting httpx send its default UA again, and the next commit adds the telemetry header here. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> address review: JSON header value, implementation field, cache base pairs, query client - Encode the X-Logfire-Telemetry value as compact JSON instead of a comma-separated key=val list. Removes a silent footgun if any value ever contains "," or "=", and lets us send native bool/int instead of formatting them as strings. - Rename the `runtime` field to `implementation` to match Python's own wording for `sys.implementation.name`. - Cache `_base_telemetry_pairs()` with `functools.cache` since the value is constant per-process. - Wire the same telemetry header into the experimental query client now that the previous custom User-Agent has been reverted. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> split out response-header handling into its own PR Per review (#1905#discussion_r3189043209), the X-Logfire-Warning / X-Logfire-Error response-hook handling is logically independent from the X-Logfire-Telemetry request header — they just happened to be introduced together. Moved that code (plus its exceptions, install calls, and tests) to a separate PR (#1906) so each can be reviewed and landed on its own. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
No description provided.