@decocms/start 4.3.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,19 @@
1
1
  /**
2
2
  * URL-based head sampler — port of `deco-cx/deco/observability/otel/samplers/urlBased.ts`.
3
3
  *
4
- * Lets ops dial sampling rates per URL pattern without redeploying. Reads
5
- * `OTEL_SAMPLING_CONFIG` (base64-encoded JSON) at boot and decides each
6
- * trace's sample rate based on the matching pattern.
4
+ * **No longer wired into `instrumentWorker` by default.** As of 4.4.0 the
5
+ * recommended path for trace sampling is Cloudflare's wrangler-level
6
+ * `observability.traces.head_sampling_rate`, which is one global rate per
7
+ * Worker. This module stays as an opt-in escape hatch for sites that need
8
+ * URL-pattern-aware sampling (e.g. always trace `/checkout`, sample
9
+ * homepages at 1%) — those sites must wire OTel themselves outside the
10
+ * default `instrumentWorker` flow.
11
+ *
12
+ * The sampler reads `OTEL_SAMPLING_CONFIG` (base64-encoded JSON) and
13
+ * decides each trace's sample rate based on the matching pattern.
7
14
  *
8
15
  * Wrapped in `ParentBasedSampler` so a span inherits its parent's sampling
9
- * decision when one exists (i.e. distributed traces are kept consistent end
16
+ * decision when one exists (i.e. distributed traces stay consistent end
10
17
  * to end).
11
18
  *
12
19
  * **Default ratio.** When no `default` is provided in the config (or the env
@@ -28,6 +35,9 @@
28
35
  * ]
29
36
  * }
30
37
  * ```
38
+ *
39
+ * @deprecated Slated for removal in 5.0.0 unless a site declares an active
40
+ * need. Use Cloudflare's `head_sampling_rate` first.
31
41
  */
32
42
 
33
43
  import { type Attributes, type Context, type Link, type SpanKind, trace } from "@opentelemetry/api";
@@ -189,7 +199,9 @@ export function decodeSamplingConfig(raw: string | undefined): SamplingConfig |
189
199
 
190
200
  /**
191
201
  * Build a `ParentBasedSampler` rooted at our URL-based sampler.
192
- * Use as the `headSampler` for `@microlabs/otel-cf-workers`.
202
+ * Wire as the `headSampler` for any custom OTel SDK setup (e.g. a site
203
+ * that opts back into `@microlabs/otel-cf-workers` outside the default
204
+ * `instrumentWorker` flow).
193
205
  */
194
206
  export function createUrlBasedHeadSampler(config: SamplingConfig | null): Sampler {
195
207
  const root = new URLBasedSampler(config ?? {});
@@ -949,10 +949,13 @@ export function createDecoWorkerEntry(
949
949
  // via getRuntimeEnv() in sdk/otelAdapters.ts.
950
950
  setRuntimeEnv(env);
951
951
 
952
- // Wrap inner handler in a single root span. `@microlabs/otel-cf-workers`
953
- // already creates an outer span via its `instrument()` wrapper; this
954
- // adds a nested span carrying our normalized path/status attributes
955
- // that microlabs doesn't capture (it uses url.path verbatim).
952
+ // Wrap inner handler in a single root span carrying our normalized
953
+ // path/method attributes. With Cloudflare-managed trace export
954
+ // (`observability.traces.destinations` in wrangler.jsonc), this
955
+ // span and any `withTracing` spans nested below it flow to
956
+ // HyperDX via CF's platform-managed OTLP push, since the bridge
957
+ // in `instrumentWorker` configures the `@opentelemetry/api`
958
+ // global tracer for us.
956
959
  return withTracing(
957
960
  "deco.http.request",
958
961
  async () => {