Skip to content

fix(Metric): canonicalize attribute order in series keys - #7993

Merged
tim-smart merged 5 commits into
Effect-TS:mainfrom
kitlangton:audit/c2-r8-metric-attribute-order
Sep 4, 2026
Merged

fix(Metric): canonicalize attribute order in series keys#7993
tim-smart merged 5 commits into
Effect-TS:mainfrom
kitlangton:audit/c2-r8-metric-attribute-order

Conversation

@kitlangton

@kitlangton kitlangton commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Why

Metrics with the same id and equal attributes could create separate series when the attributes were inserted in a different order.

What changed

  • Canonicalize attribute order when building registry keys, using an in-place sort over the fresh entry array.
  • Cover record, wrapper, contextual, and metric/context merge order in Metric.test.ts.
  • Preserve caller and public metadata order.

Verification

pnpm lint-fix
pnpm test --run packages/effect/test/Metric.test.ts packages/opentelemetry/test
pnpm --filter effect check
git diff --check

Closes #7992
Closes EFF-1221

Audit

Runtime correctness audit; intended label: audit.

@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4f2b1fe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 34.05 KB 34.05 KB 0.00 KB (0.00%)
basic.ts 7.15 KB 7.15 KB 0.00 KB (0.00%)
batching.ts 10.38 KB 10.38 KB 0.00 KB (0.00%)
brand.ts 6.63 KB 6.63 KB 0.00 KB (0.00%)
cache.ts 11.03 KB 11.03 KB 0.00 KB (0.00%)
config.ts 21.75 KB 21.75 KB 0.00 KB (0.00%)
differ.ts 20.55 KB 20.55 KB 0.00 KB (0.00%)
http-client.ts 22.20 KB 22.20 KB 0.00 KB (0.00%)
http-router.ts 32.90 KB 32.90 KB 0.00 KB (0.00%)
logger.ts 11.12 KB 11.12 KB 0.00 KB (0.00%)
metric.ts 9.28 KB 9.25 KB +0.03 KB (+0.35%)
optic.ts 6.87 KB 6.87 KB 0.00 KB (0.00%)
pubsub.ts 15.49 KB 15.49 KB 0.00 KB (0.00%)
queue.ts 12.09 KB 12.09 KB 0.00 KB (0.00%)
schedule.ts 11.20 KB 11.20 KB 0.00 KB (0.00%)
schema-binary.ts 39.70 KB 39.70 KB 0.00 KB (0.00%)
schema-class.ts 20.32 KB 20.32 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.48 KB 30.48 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 26.41 KB 26.41 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.89 KB 13.89 KB 0.00 KB (0.00%)
schema-string.ts 11.38 KB 11.38 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.76 KB 15.76 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 33.59 KB 33.59 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.76 KB 24.76 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.51 KB 19.51 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 19.65 KB 19.65 KB 0.00 KB (0.00%)
schema-toFormatter.ts 19.77 KB 19.77 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 23.84 KB 23.84 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.79 KB 19.79 KB 0.00 KB (0.00%)
schema.ts 19.53 KB 19.53 KB 0.00 KB (0.00%)
stm.ts 13.03 KB 13.03 KB 0.00 KB (0.00%)
stream.ts 10.06 KB 10.06 KB 0.00 KB (0.00%)

@tim-smart tim-smart added the audit Findings originating from the Effect runtime correctness audit label Sep 4, 2026
@tim-smart
tim-smart enabled auto-merge (squash) September 4, 2026 05:37
@tim-smart
tim-smart disabled auto-merge September 4, 2026 05:45
@tim-smart
tim-smart merged commit 53e6c73 into Effect-TS:main Sep 4, 2026
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 audit Findings originating from the Effect runtime correctness audit bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Equivalent metric labels create separate series in different insertion orders

2 participants