Repository navigation
A ClickStack namespace erasure no longer deletes other orgs' Loom metric points - #231
Merged
Merged
Conversation
…ric points Loom's own metric points carry `loom.namespace` and no `loom.org`, and the org guard let untagged rows through, so erasing namespace `default` in one org deleted every other org's points for its own `default`. A row keyed by `loom.namespace` now matches only when it carries the erasing org's `loom.org`; the untagged allowance stays for another emitter's `service.namespace`, which no longer matches Loom's deployment constant `loom`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…rs a tenant namespace named loom Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ves and their label Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…g-free histograms Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ves; the SQL test covers sessions and an own-org foreign row Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…d loom Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…t by string shape Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…eign Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
fix/clickstack-namespace-erasure-org-scope
branch
from
November 3, 2026 22:14
c5171e0 to
fe1c51e
Compare
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
A ClickStack namespace erasure no longer deletes another org's Loom metric points for a namespace with the same name, or every Loom row when the erased namespace is named
loom.Why
Failing case: org
acmeerases namespacedefault. On the metrics tables the predicate was(Attributes['service.namespace'] = 'default' OR Attributes['loom.namespace'] = 'default') AND Attributes['loom.org'] IN ('acme', ''). Loom's own metric points carryloom.namespaceand noloom.org(server/observability/metrics.py, kept org-free for label cardinality), soloom.orgreads''and orgglobex's points for its owndefaultnamespace matched and were deleted. A second case of the same kind: erasing a namespace namedloommatchedResourceAttributes['service.namespace'] = 'loom', the constant Loom's exporter stamps on every span and log, so every Loom row without aloom.orgtag (worker spans, log lines) in every org matched.Pattern: the org guard read "no
loom.org" as "a foreign emitter", but Loom itself emits rows with no org tag.Fix: the two keys get their own org rule. A row matched by
loom.namespacemust carry the erasing org'sloom.orgexactly. A row matched byservice.namespacekeeps the untagged allowance (another emitter may hold the subject), but the valueloomnever matches. The user-scope predicate is unchanged.Scope and risk
ClickStackBackend._namespace_where, plus theservice.namespaceresource value moved into one constant,SERVICE_NAMESPACEinserver/observability/otel.py, which the exporter's resource and the backend both use (same value, no behaviour change).Loom's op and domain metrics, counters and histograms (
record_op,loom.request.duration, theserver/observability/metrics.pyinstruments and theloom.code.*counters inserver/code/app/common.py), carryloom.namespaceand noloom.org, so a namespace erasure no longer removes them: by name alone they cannot be told apart from another org's. They hold no memory content, but theirloom.namespacelabel is the namespace name, and a personal namespace's name is derived from the user's email local part. That label stays until the collector table's own TTL, if it has one, removes it; the docs page says so. Closing that residue means stampingloom.orgon those metrics, which reverses a documented cardinality decision inmetrics.pyand touches every metric call site, so it is left to its own change. The state gauges inotel_probes.pyand Loom's request spans carryloom.organd are still erased. The step's fail-closed behaviour (a precount or delete failure recordsfailed) is unchanged. A foreign emitter whoseservice.namespaceis literallyloomcan no longer be erased by namespace.Compatibility, rollout and rollback
Tests
tests/unit/test_clickstack_namespace_erasure.py::test_namespace_erasure_matches_only_this_orgs_rowsruns the built predicate on clickhouse-local over Loom untagged, other-org and own-org points, Loom deployment rows and foreign emitter rows (untagged, own org, other org), for metrics, traces and sessions, one and many namespaces, and namespacesdefaultandloom. It fails on the old predicate (untagged Loom points matched;loommatched every deployment row) and passes now.test_clickstack_user_erasure_never_matches_another_orgnow runs the user-scope predicate of every default table on clickhouse-local instead of checking its string shape; that predicate is unchanged.make format lint typecheck;tests/unit/test_clickstack_namespace_erasure.py,test_otel_erasure_lightweight.py,test_package_contracts.py,test_public_copy.py,test_doc_links.py. The full unit suite runs in CI.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. The failing case was checked against the metric attribute code and reproduced on clickhouse-local.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lintandmake typecheckpass locally;make test-unitand the integration suite run in CI.main; no merged migration is edited.frontend/changed: not changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code