Sitelet https://github.com/Stephenson-Software/trace-client-python/pull/6
Skip to content

Tag every event with the program's version; version is now required (0.3.0) - #6

Merged
dmccoystephenson merged 2 commits into
mainfrom
program-version-on-every-event
Sep 30, 2026
Merged

dmccoystephenson merged 2 commits into
mainfrom
program-version-on-every-event

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Every event the Python client sends now carries the program's own version as the tag version, matching the change made in the Java client (Stephenson-Software/trace-client-java#5).

  • TraceClient(base_url, application, version, *, key=None, enabled=True): the program version is a required third positional argument. It is trimmed; None, a blank string, or one longer than 255 characters after trimming raises ValueError. MAX_TAG_LENGTH = 255 is exported.
  • Every event (startup, command, anything) is sent with version = that program version. If the event's own tags already contain version, the event's value wins. The caller's tags dict is copied, never modified (new _with_version helper, mirroring Java's withVersion). The Python client has no server-wide tags, so the precedence is simply event tags > program version.
  • TraceClient.disabled() still constructs, with an internal placeholder version "disabled".
  • Unchanged: the User-Agent still carries the client's version (trace-client-python/0.3.0 (App)), and the opt-out logic (environment, enabled, key) is untouched.
  • Breaking: version bumped 0.2.0 → 0.3.0 in __version__, pyproject.toml and both file headers.

Docs

The README example now passes __version__ and no longer tags startup by hand. A new section, "Every event carries the program's version", covers the required argument, the tag on every event, the event's own tag winning, and upgrading from 0.2.0. The wire-format example now shows a command event carrying version. The repo has no CHANGELOG.

Tests

Existing tests were updated to the new signature and expected bodies. New tests cover: a command event tagged with the trimmed version, an event's own version winning (with the caller's dict unchanged), report never modifying the caller's tags, _with_version copying rather than mutating, and a missing/blank/overlong version being rejected (a version of exactly 255 characters is accepted).

  • python -m unittest -v (the CI command): 26 tests pass on Python 3.8.10 and 3.11.15.
  • Mutation probe: with the version injection removed from report, 4 tests fail; restored, all 26 pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AuTszT2gqv7nLVYrtKD4ji


drafted by Claude on behalf of Daniel Stephenson

dmccoystephenson and others added 2 commits September 29, 2026 21:28
…0.3.0)

TraceClient takes the program's own version as a required third positional
argument, trimmed; a missing/blank one or one over 255 characters raises
ValueError. Every event the client sends carries it as the tag `version`,
unless the event's own tags already have one. The caller's tags are copied,
never modified. TraceClient.disabled() uses an internal placeholder version.
The User-Agent still names the client's version, and the opt-out logic is
unchanged. Mirrors trace-client-java PR #5.

Breaking change: 0.2.0 -> 0.3.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AuTszT2gqv7nLVYrtKD4ji
…ry-event

Keeps #4's name check inside report()'s try and applies _with_version
there; the two tests #4 added now pass a program version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AuTszT2gqv7nLVYrtKD4ji
@dmccoystephenson
dmccoystephenson merged commit 8686af6 into main Sep 30, 2026
3 checks passed
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