feat: pass env into bs tracing

This commit is contained in:
nams1570
2026-07-05 21:47:44 -07:00
parent 675e8608af
commit e13f12a799
4 changed files with 11 additions and 2 deletions
+1
View File
@@ -3,6 +3,7 @@ HEXCLAVE_BULLDOZER_SERVER_SECRET=# shared secret callers (the backend) must pres
# Sentry
BULLDOZER_JS_SENTRY_DSN=# error-reporting DSN for the bulldozer-js process. Leave empty to turn Sentry off. Falls back to SENTRY_DSN if unset
BULLDOZER_JS_SENTRY_ENVIRONMENT=# Sentry environment label for THIS deployment (e.g. "production", "staging", "dev"). Lets prod vs dev bulldozer be separated in Sentry even when both run NODE_ENV=production.
# Storage
HEXCLAVE_BULLDOZER_JS_LMDB_PATH=# folder for the on-disk LMDB store. Defaults to ./.data/bulldozer-js-lmdb
+1
View File
@@ -3,6 +3,7 @@ HEXCLAVE_BULLDOZER_SERVER_SECRET=mock_bulldozer_server_secret
# Sentry
BULLDOZER_JS_SENTRY_DSN=
BULLDOZER_JS_SENTRY_ENVIRONMENT=development
# Storage
HEXCLAVE_BULLDOZER_JS_LMDB_PATH=.data/bulldozer-js-lmdb
+2 -1
View File
@@ -21,7 +21,7 @@ import "./load-env.js";
import { instrumentation, traceSpan } from "./otel.js";
import { createPaymentsSchema, itemQuantitiesLedgerUpperBoundAsOf } from "./payments/schema/index.js";
import type { CustomerType, Json, SubscriptionRow, TransactionRow } from "./payments/schema/types.js";
import { initSentry } from "./sentry.js";
import { initSentry, resolveBulldozerSentryEnvironment } from "./sentry.js";
const sentryEnabled = initSentry();
@@ -1035,6 +1035,7 @@ const startupFields = {
port: app.server?.port ?? port,
pid: process.pid,
nodeVersion: process.version,
sentryEnvironment: resolveBulldozerSentryEnvironment(),
lowLevelBackend: process.env.HEXCLAVE_BULLDOZER_JS_LOW_LEVEL_BACKEND ?? "lmdb",
usingTmpLmdb: process.env.HEXCLAVE_BULLDOZER_JS_USE_TMP_LMDB === "1",
disableHeapReadCache: process.env.HEXCLAVE_BULLDOZER_JS_DISABLE_PILEDRIVER_HEAP_READ_CACHE === "1",
+7 -1
View File
@@ -4,6 +4,12 @@ import { ignoreUnhandledRejection } from "@hexclave/shared/dist/utils/promises";
import { sentryBaseConfig } from "@hexclave/shared/dist/utils/sentry";
import { nicify } from "@hexclave/shared/dist/utils/strings";
export function resolveBulldozerSentryEnvironment(): string {
const configured = process.env.BULLDOZER_JS_SENTRY_ENVIRONMENT?.trim();
if (configured) return configured;
return process.env.NODE_ENV === "production" ? "production" : "development";
}
// Init Sentry for the bulldozer-js process and route `captureError`/`captureWarning` to it. No-ops
// without a DSN, in which case errors still hit the default console sink. Returns whether Sentry was
// actually configured, so the boot path can decide whether to emit the startup signal to Sentry
@@ -15,7 +21,7 @@ export function initSentry(): boolean {
Sentry.init({
...sentryBaseConfig,
dsn,
environment: process.env.NODE_ENV === "production" ? "production" : "development",
environment: resolveBulldozerSentryEnvironment(),
sendDefaultPii: false,
tracesSampleRate: 0,