@glasstrace/sdk 1.3.2 → 1.3.4
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/README.md +126 -0
- package/dist/{chunk-REEU6CNO.js → chunk-3HWBR7XM.js} +3 -3
- package/dist/chunk-3HWBR7XM.js.map +1 -0
- package/dist/{chunk-XS3BO7RY.js → chunk-BQKPRFLF.js} +3 -3
- package/dist/{chunk-GCFOY7T2.js → chunk-E62DL2H4.js} +3 -3
- package/dist/{chunk-UFZEISZB.js → chunk-LQKJ27LO.js} +2 -2
- package/dist/chunk-LQKJ27LO.js.map +1 -0
- package/dist/{chunk-MQHLWSIX.js → chunk-M4ZI7J3N.js} +100 -62
- package/dist/{chunk-MQHLWSIX.js.map → chunk-M4ZI7J3N.js.map} +1 -1
- package/dist/{chunk-JFR42QG5.js → chunk-QJVAKVQJ.js} +2 -2
- package/dist/{chunk-CRM3EYOL.js → chunk-WKOQJCFN.js} +2 -2
- package/dist/{chunk-DQGNUENK.js → chunk-XFNK4YEW.js} +58 -16
- package/dist/chunk-XFNK4YEW.js.map +1 -0
- package/dist/{chunk-3TU62WD6.js → chunk-YG3X7TUI.js} +1 -1
- package/dist/chunk-YG3X7TUI.js.map +1 -0
- package/dist/cli/init.cjs +51 -13
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.js +6 -6
- package/dist/cli/mcp-add.cjs +49 -11
- package/dist/cli/mcp-add.cjs.map +1 -1
- package/dist/cli/mcp-add.js +2 -2
- package/dist/cli/uninit.cjs.map +1 -1
- package/dist/cli/uninit.js +3 -3
- package/dist/cli/validate.cjs +49 -11
- package/dist/cli/validate.cjs.map +1 -1
- package/dist/cli/validate.js +2 -2
- package/dist/edge-entry.cjs +88 -50
- package/dist/edge-entry.cjs.map +1 -1
- package/dist/edge-entry.js +2 -2
- package/dist/index.cjs +151 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +6 -6
- package/dist/node-entry.cjs +151 -70
- package/dist/node-entry.cjs.map +1 -1
- package/dist/node-entry.js +8 -8
- package/dist/node-subpath.cjs +49 -11
- package/dist/node-subpath.cjs.map +1 -1
- package/dist/node-subpath.js +4 -4
- package/dist/{source-map-uploader-LACAGKIW.js → source-map-uploader-JAD3XM4F.js} +4 -4
- package/package.json +1 -1
- package/dist/chunk-3TU62WD6.js.map +0 -1
- package/dist/chunk-DQGNUENK.js.map +0 -1
- package/dist/chunk-REEU6CNO.js.map +0 -1
- package/dist/chunk-UFZEISZB.js.map +0 -1
- /package/dist/{chunk-XS3BO7RY.js.map → chunk-BQKPRFLF.js.map} +0 -0
- /package/dist/{chunk-GCFOY7T2.js.map → chunk-E62DL2H4.js.map} +0 -0
- /package/dist/{chunk-JFR42QG5.js.map → chunk-QJVAKVQJ.js.map} +0 -0
- /package/dist/{chunk-CRM3EYOL.js.map → chunk-WKOQJCFN.js.map} +0 -0
- /package/dist/{source-map-uploader-LACAGKIW.js.map → source-map-uploader-JAD3XM4F.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createBuildHash
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-M4ZI7J3N.js";
|
|
4
4
|
|
|
5
5
|
// src/import-graph.ts
|
|
6
6
|
import * as fs from "node:fs/promises";
|
|
@@ -175,4 +175,4 @@ export {
|
|
|
175
175
|
extractImports,
|
|
176
176
|
buildImportGraph
|
|
177
177
|
};
|
|
178
|
-
//# sourceMappingURL=chunk-
|
|
178
|
+
//# sourceMappingURL=chunk-QJVAKVQJ.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-DQ25VOKK.js";
|
|
4
4
|
import {
|
|
5
5
|
GLASSTRACE_ATTRIBUTE_NAMES
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-M4ZI7J3N.js";
|
|
7
7
|
|
|
8
8
|
// src/errors.ts
|
|
9
9
|
var SdkError = class extends Error {
|
|
@@ -102,4 +102,4 @@ export {
|
|
|
102
102
|
GlasstraceSpanProcessor,
|
|
103
103
|
captureCorrelationId
|
|
104
104
|
};
|
|
105
|
-
//# sourceMappingURL=chunk-
|
|
105
|
+
//# sourceMappingURL=chunk-WKOQJCFN.js.map
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
maybeShowMcpNudge,
|
|
21
21
|
maybeShowServerActionNudge,
|
|
22
22
|
sdkLog
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-YG3X7TUI.js";
|
|
24
24
|
import {
|
|
25
25
|
_setCurrentConfig,
|
|
26
26
|
collectHealthReport,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
performInit,
|
|
34
34
|
recordSpansDropped,
|
|
35
35
|
recordSpansExported
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-3HWBR7XM.js";
|
|
37
37
|
import {
|
|
38
38
|
isAnonymousMode,
|
|
39
39
|
isProductionDisabled,
|
|
@@ -44,11 +44,11 @@ import {
|
|
|
44
44
|
getOrCreateAnonKey,
|
|
45
45
|
isSyncFsAvailable,
|
|
46
46
|
readAnonKey
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-LQKJ27LO.js";
|
|
48
48
|
import {
|
|
49
49
|
GLASSTRACE_ATTRIBUTE_NAMES,
|
|
50
50
|
deriveSessionId
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-M4ZI7J3N.js";
|
|
52
52
|
import {
|
|
53
53
|
__require
|
|
54
54
|
} from "./chunk-NSBPE2FW.js";
|
|
@@ -267,14 +267,30 @@ function prepareErrorResponseBody(body) {
|
|
|
267
267
|
|
|
268
268
|
// src/build-info.ts
|
|
269
269
|
var UNSET = "";
|
|
270
|
+
var SHA_SHAPE = /^[0-9a-f]{7,64}$/i;
|
|
271
|
+
function redactBuildHash(value) {
|
|
272
|
+
const sanitize = (s) => s.replace(/[\x00-\x1F\x7F]/g, "?");
|
|
273
|
+
if (value.length <= 12) return sanitize(value.slice(0, 4)) + "...";
|
|
274
|
+
return sanitize(value.slice(0, 8)) + "..." + sanitize(value.slice(-4));
|
|
275
|
+
}
|
|
270
276
|
function readBuildHashFromEnv() {
|
|
271
277
|
const raw = process.env.GLASSTRACE_BUILD_HASH;
|
|
272
278
|
if (typeof raw !== "string") return UNSET;
|
|
273
279
|
const trimmed = raw.trim();
|
|
274
|
-
|
|
280
|
+
if (trimmed.length === 0) return UNSET;
|
|
281
|
+
if (!SHA_SHAPE.test(trimmed)) {
|
|
282
|
+
sdkLog(
|
|
283
|
+
"warn",
|
|
284
|
+
`[glasstrace] warning: GLASSTRACE_BUILD_HASH=${redactBuildHash(trimmed)} does not match expected SHA shape (7-64 hex characters); source-map enrichment may not work as expected.`
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
return trimmed;
|
|
275
288
|
}
|
|
276
|
-
var cachedBuildHash =
|
|
289
|
+
var cachedBuildHash = null;
|
|
277
290
|
function getBuildHash() {
|
|
291
|
+
if (cachedBuildHash === null) {
|
|
292
|
+
cachedBuildHash = readBuildHashFromEnv();
|
|
293
|
+
}
|
|
278
294
|
return cachedBuildHash === UNSET ? void 0 : cachedBuildHash;
|
|
279
295
|
}
|
|
280
296
|
|
|
@@ -3747,11 +3763,27 @@ async function runCoexistencePath(existingProvider, config) {
|
|
|
3747
3763
|
setOtelState(OtelState.COEXISTENCE_FAILED);
|
|
3748
3764
|
emitLifecycleEvent("otel:configured", { state: OtelState.COEXISTENCE_FAILED, scenario: "C/F" });
|
|
3749
3765
|
emitLifecycleEvent("otel:injection_failed", { reason: "provider internals inaccessible" });
|
|
3766
|
+
emitLifecycleEvent("otel:failed", {
|
|
3767
|
+
category: "auto-attach-returned-null",
|
|
3768
|
+
message: "tryAutoAttachGlasstraceProcessor returned null \u2014 the existing OTel TracerProvider exposed no injection point. Spans are not reaching the Glasstrace exporter. Apply the manual createGlasstraceSpanProcessor() workaround documented in the SDK README.",
|
|
3769
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3770
|
+
providerClass: readProviderClass(existingProvider)
|
|
3771
|
+
});
|
|
3750
3772
|
const coreState = getCoreState();
|
|
3751
3773
|
if (coreState === CoreState.ACTIVE || coreState === CoreState.KEY_RESOLVED) {
|
|
3752
3774
|
setCoreState(CoreState.ACTIVE_DEGRADED);
|
|
3753
3775
|
}
|
|
3754
3776
|
}
|
|
3777
|
+
function readProviderClass(tracerProvider) {
|
|
3778
|
+
try {
|
|
3779
|
+
const proxy = tracerProvider;
|
|
3780
|
+
const delegate = typeof proxy.getDelegate === "function" ? proxy.getDelegate() : tracerProvider;
|
|
3781
|
+
const name = delegate?.constructor?.name;
|
|
3782
|
+
return typeof name === "string" && name.length > 0 ? name : void 0;
|
|
3783
|
+
} catch {
|
|
3784
|
+
return void 0;
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3755
3787
|
async function runRegistrationPath(config, sessionManager) {
|
|
3756
3788
|
const exporterUrl = `${config.endpoint}/v1/traces`;
|
|
3757
3789
|
const createOtlpExporter = (url, headers) => new OTLPTraceExporter({ url, headers });
|
|
@@ -4136,6 +4168,7 @@ import { join } from "node:path";
|
|
|
4136
4168
|
var _projectRoot = null;
|
|
4137
4169
|
var _sdkVersion = "unknown";
|
|
4138
4170
|
var _lastScenario;
|
|
4171
|
+
var _lastError;
|
|
4139
4172
|
var _debounceTimer = null;
|
|
4140
4173
|
var _started = false;
|
|
4141
4174
|
function startRuntimeStateWriter(options) {
|
|
@@ -4158,6 +4191,10 @@ function startRuntimeStateWriter(options) {
|
|
|
4158
4191
|
_lastScenario = scenario;
|
|
4159
4192
|
debouncedWrite();
|
|
4160
4193
|
});
|
|
4194
|
+
onLifecycleEvent("otel:failed", (payload) => {
|
|
4195
|
+
_lastError = { ...payload };
|
|
4196
|
+
debouncedWrite();
|
|
4197
|
+
});
|
|
4161
4198
|
onLifecycleEvent("auth:key_resolved", () => debouncedWrite());
|
|
4162
4199
|
onLifecycleEvent("auth:claim_started", () => debouncedWrite());
|
|
4163
4200
|
onLifecycleEvent("auth:claim_completed", () => debouncedWrite());
|
|
@@ -4185,6 +4222,9 @@ function writeStateNow() {
|
|
|
4185
4222
|
auth: { state: state.auth },
|
|
4186
4223
|
otel: { state: state.otel, scenario: _lastScenario }
|
|
4187
4224
|
};
|
|
4225
|
+
if (_lastError) {
|
|
4226
|
+
runtimeState.lastError = _lastError;
|
|
4227
|
+
}
|
|
4188
4228
|
const dir = join(_projectRoot, ".glasstrace");
|
|
4189
4229
|
const filePath = join(dir, "runtime-state.json");
|
|
4190
4230
|
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
@@ -4229,7 +4269,7 @@ function registerGlasstrace(options) {
|
|
|
4229
4269
|
setCoreState(CoreState.REGISTERING);
|
|
4230
4270
|
startRuntimeStateWriter({
|
|
4231
4271
|
projectRoot: process.cwd(),
|
|
4232
|
-
sdkVersion: "1.3.
|
|
4272
|
+
sdkVersion: "1.3.4"
|
|
4233
4273
|
});
|
|
4234
4274
|
const config = resolveConfig(options);
|
|
4235
4275
|
if (config.verbose) {
|
|
@@ -4395,8 +4435,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
|
|
|
4395
4435
|
if (config.verbose) {
|
|
4396
4436
|
console.info("[glasstrace] Background init firing.");
|
|
4397
4437
|
}
|
|
4398
|
-
const healthReport = collectHealthReport("1.3.
|
|
4399
|
-
const initResult = await performInit(config, anonKeyForInit, "1.3.
|
|
4438
|
+
const healthReport = collectHealthReport("1.3.4");
|
|
4439
|
+
const initResult = await performInit(config, anonKeyForInit, "1.3.4", healthReport);
|
|
4400
4440
|
if (generation !== registrationGeneration) return;
|
|
4401
4441
|
const currentState = getCoreState();
|
|
4402
4442
|
if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
|
|
@@ -4419,7 +4459,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
|
|
|
4419
4459
|
}
|
|
4420
4460
|
maybeInstallConsoleCapture();
|
|
4421
4461
|
if (didLastInitSucceed()) {
|
|
4422
|
-
startHeartbeat(config, anonKeyForInit, "1.3.
|
|
4462
|
+
startHeartbeat(config, anonKeyForInit, "1.3.4", generation, (newApiKey, accountId) => {
|
|
4423
4463
|
setAuthState(AuthState.CLAIMING);
|
|
4424
4464
|
emitLifecycleEvent("auth:claim_started", { accountId });
|
|
4425
4465
|
setResolvedApiKey(newApiKey);
|
|
@@ -4556,9 +4596,11 @@ This message will not appear once Glasstrace is added to your provider config.`
|
|
|
4556
4596
|
}
|
|
4557
4597
|
function emitGuidanceMessage() {
|
|
4558
4598
|
const isSentry = detectSentry();
|
|
4599
|
+
const isProduction = typeof process !== "undefined" && process.env?.NODE_ENV === "production";
|
|
4600
|
+
const level = isProduction ? "error" : "warn";
|
|
4559
4601
|
if (isSentry) {
|
|
4560
4602
|
sdkLog(
|
|
4561
|
-
|
|
4603
|
+
level,
|
|
4562
4604
|
`[glasstrace] An existing OTel TracerProvider is registered but Glasstrace could not auto-attach its span processor.
|
|
4563
4605
|
Add Glasstrace to your Sentry config:
|
|
4564
4606
|
|
|
@@ -4571,7 +4613,7 @@ Add Glasstrace to your Sentry config:
|
|
|
4571
4613
|
);
|
|
4572
4614
|
} else {
|
|
4573
4615
|
sdkLog(
|
|
4574
|
-
|
|
4616
|
+
level,
|
|
4575
4617
|
`[glasstrace] An existing OTel TracerProvider is registered but Glasstrace could not auto-attach its span processor.
|
|
4576
4618
|
Add Glasstrace to your provider configuration:
|
|
4577
4619
|
|
|
@@ -4714,7 +4756,7 @@ async function handleSourceMapUpload(distDir) {
|
|
|
4714
4756
|
);
|
|
4715
4757
|
return;
|
|
4716
4758
|
}
|
|
4717
|
-
const { discoverSourceMapFiles, computeBuildHash, uploadSourceMaps } = await import("./source-map-uploader-
|
|
4759
|
+
const { discoverSourceMapFiles, computeBuildHash, uploadSourceMaps } = await import("./source-map-uploader-JAD3XM4F.js");
|
|
4718
4760
|
const files = await discoverSourceMapFiles(distDir);
|
|
4719
4761
|
if (files.length === 0) {
|
|
4720
4762
|
console.info("[glasstrace] No source map files found. Skipping upload.");
|
|
@@ -4734,8 +4776,8 @@ async function handleSourceMapUpload(distDir) {
|
|
|
4734
4776
|
}
|
|
4735
4777
|
|
|
4736
4778
|
// src/stack-frame.ts
|
|
4737
|
-
var PAREN_FRAME = /^\s*at\s+(?:[^()]+\s+)?\(([^()\s]+):(\d+):(\d+)\)\s*$/;
|
|
4738
|
-
var BARE_FRAME = /^\s*at\s+(?:async\s+)?([^()\s]+):(\d+):(\d+)\s*$/;
|
|
4779
|
+
var PAREN_FRAME = /^\s*at\s+(?!eval\s+\(eval\s+at\b)(?:[^()]+\s+)?\(([^()\s]+(?:\([A-Za-z0-9_.-]+\)[^()\s]*)*):(\d+):(\d+)\)\s*$/;
|
|
4780
|
+
var BARE_FRAME = /^\s*at\s+(?:async\s+)?([^()\s]+(?:\([A-Za-z0-9_.-]+\)[^()\s]*)*):(\d+):(\d+)\s*$/;
|
|
4739
4781
|
var INTERNAL_FRAME_PATTERNS = [
|
|
4740
4782
|
/^node:/,
|
|
4741
4783
|
/^node:internal\//,
|
|
@@ -4817,4 +4859,4 @@ export {
|
|
|
4817
4859
|
withGlasstraceConfig,
|
|
4818
4860
|
captureError
|
|
4819
4861
|
};
|
|
4820
|
-
//# sourceMappingURL=chunk-
|
|
4862
|
+
//# sourceMappingURL=chunk-XFNK4YEW.js.map
|