@decocms/blocks 7.16.1 → 7.16.3
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.
- package/package.json +1 -1
- package/src/sdk/otel.ts +9 -6
package/package.json
CHANGED
package/src/sdk/otel.ts
CHANGED
|
@@ -82,6 +82,7 @@ import {
|
|
|
82
82
|
ATTR_CLOUD_PROVIDER,
|
|
83
83
|
} from "@opentelemetry/semantic-conventions/incubating";
|
|
84
84
|
import { createCompositeLogger, createCompositeMeter } from "./composite";
|
|
85
|
+
import { isDevMode } from "./env";
|
|
85
86
|
import { configureLogger, defaultLoggerAdapter, logger, setLogLevel, setLoggerAttributeFloor, type LogLevel } from "./logger";
|
|
86
87
|
import { configureMeter, configureTracer, getActiveSpan, METRIC_METADATA } from "../middleware/observability";
|
|
87
88
|
import { createAnalyticsEngineMeterAdapter } from "./otelAdapters";
|
|
@@ -110,8 +111,9 @@ export interface OtelOptions {
|
|
|
110
111
|
* - `"off"` → force disable
|
|
111
112
|
* - unset → auto: enabled in real deploys, disabled in local
|
|
112
113
|
*
|
|
113
|
-
* Local is detected
|
|
114
|
-
*
|
|
114
|
+
* Local is detected via `isDevMode()` (reads
|
|
115
|
+
* `process.env.NODE_ENV === "development"`, which Vite and
|
|
116
|
+
* `@cloudflare/vite-plugin` set during `vite dev`).
|
|
115
117
|
*
|
|
116
118
|
* Defaults to `"DECO_OTEL"`.
|
|
117
119
|
*/
|
|
@@ -641,13 +643,14 @@ function bootObservability(opts: OtelOptions, env: Record<string, unknown>): voi
|
|
|
641
643
|
const state = getBootState();
|
|
642
644
|
if (state.booted) return;
|
|
643
645
|
|
|
644
|
-
//
|
|
645
|
-
//
|
|
646
|
+
// `isDevMode()` reads `process.env.NODE_ENV === "development"`. Vite and
|
|
647
|
+
// `@cloudflare/vite-plugin` set NODE_ENV during `vite dev`; `wrangler
|
|
648
|
+
// deploy` does not. `CF_VERSION_METADATA` is NOT a reliable local signal —
|
|
649
|
+
// wrangler dev populates it with a random per-session UUID.
|
|
646
650
|
const mode = env[opts.envVar ?? "DECO_OTEL"];
|
|
647
|
-
const isLocal = !env.CF_VERSION_METADATA;
|
|
648
651
|
const isDisabled =
|
|
649
652
|
mode === "off" ||
|
|
650
|
-
(mode !== "on" && (opts.disabled ||
|
|
653
|
+
(mode !== "on" && (opts.disabled || isDevMode()));
|
|
651
654
|
if (isDisabled) {
|
|
652
655
|
state.booted = true;
|
|
653
656
|
return;
|