Skip to content

feat(observability)!: emit canonical http.client.request.duration via framework helper#78

Merged
nicacioliveira merged 4 commits into
mainfrom
chore/recordCommerceMetric-canonical
Jun 11, 2026
Merged

feat(observability)!: emit canonical http.client.request.duration via framework helper#78
nicacioliveira merged 4 commits into
mainfrom
chore/recordCommerceMetric-canonical

Conversation

@nicacioliveira

@nicacioliveira nicacioliveira commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace the direct meter call to the legacy snake_case histogram name with the framework's recordCommerceMetric(...) helper. The VTEX and Shopify outbound-fetch factories were the only producers still hardcoding commerce_request_duration_ms, splitting outbound-fetch samples between two metrics in the data lake — the framework has been emitting canonical OTel SemConv names everywhere else.

Also bumps the @decocms/start peer dep min to >=6.6.0 (the version that exports recordCommerceMetric and finalised the canonical names).

The release workflow (feat! prefix) will cut a major bump — 5.0.0. Customers tracking ^4.x will not auto-receive this change; they need to bump the range to pick it up.

What changes for consumers

  • Metric name: outbound commerce histogram is now http.client.request.duration (canonical) instead of commerce_request_duration_ms.
  • Label rename: status_code (e.g. "200", "503") → status_class ("2xx", "5xx"). Lower cardinality, easier dashboards.
  • Label type: cached is now a boolean attribute (was a "true"/"false" string).
  • Peer dep: @decocms/start is now >=6.6.0 (was >=5.3.0).

Dashboards and alerts querying the old metric name or the status_code label need to be updated. None of the live *-tanstack sites consume those dashboards yet — the framework switched to canonical names in 6.6.x, so they were already drifting.

Test plan

  • npm test — 662/662 pass.
  • npm run typecheck — clean on touched files (pre-existing errors in blog/ are unrelated, same count on plain main).
  • npm run lint on touched files — only pre-existing warnings (unused beforeEach, any types in other files).
  • After @latest ships, install on miess-01-tanstack (and/or storefront-tanstack) and confirm canonical metric appears in stats-lake under http.client.request.duration with provider=vtex, no leftover snake_case.

Files touched

  • vtex/utils/instrumentedFetch.ts — switch to recordCommerceMetric
  • shopify/utils/instrumentedFetch.ts — switch to recordCommerceMetric
  • vtex/utils/__tests__/instrumentedFetch.test.ts — assert canonical name + new label shape
  • shopify/utils/__tests__/instrumentedFetch.test.ts — same
  • vtex/client.ts — docstring
  • README.md — docstring
  • package.json — peer dep bump + devDep bump

🤖 Generated with Claude Code


Summary by cubic

Switch VTEX and Shopify outbound fetch to emit canonical http.client.request.duration via recordCommerceMetric, replacing commerce_request_duration_ms. Also fixes blog tests to unblock CI (add Vitest imports, replace toSorted with [...].sort, and tighten a test stub) with no behavior change.

  • Migration

    • Update dashboards/alerts: query http.client.request.duration, use status_class instead of status_code, and treat cached as a boolean.
  • Dependencies

    • Bump @decocms/start peer to >=6.6.0 (dev uses 6.6.1); regenerated lockfile.

Written for commit 81bd6d1. Summary will update on new commits.

Review in cubic

… framework helper

Replace the direct meter call to the legacy snake_case histogram name with
the framework's `recordCommerceMetric(...)` helper. The framework already
emits canonical OTel SemConv names everywhere else; the VTEX and Shopify
factories were the only producers still hardcoding the old name, splitting
outbound-fetch samples between two metrics in the data lake.

Also bump the @decocms/start peer dep min to >=6.6.0 (the version that
exports `recordCommerceMetric` and finalised the canonical names).

BREAKING CHANGE: the outbound commerce histogram is now emitted as
`http.client.request.duration` (canonical) instead of
`commerce_request_duration_ms`. Status is reported as `status_class`
(2xx/3xx/4xx/5xx) instead of the full `status_code`. `cached` is now a
boolean attribute. Dashboards / alerts querying the old metric name or
labels need to be updated. Peer dep on `@decocms/start` is now `>=6.6.0`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@nicacioliveira nicacioliveira requested a review from a team June 11, 2026 15:03
igoramf
igoramf previously approved these changes Jun 11, 2026
CI runs `bun install --frozen-lockfile`; the package.json bump in this
PR wasn't reflected in bun.lock yet.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
nicacioliveira and others added 2 commits June 11, 2026 14:08
Pre-existing lint errors in blog/__tests__/handlePosts.test.ts and
blog/__tests__/loaders.test.ts surfaced on this PR because CI only
runs on pull requests, not on direct pushes to main. Mechanical fix
from `biome check --write` — no behavior change.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ypecheck

Pre-existing typecheck errors in blog/ surfaced on CI because the workflow
only runs on pull requests, not pushes to main. Three classes of fix:

- Add explicit `vitest` imports (`describe`/`it`/`expect`/`beforeEach`) to
  every `blog/__tests__/*.test.ts` — matches the convention used by all
  other test files in the repo.
- Replace `blogPosts.toSorted(...)` with `[...blogPosts].sort(...)` in
  `blog/core/handlePosts.ts` — same non-destructive semantics, doesn't
  require bumping the tsconfig `lib` to ES2023.
- Tighten the `ResolveSecretFn` stub in `mod.test.ts` to return `null`
  instead of `undefined` to satisfy `Promise<string | null>`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@nicacioliveira nicacioliveira requested a review from igoramf June 11, 2026 17:16
@nicacioliveira nicacioliveira merged commit b009ca7 into main Jun 11, 2026
2 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 5.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants