feat(telemetry): generated metrics schema and CI compatibility gate - #922
Open
sirahd wants to merge 2 commits into
Open
feat(telemetry): generated metrics schema and CI compatibility gate#922sirahd wants to merge 2 commits into
sirahd wants to merge 2 commits into
Conversation
sirahd
force-pushed
the
sira/telemetry-schema-contract
branch
from
July 30, 2026 00:02
6eaefb6 to
d309473
Compare
sirahd
force-pushed
the
sira/telemetry-schema-contract
branch
from
July 30, 2026 19:21
d309473 to
8e75241
Compare
sirahd
force-pushed
the
sira/telemetry-schema-contract
branch
4 times, most recently
from
July 31, 2026 00:00
ebbb146 to
45a0729
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 45a0729. Configure here.
sirahd
force-pushed
the
sira/telemetry-schema-contract
branch
from
July 31, 2026 20:09
5797c10 to
82a233c
Compare
Publishes the telemetry metric vocabulary as a generated, committed JSON
Schema and enforces the compatibility rules consumers depend on.
telemetry/metrics.schema.json is the source of truth for what the client
collects: every one of the 65 properties carries a description of what it
measures and its unit, so a consumer needs nothing from this repo's source
to interpret a document. A test fails the build if any property reaches the
schema without one - a metric documented only by its name is a metric nobody
outside this repo can read.
xet_data/src/telemetry/payload.rs remains the source of truth for the code;
the schema is generated from it and must never be hand-edited:
UPDATE_TELEMETRY_SCHEMA=1 cargo test -p xet-data --lib telemetry::schema
Without that variable the same test asserts the committed file is current,
so a payload change that forgets to regenerate fails the build.
schemars is a dev-dependency and the JsonSchema derives are cfg(test):
`cargo tree -e normal` shows zero occurrences, so nothing ships.
Scope: this publishes what the client *emits* - property names, JSON types,
and meanings. It deliberately does not describe how any consumer stores or
indexes those documents. That is the consumer's concern, this repo is
public, and it has no way to keep a description of someone else's storage
layer correct. A consumer types its own storage from each property's `type`;
the schema states the compatibility rules that make that safe, and the
api_changes note spells out that the numeric properties must be stored as
numbers or the alerting cannot work.
CI gate (scripts/check_telemetry_schema_compat.py, telemetry-schema-compat
job) diffs the branch schema against the merge target: added property
passes, removed or retyped fails. A missing baseline is treated as the
introducing commit. Checkout uses fetch-depth 0, since the shallow default
cannot read the base ref. Verified against all six cases including
malformed input.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`test_committed_schema_is_current` compares the committed `telemetry/metrics.schema.json` byte-for-byte against a freshly generated string. Git checks that file out with CRLF on Windows under the default `core.autocrlf=true`, while the generated string always uses `\n`, so the comparison failed there and only there - reporting the schema as out of date when it was identical. This was latent: `build_and_test-win` was already failing to compile for an unrelated reason, so the test never got far enough to run. Fixing that compile error surfaced this. Normalizes line endings before comparing, and adds a `.gitattributes` entry pinning the file to LF. The test does not rely on the latter, since `.gitattributes` only governs fresh checkouts. Verified by rewriting the committed schema with CRLF locally: the test fails without the normalization and passes with it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
sirahd
force-pushed
the
sira/telemetry-schema-contract
branch
from
July 31, 2026 21:23
82a233c to
7819742
Compare
seanses
reviewed
Aug 6, 2026
seanses
left a comment
Collaborator
There was a problem hiding this comment.
Trying to understand this PR, what's the purpose of generating a JSON schema? We don't expect users to consume or use the telemetry details right?
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.

Publishes the telemetry metric vocabulary as a generated, committed JSON Schema, and enforces the compatibility rules consumers depend on. This is PR 2 of 2.
telemetry/metrics.schema.jsonis the source of truth for what we collectAll 65 properties carry a description of what they measure and their unit, so a consumer needs nothing from this repo's source to interpret a document:
A test fails the build if any property reaches the schema without a description. A metric documented only by its name is a metric nobody outside this repo can read.
xet_data/src/telemetry/payload.rsremains the source of truth for the code; the schema is generated from it and must never be hand-edited:UPDATE_TELEMETRY_SCHEMA=1 cargo test -p xet-data --lib telemetry::schemaWithout that variable, the same test asserts the committed file is current — so a payload change that forgets to regenerate fails
cargo test.schemarsis a dev-dependency and the derives arecfg(test);cargo tree -p xet-data -e normalshows zero occurrences of it or its transitive deps, so nothing ships.Scope: what this repo publishes
What the client emits — property names, JSON types, meanings.
It deliberately does not describe how any consumer stores, indexes, or aggregates these documents. That's the consumer's concern, this repo is public, and it has no way to keep a description of someone else's storage layer correct. A consumer types its own storage from each property's
type:"integer""number""boolean""string"transfer_idEvery value is a scalar: never null, never nested, never an array.
Two things the
api_changesnote flags for whoever builds the ingestion side: the numeric properties must be stored as numbers, or throughput and duration can't be averaged or range-queried — which is the entire point of collecting them. And the mapping should tolerate an unknown property, since consumers pin a tag and a client can ship ahead of a consumer rebuild.CI gate
scripts/check_telemetry_schema_compat.pydiffs the branch schema against the merge target in a newtelemetry-schema-compatjob.A missing baseline is treated as the introducing commit. Checkout needs
fetch-depth: 0— the shallow default can't read the base ref.Testing
6 schema tests: drift, every property documented, scalars only, both directions present, cross-direction type agreement, alerting metrics are numeric. I verified the drift test actually fires by tampering with the committed artifact, and exercised the CI script against all six cases (identical / missing baseline / added / removed / retyped / malformed).
cargo test --features "strict simulation internal-tools"— 38 test binaries, all greencargo clippy -r --features "strict simulation internal-tools"— cleancargo +nightly fmt— cleanChanged since first review
Dropped
telemetry/es-index-template.json. It described the receiving service's document shape and storage layout, which doesn't belong in a public repo. The generated JSON Schema now carries the type information a consumer needs to derive its own mapping, and the storage-specific guidance moved to prose in theapi_changesnote. Related wording elsewhere in these files was made storage-agnostic for the same reason.Note
Low Risk
Mostly contract, tests, and CI; runtime telemetry behavior is unchanged and
schemarsstays dev-only.Overview
Introduces a published, generated contract for client transfer telemetry: committed
telemetry/metrics.schema.jsonis built fromxet_datapayload types (via test-onlyschemars+schema.rs), not hand-edited. Payload fields gain///doc comments that become schemadescriptions; tests require every property to be documented and keep the committed file in sync (UPDATE_TELEMETRY_SCHEMA=1to regenerate).Adds
scripts/check_telemetry_schema_compat.pyand atelemetry-schema-compatCI job that diffs the branch schema against the merge target: new metrics allowed, removals or JSONtypechanges fail..gitattributespins the schema to LF for stable byte comparisons on Windows.Documents the contract in
api_changes/update_260729_telemetry_schema_contract.md(pin-by-tag URL, regeneration, consumer typing rules).Cargo.lockupdates reflectschemarsas a dev-only dependency path.Reviewed by Cursor Bugbot for commit 7819742. Bugbot is set up for automated code reviews on this repo. Configure here.