@glasstrace/sdk 0.13.1 → 0.13.2
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/dist/index.cjs +26 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +27 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -361,6 +361,7 @@ interface GlasstraceExporterOptions {
|
|
|
361
361
|
environment: string | undefined;
|
|
362
362
|
endpointUrl: string;
|
|
363
363
|
createDelegate: ((url: string, headers: Record<string, string>) => SpanExporter) | null;
|
|
364
|
+
/** @deprecated No-op retained for backward compatibility. Will be removed in a future major. */
|
|
364
365
|
verbose?: boolean;
|
|
365
366
|
}
|
|
366
367
|
/**
|
|
@@ -382,7 +383,6 @@ declare class GlasstraceExporter implements SpanExporter {
|
|
|
382
383
|
private readonly environment;
|
|
383
384
|
private readonly endpointUrl;
|
|
384
385
|
private readonly createDelegateFn;
|
|
385
|
-
private readonly verbose;
|
|
386
386
|
private delegate;
|
|
387
387
|
private delegateKey;
|
|
388
388
|
private pendingBatches;
|
package/dist/index.d.ts
CHANGED
|
@@ -361,6 +361,7 @@ interface GlasstraceExporterOptions {
|
|
|
361
361
|
environment: string | undefined;
|
|
362
362
|
endpointUrl: string;
|
|
363
363
|
createDelegate: ((url: string, headers: Record<string, string>) => SpanExporter) | null;
|
|
364
|
+
/** @deprecated No-op retained for backward compatibility. Will be removed in a future major. */
|
|
364
365
|
verbose?: boolean;
|
|
365
366
|
}
|
|
366
367
|
/**
|
|
@@ -382,7 +383,6 @@ declare class GlasstraceExporter implements SpanExporter {
|
|
|
382
383
|
private readonly environment;
|
|
383
384
|
private readonly endpointUrl;
|
|
384
385
|
private readonly createDelegateFn;
|
|
385
|
-
private readonly verbose;
|
|
386
386
|
private delegate;
|
|
387
387
|
private delegateKey;
|
|
388
388
|
private pendingBatches;
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
import {
|
|
34
34
|
DiagLogLevel,
|
|
35
35
|
INVALID_SPAN_CONTEXT,
|
|
36
|
+
ROOT_CONTEXT,
|
|
36
37
|
SamplingDecision,
|
|
37
38
|
SpanKind,
|
|
38
39
|
SpanStatusCode,
|
|
@@ -577,7 +578,6 @@ var GlasstraceExporter = class {
|
|
|
577
578
|
environment;
|
|
578
579
|
endpointUrl;
|
|
579
580
|
createDelegateFn;
|
|
580
|
-
verbose;
|
|
581
581
|
delegate = null;
|
|
582
582
|
delegateKey = null;
|
|
583
583
|
pendingBatches = [];
|
|
@@ -590,7 +590,6 @@ var GlasstraceExporter = class {
|
|
|
590
590
|
this.environment = options.environment;
|
|
591
591
|
this.endpointUrl = options.endpointUrl;
|
|
592
592
|
this.createDelegateFn = options.createDelegate;
|
|
593
|
-
this.verbose = options.verbose ?? false;
|
|
594
593
|
}
|
|
595
594
|
export(spans, resultCallback) {
|
|
596
595
|
const currentKey = this.getApiKey();
|
|
@@ -598,15 +597,6 @@ var GlasstraceExporter = class {
|
|
|
598
597
|
this.bufferSpans(spans, resultCallback);
|
|
599
598
|
return;
|
|
600
599
|
}
|
|
601
|
-
if (this.verbose) {
|
|
602
|
-
for (const span of spans) {
|
|
603
|
-
const ctx = span.spanContext();
|
|
604
|
-
sdkLog(
|
|
605
|
-
"info",
|
|
606
|
-
`[glasstrace:span-diag] name=${span.name} traceId=${ctx.traceId} spanId=${ctx.spanId} parentSpanId=${span.parentSpanId ?? "root"}`
|
|
607
|
-
);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
600
|
const enrichedSpans = spans.map((span) => this.enrichSpan(span));
|
|
611
601
|
const exporter = this.ensureDelegate();
|
|
612
602
|
if (exporter) {
|
|
@@ -838,15 +828,6 @@ var GlasstraceExporter = class {
|
|
|
838
828
|
this.pendingBatches = [];
|
|
839
829
|
this.pendingSpanCount = 0;
|
|
840
830
|
for (const batch of batches) {
|
|
841
|
-
if (this.verbose) {
|
|
842
|
-
for (const span of batch.spans) {
|
|
843
|
-
const ctx = span.spanContext();
|
|
844
|
-
sdkLog(
|
|
845
|
-
"info",
|
|
846
|
-
`[glasstrace:span-diag] name=${span.name} traceId=${ctx.traceId} spanId=${ctx.spanId} parentSpanId=${span.parentSpanId ?? "root"}`
|
|
847
|
-
);
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
831
|
const enriched = batch.spans.map((span) => this.enrichSpan(span));
|
|
851
832
|
exporter.export(enriched, (result) => {
|
|
852
833
|
if (result.code !== 0) {
|
|
@@ -3616,8 +3597,7 @@ async function configureOtel(config, sessionManager) {
|
|
|
3616
3597
|
getConfig: () => getActiveConfig(),
|
|
3617
3598
|
environment: config.environment,
|
|
3618
3599
|
endpointUrl: exporterUrl,
|
|
3619
|
-
createDelegate: createOtlpExporter
|
|
3620
|
-
verbose: config.verbose
|
|
3600
|
+
createDelegate: createOtlpExporter
|
|
3621
3601
|
});
|
|
3622
3602
|
_activeExporter = glasstraceExporter;
|
|
3623
3603
|
const vercelOtel = await tryImport("@vercel/otel");
|
|
@@ -3663,6 +3643,28 @@ async function configureOtel(config, sessionManager) {
|
|
|
3663
3643
|
const provider = new BasicTracerProvider({
|
|
3664
3644
|
spanProcessors: [processor]
|
|
3665
3645
|
});
|
|
3646
|
+
const asyncHooks = await tryImport("node:async_hooks");
|
|
3647
|
+
if (!asyncHooks) {
|
|
3648
|
+
trace.setGlobalTracerProvider(provider);
|
|
3649
|
+
registerShutdownHooks(provider);
|
|
3650
|
+
return;
|
|
3651
|
+
}
|
|
3652
|
+
const { AsyncLocalStorage } = asyncHooks;
|
|
3653
|
+
const als = new AsyncLocalStorage();
|
|
3654
|
+
const contextManager = {
|
|
3655
|
+
active: () => als.getStore() ?? ROOT_CONTEXT,
|
|
3656
|
+
with: (context2, fn, thisArg, ...args) => als.run(context2, () => fn.apply(thisArg, args)),
|
|
3657
|
+
bind: (context2, target) => {
|
|
3658
|
+
if (typeof target === "function") {
|
|
3659
|
+
const bound = (...args) => als.run(context2, () => target(...args));
|
|
3660
|
+
return bound;
|
|
3661
|
+
}
|
|
3662
|
+
return target;
|
|
3663
|
+
},
|
|
3664
|
+
enable: () => contextManager,
|
|
3665
|
+
disable: () => contextManager
|
|
3666
|
+
};
|
|
3667
|
+
context.setGlobalContextManager(contextManager);
|
|
3666
3668
|
trace.setGlobalTracerProvider(provider);
|
|
3667
3669
|
registerShutdownHooks(provider);
|
|
3668
3670
|
}
|
|
@@ -3923,8 +3925,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
|
|
|
3923
3925
|
if (config.verbose) {
|
|
3924
3926
|
console.info("[glasstrace] Background init firing.");
|
|
3925
3927
|
}
|
|
3926
|
-
const healthReport = collectHealthReport("0.13.
|
|
3927
|
-
const initResult = await performInit(config, anonKeyForInit, "0.13.
|
|
3928
|
+
const healthReport = collectHealthReport("0.13.2");
|
|
3929
|
+
const initResult = await performInit(config, anonKeyForInit, "0.13.2", healthReport);
|
|
3928
3930
|
if (generation !== registrationGeneration) return;
|
|
3929
3931
|
if (initResult?.claimResult) {
|
|
3930
3932
|
setResolvedApiKey(initResult.claimResult.newApiKey);
|
|
@@ -3932,7 +3934,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
|
|
|
3932
3934
|
}
|
|
3933
3935
|
maybeInstallConsoleCapture();
|
|
3934
3936
|
if (didLastInitSucceed()) {
|
|
3935
|
-
startHeartbeat(config, anonKeyForInit, "0.13.
|
|
3937
|
+
startHeartbeat(config, anonKeyForInit, "0.13.2", generation, (newApiKey) => {
|
|
3936
3938
|
setResolvedApiKey(newApiKey);
|
|
3937
3939
|
notifyApiKeyResolved();
|
|
3938
3940
|
});
|