Skip to content

Commit 7daded1

Browse files
hugo-ccabralhugo-ccabralclaude
authored
chore: pin @decocms/start to fast-deploy test commit (#32)
* chore: pin @decocms/start to fast-deploy test commit Pin @decocms/start to github:decocms/deco-start#49140ce to test the fast deploy on TanStack with the fix from the last PR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: sync bun.lock to pinned @decocms/start commit CF Workers build uses bun --frozen-lockfile; bun.lock still pointed at 6.12.0, causing the frozen-lockfile failure. Regenerated with bun install. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(fast-deploy): add DECO_KV binding + DECO_FAST_DEPLOY, align worker name Wires the worker for KV-first content (fast deploy): - name: storefront-tanstack-template -> storefront-tanstack (match the deployed service + DECO_SITE_NAME) - add kv_namespaces DECO_KV binding (placeholder id — replace with the real namespace id from `wrangler kv namespace create DECO_KV`) - add DECO_FAST_DEPLOY="1" var (inert until the binding has a real id) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(fast-deploy): finalize DECO_KV binding + enable flag, align name - name -> storefront-tanstack (match deployed service + DECO_SITE_NAME) - DECO_KV bound to real namespace id a205a78ee28c44c3910cf52a3482a65f - add DECO_FAST_DEPLOY=1 (both flag + binding required to activate) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(otel): switch endpoints to otel-worker.deco.cx + manual instrument wrap Mirrors deco-sites/casaevideo-tanstack@00314c9 (env vars + worker-entry), adapted to storefront (no AB-testing layer): - vars: OTel metrics/logs -> https://otel-worker.deco.cx; add traces endpoint + DECO_OTEL_TRACES_SAMPLING_RATE=0.01 - worker-entry: observability:false to opt out of the framework auto-wrap; manual instrumentWorker(decoWorker) as the outermost export - NOT bumping @decocms/start (kept pinned to the fast-deploy commit) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: hugo-ccabral <hugo@deco.cx> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 14c85a7 commit 7daded1

5 files changed

Lines changed: 152 additions & 119 deletions

File tree

bun.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"license": "MIT",
3131
"dependencies": {
3232
"@decocms/apps": "^5.2.0",
33-
"@decocms/start": "6.12.0",
33+
"@decocms/start": "github:decocms/deco-start#49140ce24363926a7bd1df106f03c87ecfc7b1dc",
3434
"@tanstack/react-query": "5.90.21",
3535
"@tanstack/react-router": "1.166.7",
3636
"@tanstack/react-start": "1.166.8",

src/worker-entry.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import "./setup";
1212
import handler, { createServerEntry } from "@tanstack/react-start/server-entry";
1313
import { createDecoWorkerEntry } from "@decocms/start/sdk/workerEntry";
14+
import { instrumentWorker } from "@decocms/start/sdk/otel";
1415
import { detectDevice } from "@decocms/start/sdk/useDevice";
1516
import {
1617
handleMeta,
@@ -34,6 +35,14 @@ const CSP_DIRECTIVES = [
3435
];
3536

3637
const decoWorker = createDecoWorkerEntry(serverEntry, {
38+
// Opt out of the auto-wrap the framework (6.6.0+) applies inside
39+
// createDecoWorkerEntry. We keep the manual `instrumentWorker(decoWorker)`
40+
// wrap at the bottom of this file as the outermost layer. Without
41+
// `observability: false` we'd double-wrap and reinitialize the OTel SDK
42+
// twice per request. Manual wrap is the proven path on every tanstack site
43+
// that emits today.
44+
observability: false,
45+
3746
admin: {
3847
handleMeta,
3948
handleDecofileRead,
@@ -71,4 +80,6 @@ const decoWorker = createDecoWorkerEntry(serverEntry, {
7180
// proxyHandler unset keeps all routes going through TanStack Start.
7281
});
7382

74-
export default decoWorker;
83+
// instrumentWorker MUST be the outermost wrapper — it initialises the OTel SDK
84+
// and flushes telemetry via ctx.waitUntil after each request.
85+
export default instrumentWorker(decoWorker);

wrangler.jsonc

Lines changed: 130 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,131 @@
11
{
2-
"name": "storefront-tanstack-template",
3-
"account_id": "c95fc4cec7fc52453228d9db170c372c",
4-
"compatibility_date": "2026-02-14",
5-
"compatibility_flags": ["nodejs_compat", "no_handle_cross_request_promise_resolution"],
6-
"main": "./src/worker-entry.ts",
7-
"workers_dev": true,
8-
"preview_urls": true,
9-
// Uncomment for redirect/AB testing support via KV:
10-
// "kv_namespaces": [
11-
// { "binding": "SITES_KV", "id": "YOUR_KV_NAMESPACE_ID" }
12-
// ],
13-
// Strategy B tail worker — 100% capture of producer errors that the
14-
// framework's direct-POST channel can't see (uncaught throws, exceededCpu,
15-
// exceededMemory, raw console.error). Invoked by CF on every request to
16-
// this worker; filters and forwards to deco-otel-ingest via in-account
17-
// service binding. See the observability block below for the full
18-
// three-channel model.
19-
"tail_consumers": [
20-
{ "service": "deco-otel-tail" }
21-
],
22-
// Worker version (build SHA / deployment id) — surfaced as
23-
// `service.version` on every span / log line by `instrumentWorker`.
24-
"version_metadata": {
25-
"binding": "CF_VERSION_METADATA"
26-
},
27-
// Cloudflare Analytics Engine dataset for high-cardinality counters
28-
// (per-route request counts, cache hit/miss, request duration).
29-
// Queryable via SQL from the CF dashboard. Replace YOUR_SITE_NAME with
30-
// the actual site slug (must match DECO_SITE_NAME below).
31-
// "analytics_engine_datasets": [
32-
// {
33-
// "binding": "DECO_METRICS",
34-
// "dataset": "deco_metrics_YOUR_SITE_NAME"
35-
// }
36-
// ],
37-
// Observability — three-channel model (Strategy B, see decocms/deco-start D-8).
38-
//
39-
// Identity:
40-
// `DECO_SITE_NAME` drives `service.name` on every span and log line.
41-
// `DECO_ENV_NAME` drives `deployment.environment`.
42-
//
43-
// Three channels, each owning a different slice of the observability cube:
44-
//
45-
// 1. CF Destinations (`observability.{logs,traces}.destinations` below)
46-
// Sampled 1% logs + 1% traces. Bulk volume.
47-
// 2. Direct-POST in-worker (`DECO_OTEL_*_ENDPOINT`, resolved at
48-
// `instrumentWorker` boot)
49-
// - METRICS_ENDPOINT → direct POST `/v1/metrics` (CF Destinations
50-
// doesn't support OTLP metrics). Buffered per-isolate, flushed
51-
// via `ctx.waitUntil` after every request.
52-
// - LOGS_ENDPOINT → direct POST `/v1/logs` for framework
53-
// `logger.error(...)` only (100% capture, rate-limited).
54-
// 3. Tail Worker (`tail_consumers` above → deco-otel-tail)
55-
// Catches uncaught throws, exceededCpu/Memory, raw console.error —
56-
// what direct-POST can't see and CF Destinations would sample away.
57-
//
58-
// Coverage matrix:
59-
// framework logger.error → direct-POST (100%, rate-limited)
60-
// framework span errors → CF Destinations + tail (1% sampled + 100%)
61-
// uncaught throws → tail worker (100%)
62-
// exceededCpu / exceededMemory → tail worker (100%)
63-
// raw console.error → tail worker (100%)
64-
// console.log / console.warn → CF Destinations (1% sampled)
65-
// OTel spans → CF Destinations (1% sampled)
66-
// OTel metrics → direct-POST (100%, buffered)
67-
"vars": {
68-
"DECO_SITE_NAME": "storefront-tanstack",
69-
"DECO_ENV_NAME": "production",
70-
"DECO_OTEL_METRICS_ENDPOINT": "https://deco-otel-ingest.deco-cx.workers.dev/v1/metrics",
71-
"DECO_OTEL_LOGS_ENDPOINT": "https://deco-otel-ingest.deco-cx.workers.dev/v1/logs"
72-
},
73-
// CF-native observability: structured console.* output and auto-
74-
// instrumented traces (fetch/KV/R2/DO subrequests + @opentelemetry/api
75-
// global-tracer spans the framework's withTracing() emits) are
76-
// captured by the Cloudflare runtime, retained in the CF dashboard
77-
// via persist:true, AND forwarded to deco-otel-ingest →
78-
// stats-lake ClickHouse via the named destinations below.
79-
//
80-
// The named destinations are registered out-of-band in the CF
81-
// dashboard (Workers & Pages → Observability → Destinations) against
82-
// the deco-cx account. Wrangler resolves these names to the URLs +
83-
// any auth headers configured there.
84-
"observability": {
85-
// Master switch — without enabled:true at the top level CF
86-
// captures nothing, regardless of the sub-block flags.
87-
"enabled": true,
88-
"logs": {
89-
"enabled": true,
90-
"invocation_logs": true,
91-
// 1% of info/warn logs forward to deco-otel-ingest. Errors are
92-
// NOT subject to this rate — they're covered by both the
93-
// direct-POST channel (framework logger.error) and the tail
94-
// worker (uncaught throws, exceededCpu, raw console.error).
95-
"head_sampling_rate": 0.01,
96-
"persist": true,
97-
"destinations": ["deco-otel-ingest-logs"]
98-
},
99-
"traces": {
100-
"enabled": true,
101-
// Fleet-scale cost discipline — see `@decocms/start`
102-
// docs/observability.md "Sampling" section. 1% gives 2.5x
103-
// headroom against the 5B-events/day CF cap at projected
104-
// fleet traffic.
105-
"head_sampling_rate": 0.01,
106-
"persist": true,
107-
"destinations": ["deco-otel-ingest-traces"]
108-
}
109-
}
110-
}
2+
"name": "storefront-tanstack",
3+
"account_id": "c95fc4cec7fc52453228d9db170c372c",
4+
"compatibility_date": "2026-02-14",
5+
"compatibility_flags": [
6+
"nodejs_compat",
7+
"no_handle_cross_request_promise_resolution"
8+
],
9+
"main": "./src/worker-entry.ts",
10+
"workers_dev": true,
11+
"preview_urls": true,
12+
// Uncomment for redirect/AB testing support via KV:
13+
// "kv_namespaces": [
14+
// { "binding": "SITES_KV", "id": "YOUR_KV_NAMESPACE_ID" }
15+
// ],
16+
// Strategy B tail worker — 100% capture of producer errors that the
17+
// framework's direct-POST channel can't see (uncaught throws, exceededCpu,
18+
// exceededMemory, raw console.error). Invoked by CF on every request to
19+
// this worker; filters and forwards to deco-otel-ingest via in-account
20+
// service binding. See the observability block below for the full
21+
// three-channel model.
22+
"tail_consumers": [
23+
{
24+
"service": "deco-otel-tail"
25+
}
26+
],
27+
// Worker version (build SHA / deployment id) — surfaced as
28+
// `service.version` on every span / log line by `instrumentWorker`.
29+
"version_metadata": {
30+
"binding": "CF_VERSION_METADATA"
31+
},
32+
// Cloudflare Analytics Engine dataset for high-cardinality counters
33+
// (per-route request counts, cache hit/miss, request duration).
34+
// Queryable via SQL from the CF dashboard. Replace YOUR_SITE_NAME with
35+
// the actual site slug (must match DECO_SITE_NAME below).
36+
// "analytics_engine_datasets": [
37+
// {
38+
// "binding": "DECO_METRICS",
39+
// "dataset": "deco_metrics_YOUR_SITE_NAME"
40+
// }
41+
// ],
42+
// Observability — three-channel model (Strategy B, see decocms/deco-start D-8).
43+
//
44+
// Identity:
45+
// `DECO_SITE_NAME` drives `service.name` on every span and log line.
46+
// `DECO_ENV_NAME` drives `deployment.environment`.
47+
//
48+
// Three channels, each owning a different slice of the observability cube:
49+
//
50+
// 1. CF Destinations (`observability.{logs,traces}.destinations` below)
51+
// Sampled 1% logs + 1% traces. Bulk volume.
52+
// 2. Direct-POST in-worker (`DECO_OTEL_*_ENDPOINT`, resolved at
53+
// `instrumentWorker` boot)
54+
// - METRICS_ENDPOINT → direct POST `/v1/metrics` (CF Destinations
55+
// doesn't support OTLP metrics). Buffered per-isolate, flushed
56+
// via `ctx.waitUntil` after every request.
57+
// - LOGS_ENDPOINT → direct POST `/v1/logs` for framework
58+
// `logger.error(...)` only (100% capture, rate-limited).
59+
// 3. Tail Worker (`tail_consumers` above → deco-otel-tail)
60+
// Catches uncaught throws, exceededCpu/Memory, raw console.error —
61+
// what direct-POST can't see and CF Destinations would sample away.
62+
//
63+
// Coverage matrix:
64+
// framework logger.error → direct-POST (100%, rate-limited)
65+
// framework span errors → CF Destinations + tail (1% sampled + 100%)
66+
// uncaught throws → tail worker (100%)
67+
// exceededCpu / exceededMemory → tail worker (100%)
68+
// raw console.error → tail worker (100%)
69+
// console.log / console.warn → CF Destinations (1% sampled)
70+
// OTel spans → CF Destinations (1% sampled)
71+
// OTel metrics → direct-POST (100%, buffered)
72+
"vars": {
73+
"DECO_SITE_NAME": "storefront-tanstack",
74+
"DECO_ENV_NAME": "production",
75+
// Fast Deploy opt-in. Requires BOTH this flag AND the DECO_KV binding
76+
// below; inert if either is missing. Set to "0" to disable.
77+
"DECO_FAST_DEPLOY": "1",
78+
"DECO_OTEL_METRICS_ENDPOINT": "https://otel-worker.deco.cx/v1/metrics",
79+
"DECO_OTEL_LOGS_ENDPOINT": "https://otel-worker.deco.cx/v1/logs",
80+
"DECO_OTEL_TRACES_ENDPOINT": "https://otel-worker.deco.cx/v1/traces",
81+
"DECO_OTEL_TRACES_SAMPLING_RATE": "0.01"
82+
},
83+
// CF-native observability: structured console.* output and auto-
84+
// instrumented traces (fetch/KV/R2/DO subrequests + @opentelemetry/api
85+
// global-tracer spans the framework's withTracing() emits) are
86+
// captured by the Cloudflare runtime, retained in the CF dashboard
87+
// via persist:true, AND forwarded to deco-otel-ingest →
88+
// stats-lake ClickHouse via the named destinations below.
89+
//
90+
// The named destinations are registered out-of-band in the CF
91+
// dashboard (Workers & Pages → Observability → Destinations) against
92+
// the deco-cx account. Wrangler resolves these names to the URLs +
93+
// any auth headers configured there.
94+
"observability": {
95+
// Master switch — without enabled:true at the top level CF
96+
// captures nothing, regardless of the sub-block flags.
97+
"enabled": true,
98+
"logs": {
99+
"enabled": true,
100+
"invocation_logs": true,
101+
// 1% of info/warn logs forward to deco-otel-ingest. Errors are
102+
// NOT subject to this rate — they're covered by both the
103+
// direct-POST channel (framework logger.error) and the tail
104+
// worker (uncaught throws, exceededCpu, raw console.error).
105+
"head_sampling_rate": 0.01,
106+
"persist": true,
107+
"destinations": [
108+
"deco-otel-ingest-logs"
109+
]
110+
},
111+
"traces": {
112+
"enabled": true,
113+
// Fleet-scale cost discipline — see `@decocms/start`
114+
// docs/observability.md "Sampling" section. 1% gives 2.5x
115+
// headroom against the 5B-events/day CF cap at projected
116+
// fleet traffic.
117+
"head_sampling_rate": 0.01,
118+
"persist": true,
119+
"destinations": [
120+
"deco-otel-ingest-traces"
121+
]
122+
}
123+
},
124+
"kv_namespaces": [
125+
{
126+
"binding": "DECO_KV",
127+
"id": "a205a78ee28c44c3910cf52a3482a65f",
128+
"remote": true
129+
}
130+
]
131+
}

0 commit comments

Comments
 (0)