@glasstrace/sdk 1.0.1 → 1.1.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.
- package/README.md +3 -2
- package/dist/{chunk-MV3F7HVX.js → chunk-ZBTC5QIQ.js} +45 -23
- package/dist/{chunk-MV3F7HVX.js.map → chunk-ZBTC5QIQ.js.map} +1 -1
- package/dist/cli/init.cjs +1 -1
- package/dist/cli/init.js +1 -1
- package/dist/index.cjs +134 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/node-entry.cjs +134 -111
- package/dist/node-entry.cjs.map +1 -1
- package/dist/node-entry.js +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -112,8 +112,9 @@ Glasstrace browser extension captures.
|
|
|
112
112
|
### Correlating a trace with browser extension data
|
|
113
113
|
|
|
114
114
|
To correlate a server-captured trace with extension-side action data,
|
|
115
|
-
call `captureCorrelationId` from a Next.js `middleware.ts` (or
|
|
116
|
-
custom server request hook that runs
|
|
115
|
+
call `captureCorrelationId` from a Next.js `middleware.ts` (or
|
|
116
|
+
`proxy.ts` on Next 16+, or any custom server request hook that runs
|
|
117
|
+
inside the request's OTel context):
|
|
117
118
|
|
|
118
119
|
```ts
|
|
119
120
|
// middleware.ts
|
|
@@ -1090,7 +1090,7 @@ function getStringFromEnv(key) {
|
|
|
1090
1090
|
}
|
|
1091
1091
|
|
|
1092
1092
|
// ../../node_modules/@opentelemetry/core/build/esm/version.js
|
|
1093
|
-
var VERSION = "2.
|
|
1093
|
+
var VERSION = "2.7.0";
|
|
1094
1094
|
|
|
1095
1095
|
// ../../node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js
|
|
1096
1096
|
var ATTR_EXCEPTION_MESSAGE = "exception.message";
|
|
@@ -1254,6 +1254,9 @@ function mergeTwoObjects(one, two, level = 0, objects) {
|
|
|
1254
1254
|
const keys = Object.keys(two);
|
|
1255
1255
|
for (let i = 0, j = keys.length; i < j; i++) {
|
|
1256
1256
|
const key = keys[i];
|
|
1257
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1257
1260
|
result[key] = takeValue(two[key]);
|
|
1258
1261
|
}
|
|
1259
1262
|
}
|
|
@@ -1266,6 +1269,9 @@ function mergeTwoObjects(one, two, level = 0, objects) {
|
|
|
1266
1269
|
const keys = Object.keys(two);
|
|
1267
1270
|
for (let i = 0, j = keys.length; i < j; i++) {
|
|
1268
1271
|
const key = keys[i];
|
|
1272
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
1273
|
+
continue;
|
|
1274
|
+
}
|
|
1269
1275
|
const twoValue = two[key];
|
|
1270
1276
|
if (isPrimitive(twoValue)) {
|
|
1271
1277
|
if (typeof twoValue === "undefined") {
|
|
@@ -2326,7 +2332,7 @@ function samplingDecisionToString(decision) {
|
|
|
2326
2332
|
}
|
|
2327
2333
|
|
|
2328
2334
|
// ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/version.js
|
|
2329
|
-
var VERSION2 = "2.
|
|
2335
|
+
var VERSION2 = "2.7.0";
|
|
2330
2336
|
|
|
2331
2337
|
// ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js
|
|
2332
2338
|
var Tracer = class {
|
|
@@ -2972,7 +2978,12 @@ var JsonTraceSerializer = {
|
|
|
2972
2978
|
return {};
|
|
2973
2979
|
}
|
|
2974
2980
|
const decoder = new TextDecoder();
|
|
2975
|
-
|
|
2981
|
+
try {
|
|
2982
|
+
return JSON.parse(decoder.decode(arg));
|
|
2983
|
+
} catch (err) {
|
|
2984
|
+
diag.warn(`Failed to parse trace export response: ${err.message}. Returning empty response`);
|
|
2985
|
+
return {};
|
|
2986
|
+
}
|
|
2976
2987
|
}
|
|
2977
2988
|
};
|
|
2978
2989
|
|
|
@@ -3082,10 +3093,11 @@ function parseRetryAfterToMills(retryAfter) {
|
|
|
3082
3093
|
}
|
|
3083
3094
|
|
|
3084
3095
|
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.js
|
|
3085
|
-
var VERSION3 = "0.
|
|
3096
|
+
var VERSION3 = "0.215.0";
|
|
3086
3097
|
|
|
3087
3098
|
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js
|
|
3088
3099
|
var DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION3}`;
|
|
3100
|
+
var MAX_RESPONSE_BODY_SIZE = 4 * 1024 * 1024;
|
|
3089
3101
|
function sendWithHttp(request, url, headers, compression, userAgent, agent, data, timeoutMillis) {
|
|
3090
3102
|
return new Promise((resolve2) => {
|
|
3091
3103
|
const parsedUrl = new URL(url);
|
|
@@ -3104,7 +3116,17 @@ function sendWithHttp(request, url, headers, compression, userAgent, agent, data
|
|
|
3104
3116
|
};
|
|
3105
3117
|
const req = request(options, (res) => {
|
|
3106
3118
|
const responseData = [];
|
|
3107
|
-
|
|
3119
|
+
let responseSize = 0;
|
|
3120
|
+
res.on("data", (chunk) => {
|
|
3121
|
+
responseSize += chunk.length;
|
|
3122
|
+
if (responseSize > MAX_RESPONSE_BODY_SIZE) {
|
|
3123
|
+
const sizeError = new Error(`OTLP export response body exceeded size limit of ${MAX_RESPONSE_BODY_SIZE} bytes`);
|
|
3124
|
+
resolve2({ status: "failure", error: sizeError });
|
|
3125
|
+
res.destroy();
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3128
|
+
responseData.push(chunk);
|
|
3129
|
+
});
|
|
3108
3130
|
res.on("end", () => {
|
|
3109
3131
|
if (res.statusCode && res.statusCode <= 299) {
|
|
3110
3132
|
resolve2({
|
|
@@ -3482,24 +3504,24 @@ var OTLPTraceExporter = class extends OTLPExporterBase {
|
|
|
3482
3504
|
};
|
|
3483
3505
|
|
|
3484
3506
|
// src/otel-config.ts
|
|
3485
|
-
var
|
|
3486
|
-
var
|
|
3487
|
-
var
|
|
3488
|
-
var
|
|
3507
|
+
var resolvedApiKey = API_KEY_PENDING;
|
|
3508
|
+
var activeExporter = null;
|
|
3509
|
+
var additionalExporters = [];
|
|
3510
|
+
var injectedProcessor = null;
|
|
3489
3511
|
function setResolvedApiKey(key) {
|
|
3490
|
-
|
|
3512
|
+
resolvedApiKey = key;
|
|
3491
3513
|
}
|
|
3492
3514
|
function getResolvedApiKey() {
|
|
3493
|
-
return
|
|
3515
|
+
return resolvedApiKey;
|
|
3494
3516
|
}
|
|
3495
3517
|
function notifyApiKeyResolved() {
|
|
3496
|
-
|
|
3497
|
-
for (const exporter of
|
|
3518
|
+
activeExporter?.notifyKeyResolved();
|
|
3519
|
+
for (const exporter of additionalExporters) {
|
|
3498
3520
|
exporter.notifyKeyResolved();
|
|
3499
3521
|
}
|
|
3500
3522
|
}
|
|
3501
3523
|
function registerExporterForKeyNotification(exporter) {
|
|
3502
|
-
|
|
3524
|
+
additionalExporters.push(exporter);
|
|
3503
3525
|
}
|
|
3504
3526
|
async function tryImport(moduleId) {
|
|
3505
3527
|
try {
|
|
@@ -3542,7 +3564,7 @@ async function runCoexistencePath(existingProvider, config) {
|
|
|
3542
3564
|
return;
|
|
3543
3565
|
}
|
|
3544
3566
|
if (result !== null) {
|
|
3545
|
-
|
|
3567
|
+
injectedProcessor = result.processor;
|
|
3546
3568
|
if (config.verbose) {
|
|
3547
3569
|
sdkLog(
|
|
3548
3570
|
"info",
|
|
@@ -3553,8 +3575,8 @@ async function runCoexistencePath(existingProvider, config) {
|
|
|
3553
3575
|
name: "coexistence-flush",
|
|
3554
3576
|
priority: 5,
|
|
3555
3577
|
fn: async () => {
|
|
3556
|
-
if (
|
|
3557
|
-
await
|
|
3578
|
+
if (injectedProcessor) {
|
|
3579
|
+
await injectedProcessor.forceFlush();
|
|
3558
3580
|
}
|
|
3559
3581
|
}
|
|
3560
3582
|
});
|
|
@@ -3590,7 +3612,7 @@ async function runRegistrationPath(config, sessionManager) {
|
|
|
3590
3612
|
createDelegate: createOtlpExporter,
|
|
3591
3613
|
verbose: config.verbose
|
|
3592
3614
|
});
|
|
3593
|
-
|
|
3615
|
+
activeExporter = glasstraceExporter;
|
|
3594
3616
|
const vercelOtel = await tryImport("@vercel/otel");
|
|
3595
3617
|
if (vercelOtel && typeof vercelOtel.registerOTel === "function") {
|
|
3596
3618
|
const otelConfig = {
|
|
@@ -4005,7 +4027,7 @@ function registerGlasstrace(options) {
|
|
|
4005
4027
|
setCoreState(CoreState.REGISTERING);
|
|
4006
4028
|
startRuntimeStateWriter({
|
|
4007
4029
|
projectRoot: process.cwd(),
|
|
4008
|
-
sdkVersion: "1.0
|
|
4030
|
+
sdkVersion: "1.1.0"
|
|
4009
4031
|
});
|
|
4010
4032
|
const config = resolveConfig(options);
|
|
4011
4033
|
if (config.verbose) {
|
|
@@ -4171,8 +4193,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
|
|
|
4171
4193
|
if (config.verbose) {
|
|
4172
4194
|
console.info("[glasstrace] Background init firing.");
|
|
4173
4195
|
}
|
|
4174
|
-
const healthReport = collectHealthReport("1.0
|
|
4175
|
-
const initResult = await performInit(config, anonKeyForInit, "1.0
|
|
4196
|
+
const healthReport = collectHealthReport("1.1.0");
|
|
4197
|
+
const initResult = await performInit(config, anonKeyForInit, "1.1.0", healthReport);
|
|
4176
4198
|
if (generation !== registrationGeneration) return;
|
|
4177
4199
|
const currentState = getCoreState();
|
|
4178
4200
|
if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
|
|
@@ -4195,7 +4217,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
|
|
|
4195
4217
|
}
|
|
4196
4218
|
maybeInstallConsoleCapture();
|
|
4197
4219
|
if (didLastInitSucceed()) {
|
|
4198
|
-
startHeartbeat(config, anonKeyForInit, "1.0
|
|
4220
|
+
startHeartbeat(config, anonKeyForInit, "1.1.0", generation, (newApiKey, accountId) => {
|
|
4199
4221
|
setAuthState(AuthState.CLAIMING);
|
|
4200
4222
|
emitLifecycleEvent("auth:claim_started", { accountId });
|
|
4201
4223
|
setResolvedApiKey(newApiKey);
|
|
@@ -4544,4 +4566,4 @@ export {
|
|
|
4544
4566
|
withGlasstraceConfig,
|
|
4545
4567
|
captureError
|
|
4546
4568
|
};
|
|
4547
|
-
//# sourceMappingURL=chunk-
|
|
4569
|
+
//# sourceMappingURL=chunk-ZBTC5QIQ.js.map
|