@bitfab/sdk 0.51.0 → 0.52.1
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/{chunk-RGC7IEOI.js → chunk-6DIR65JW.js} +63 -3
- package/dist/chunk-6DIR65JW.js.map +1 -0
- package/dist/{chunk-DNYZJLNY.js → chunk-A5UGSRMK.js} +2 -2
- package/dist/{chunk-4CLJF2DZ.js → chunk-UQLT25PG.js} +40 -3
- package/dist/chunk-UQLT25PG.js.map +1 -0
- package/dist/{chunk-VXD27AJ3.js → chunk-XAT6WLCS.js} +41 -19
- package/dist/chunk-XAT6WLCS.js.map +1 -0
- package/dist/{http-HLRWCSFF.js → http-B2AK43BN.js} +2 -2
- package/dist/{http-AKFJONE7.js → http-RI4YCAS2.js} +2 -2
- package/dist/index.cjs +100 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +3 -3
- package/dist/node.cjs +100 -15
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +3 -3
- package/dist/{replay-ISXRCXUP.js → replay-24F3F5RD.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-4CLJF2DZ.js.map +0 -1
- package/dist/chunk-RGC7IEOI.js.map +0 -1
- package/dist/chunk-VXD27AJ3.js.map +0 -1
- /package/dist/{chunk-DNYZJLNY.js.map → chunk-A5UGSRMK.js.map} +0 -0
- /package/dist/{http-AKFJONE7.js.map → http-B2AK43BN.js.map} +0 -0
- /package/dist/{http-HLRWCSFF.js.map → http-RI4YCAS2.js.map} +0 -0
- /package/dist/{replay-ISXRCXUP.js.map → replay-24F3F5RD.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -536,7 +536,7 @@ declare class HttpClient {
|
|
|
536
536
|
* {@link HttpClient.sendExternalSpan}; replay confirms persistence with the
|
|
537
537
|
* server-authoritative barrier in `replay.ts`, not by awaiting this call.
|
|
538
538
|
*/
|
|
539
|
-
sendExternalTrace(
|
|
539
|
+
sendExternalTrace(rawPayload: Record<string, unknown>): void;
|
|
540
540
|
/**
|
|
541
541
|
* Partial update of an existing trace identified by its Bitfab trace ID.
|
|
542
542
|
* Used by the detached `client.getTrace(id)` handle.
|
|
@@ -802,11 +802,19 @@ type TraceAssertionsResult = {
|
|
|
802
802
|
assertions: TraceAssertion[];
|
|
803
803
|
inheritedFrom: string | null;
|
|
804
804
|
};
|
|
805
|
+
type TraceAssertionsUpdate = {
|
|
806
|
+
traceId: string;
|
|
807
|
+
assertions: SaveAssertion[];
|
|
808
|
+
};
|
|
805
809
|
type SaveAssertionsParams = {
|
|
806
810
|
traceId: string;
|
|
807
811
|
assertions: SaveAssertion[];
|
|
808
812
|
source?: TraceAssertionSource;
|
|
809
813
|
};
|
|
814
|
+
type SaveAssertionsAllParams = {
|
|
815
|
+
updates: TraceAssertionsUpdate[];
|
|
816
|
+
source?: TraceAssertionSource;
|
|
817
|
+
};
|
|
810
818
|
type ArchiveAssertionsParams = {
|
|
811
819
|
traceId: string;
|
|
812
820
|
assertionIds: string[];
|
|
@@ -816,6 +824,7 @@ declare class TracesClient {
|
|
|
816
824
|
constructor(httpClient: HttpClient);
|
|
817
825
|
getAssertions(traceId: string): Promise<TraceAssertionsResult>;
|
|
818
826
|
saveAssertions(params: SaveAssertionsParams): Promise<TraceAssertion[]>;
|
|
827
|
+
saveAssertionsAll(params: SaveAssertionsAllParams): Promise<TraceAssertion[]>;
|
|
819
828
|
archiveAssertions(params: ArchiveAssertionsParams): Promise<string[]>;
|
|
820
829
|
}
|
|
821
830
|
|
|
@@ -3279,7 +3288,7 @@ declare class BitfabFunction {
|
|
|
3279
3288
|
/**
|
|
3280
3289
|
* SDK version from package.json (injected at build time)
|
|
3281
3290
|
*/
|
|
3282
|
-
declare const __version__ = "0.
|
|
3291
|
+
declare const __version__ = "0.52.1";
|
|
3283
3292
|
|
|
3284
3293
|
/**
|
|
3285
3294
|
* Constants for the Bitfab SDK.
|
|
@@ -3409,4 +3418,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
|
|
|
3409
3418
|
run?: boolean;
|
|
3410
3419
|
}): Promise<SeedResult>;
|
|
3411
3420
|
|
|
3412
|
-
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ArchiveAssertionsParams, type AssertionVerdict, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, type LabelUpdate, LabelsClient, type LangGraphIntegrationOptions, type ListDatasetsParams, MixedTracingError, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveAssertion, type SaveAssertionsParams, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceAssertion, type TraceAssertionSource, type TraceAssertionsResult, type TraceIngestionType, type TraceLabels, type TraceOutline, type TraceOutlineSpan, type TraceOutlineSpanError, type TraceResponse, type TraceTarget, type TraceTargetOccurrence, TracesClient, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
|
|
3421
|
+
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ArchiveAssertionsParams, type AssertionVerdict, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, type LabelUpdate, LabelsClient, type LangGraphIntegrationOptions, type ListDatasetsParams, MixedTracingError, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveAssertion, type SaveAssertionsAllParams, type SaveAssertionsParams, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceAssertion, type TraceAssertionSource, type TraceAssertionsResult, type TraceAssertionsUpdate, type TraceIngestionType, type TraceLabels, type TraceOutline, type TraceOutlineSpan, type TraceOutlineSpanError, type TraceResponse, type TraceTarget, type TraceTargetOccurrence, TracesClient, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -536,7 +536,7 @@ declare class HttpClient {
|
|
|
536
536
|
* {@link HttpClient.sendExternalSpan}; replay confirms persistence with the
|
|
537
537
|
* server-authoritative barrier in `replay.ts`, not by awaiting this call.
|
|
538
538
|
*/
|
|
539
|
-
sendExternalTrace(
|
|
539
|
+
sendExternalTrace(rawPayload: Record<string, unknown>): void;
|
|
540
540
|
/**
|
|
541
541
|
* Partial update of an existing trace identified by its Bitfab trace ID.
|
|
542
542
|
* Used by the detached `client.getTrace(id)` handle.
|
|
@@ -802,11 +802,19 @@ type TraceAssertionsResult = {
|
|
|
802
802
|
assertions: TraceAssertion[];
|
|
803
803
|
inheritedFrom: string | null;
|
|
804
804
|
};
|
|
805
|
+
type TraceAssertionsUpdate = {
|
|
806
|
+
traceId: string;
|
|
807
|
+
assertions: SaveAssertion[];
|
|
808
|
+
};
|
|
805
809
|
type SaveAssertionsParams = {
|
|
806
810
|
traceId: string;
|
|
807
811
|
assertions: SaveAssertion[];
|
|
808
812
|
source?: TraceAssertionSource;
|
|
809
813
|
};
|
|
814
|
+
type SaveAssertionsAllParams = {
|
|
815
|
+
updates: TraceAssertionsUpdate[];
|
|
816
|
+
source?: TraceAssertionSource;
|
|
817
|
+
};
|
|
810
818
|
type ArchiveAssertionsParams = {
|
|
811
819
|
traceId: string;
|
|
812
820
|
assertionIds: string[];
|
|
@@ -816,6 +824,7 @@ declare class TracesClient {
|
|
|
816
824
|
constructor(httpClient: HttpClient);
|
|
817
825
|
getAssertions(traceId: string): Promise<TraceAssertionsResult>;
|
|
818
826
|
saveAssertions(params: SaveAssertionsParams): Promise<TraceAssertion[]>;
|
|
827
|
+
saveAssertionsAll(params: SaveAssertionsAllParams): Promise<TraceAssertion[]>;
|
|
819
828
|
archiveAssertions(params: ArchiveAssertionsParams): Promise<string[]>;
|
|
820
829
|
}
|
|
821
830
|
|
|
@@ -3279,7 +3288,7 @@ declare class BitfabFunction {
|
|
|
3279
3288
|
/**
|
|
3280
3289
|
* SDK version from package.json (injected at build time)
|
|
3281
3290
|
*/
|
|
3282
|
-
declare const __version__ = "0.
|
|
3291
|
+
declare const __version__ = "0.52.1";
|
|
3283
3292
|
|
|
3284
3293
|
/**
|
|
3285
3294
|
* Constants for the Bitfab SDK.
|
|
@@ -3409,4 +3418,4 @@ declare function seedFromRegistry(registry: ReplayRegistry, pipeline: string, ca
|
|
|
3409
3418
|
run?: boolean;
|
|
3410
3419
|
}): Promise<SeedResult>;
|
|
3411
3420
|
|
|
3412
|
-
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ArchiveAssertionsParams, type AssertionVerdict, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, type LabelUpdate, LabelsClient, type LangGraphIntegrationOptions, type ListDatasetsParams, MixedTracingError, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveAssertion, type SaveAssertionsParams, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceAssertion, type TraceAssertionSource, type TraceAssertionsResult, type TraceIngestionType, type TraceLabels, type TraceOutline, type TraceOutlineSpan, type TraceOutlineSpanError, type TraceResponse, type TraceTarget, type TraceTargetOccurrence, TracesClient, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
|
|
3421
|
+
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AddDatasetGradersResult, type AddDatasetTracesResult, type AllowedEnvVars, type ArchiveAssertionsParams, type AssertionVerdict, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, BitfabLangGraphIntegration, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureSurface, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type Dataset, type DatasetGraderRef, type DatasetTraceIds, DatasetsClient, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, type GetGraderLabelsParams, type GraderLabel, type GraderLabelSource, type GraderRerun, type GraderRerunProgress, type GraderRerunResult, type GraderRerunStatus, GradersClient, HttpClient, type HumanLabelOutcome, type HumanLabelUpdate, type LabelAction, type LabelConfidence, type LabelOutcome, type LabelSource, type LabelStatus, type LabelUpdate, LabelsClient, type LangGraphIntegrationOptions, type ListDatasetsParams, MixedTracingError, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, type RemoveDatasetGradersResult, type RemoveDatasetTracesResult, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, type RerunGradersOptions, type RerunGradersResult, SUPPORTED_PROVIDERS, type SaveAssertion, type SaveAssertionsAllParams, type SaveAssertionsParams, type SaveDatasetParams, type SaveDatasetResult, type SeedCase, type SeedCaseOptions, type SeedResult, type SeedRunOptions, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceAssertion, type TraceAssertionSource, type TraceAssertionsResult, type TraceAssertionsUpdate, type TraceIngestionType, type TraceLabels, type TraceOutline, type TraceOutlineSpan, type TraceOutlineSpanError, type TraceResponse, type TraceTarget, type TraceTargetOccurrence, TracesClient, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, seedFromRegistry, serializeReplayResult };
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
getCurrentSpan,
|
|
19
19
|
getCurrentTrace,
|
|
20
20
|
seedFromRegistry
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-XAT6WLCS.js";
|
|
22
22
|
import "./chunk-ZUD7OFYB.js";
|
|
23
23
|
import {
|
|
24
24
|
BITFAB_PROGRESS_PREFIX,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
ReplayError,
|
|
28
28
|
reportReplayProgress,
|
|
29
29
|
serializeReplayResult
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-A5UGSRMK.js";
|
|
31
31
|
import {
|
|
32
32
|
BitfabError,
|
|
33
33
|
DEFAULT_SERVICE_URL,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
MixedTracingError,
|
|
36
36
|
__version__,
|
|
37
37
|
flushTraces
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-6DIR65JW.js";
|
|
39
39
|
import "./chunk-H6LZRFMN.js";
|
|
40
40
|
export {
|
|
41
41
|
BITFAB_PROGRESS_PREFIX,
|
package/dist/node.cjs
CHANGED
|
@@ -88,7 +88,7 @@ var __version__, __packageName__;
|
|
|
88
88
|
var init_version_generated = __esm({
|
|
89
89
|
"src/version.generated.ts"() {
|
|
90
90
|
"use strict";
|
|
91
|
-
__version__ = "0.
|
|
91
|
+
__version__ = "0.52.1";
|
|
92
92
|
__packageName__ = "@bitfab/sdk";
|
|
93
93
|
}
|
|
94
94
|
});
|
|
@@ -541,6 +541,69 @@ var init_serializePayload = __esm({
|
|
|
541
541
|
}
|
|
542
542
|
});
|
|
543
543
|
|
|
544
|
+
// src/traceMetadata.ts
|
|
545
|
+
function recordCallerTraceMetadata(traceId, metadata) {
|
|
546
|
+
if (typeof traceId !== "string" || traceId === "") {
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
if (typeof metadata !== "object" || metadata === null) {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
if (Object.keys(metadata).length === 0) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
callerMetadata.set(traceId, { ...callerMetadata.get(traceId), ...metadata });
|
|
556
|
+
}
|
|
557
|
+
function callerTraceMetadata(traceId) {
|
|
558
|
+
const recorded = callerMetadata.get(traceId);
|
|
559
|
+
return recorded ? { ...recorded } : void 0;
|
|
560
|
+
}
|
|
561
|
+
function forgetTraceMetadata(traceId) {
|
|
562
|
+
callerMetadata.delete(traceId);
|
|
563
|
+
derivedMetadata.delete(traceId);
|
|
564
|
+
}
|
|
565
|
+
function mergeCallerMetadataIntoTracePayload(payload) {
|
|
566
|
+
const externalTrace = payload.externalTrace;
|
|
567
|
+
if (typeof externalTrace !== "object" || externalTrace === null) {
|
|
568
|
+
return payload;
|
|
569
|
+
}
|
|
570
|
+
const external = externalTrace;
|
|
571
|
+
const traceId = typeof payload.id === "string" && payload.id !== "" ? payload.id : external.id;
|
|
572
|
+
if (typeof traceId !== "string" || traceId === "") {
|
|
573
|
+
return payload;
|
|
574
|
+
}
|
|
575
|
+
const caller = callerMetadata.get(traceId);
|
|
576
|
+
if (!caller) {
|
|
577
|
+
return payload;
|
|
578
|
+
}
|
|
579
|
+
const derived = derivedMetadata.get(traceId) ?? {};
|
|
580
|
+
const exported = external.metadata;
|
|
581
|
+
if (typeof exported === "object" && exported !== null) {
|
|
582
|
+
Object.assign(derived, exported);
|
|
583
|
+
}
|
|
584
|
+
derivedMetadata.set(traceId, derived);
|
|
585
|
+
const shadowed = Object.keys(derived).filter((key) => key in caller && caller[key] !== derived[key]).sort();
|
|
586
|
+
if (shadowed.length > 0) {
|
|
587
|
+
warnOnce(
|
|
588
|
+
`trace-metadata-shadowed:${shadowed.join(",")}`,
|
|
589
|
+
`trace metadata key(s) ${shadowed.join(", ")} were set both by the caller and by an integration's own trace export; the caller's value is the one kept on the trace.`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
return {
|
|
593
|
+
...payload,
|
|
594
|
+
externalTrace: { ...external, metadata: { ...derived, ...caller } }
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
var callerMetadata, derivedMetadata;
|
|
598
|
+
var init_traceMetadata = __esm({
|
|
599
|
+
"src/traceMetadata.ts"() {
|
|
600
|
+
"use strict";
|
|
601
|
+
init_warnOnce();
|
|
602
|
+
callerMetadata = /* @__PURE__ */ new Map();
|
|
603
|
+
derivedMetadata = /* @__PURE__ */ new Map();
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
|
|
544
607
|
// src/transportTypes.ts
|
|
545
608
|
var DeliveryError;
|
|
546
609
|
var init_transportTypes = __esm({
|
|
@@ -1359,6 +1422,7 @@ var init_http = __esm({
|
|
|
1359
1422
|
init_errors();
|
|
1360
1423
|
init_replayContext();
|
|
1361
1424
|
init_serializePayload();
|
|
1425
|
+
init_traceMetadata();
|
|
1362
1426
|
init_transport();
|
|
1363
1427
|
init_transportTypes();
|
|
1364
1428
|
init_unrefTimer();
|
|
@@ -1822,7 +1886,8 @@ var init_http = __esm({
|
|
|
1822
1886
|
* {@link HttpClient.sendExternalSpan}; replay confirms persistence with the
|
|
1823
1887
|
* server-authoritative barrier in `replay.ts`, not by awaiting this call.
|
|
1824
1888
|
*/
|
|
1825
|
-
sendExternalTrace(
|
|
1889
|
+
sendExternalTrace(rawPayload) {
|
|
1890
|
+
const payload = mergeCallerMetadataIntoTracePayload(rawPayload);
|
|
1826
1891
|
this.getTraceTransport()?.submit(
|
|
1827
1892
|
"external_trace",
|
|
1828
1893
|
{
|
|
@@ -3330,7 +3395,8 @@ registerAsyncLocalStorageClass(
|
|
|
3330
3395
|
);
|
|
3331
3396
|
|
|
3332
3397
|
// src/assertions.ts
|
|
3333
|
-
|
|
3398
|
+
var ASSERTIONS_PATH = "/api/sdk/traces/assertions";
|
|
3399
|
+
function traceAssertionsPath(traceId, suffix = "") {
|
|
3334
3400
|
return `/api/sdk/traces/${encodeURIComponent(traceId)}/assertions${suffix}`;
|
|
3335
3401
|
}
|
|
3336
3402
|
var TracesClient = class {
|
|
@@ -3338,18 +3404,29 @@ var TracesClient = class {
|
|
|
3338
3404
|
this.httpClient = httpClient;
|
|
3339
3405
|
}
|
|
3340
3406
|
async getAssertions(traceId) {
|
|
3341
|
-
return this.httpClient.get(
|
|
3407
|
+
return this.httpClient.get(
|
|
3408
|
+
traceAssertionsPath(traceId)
|
|
3409
|
+
);
|
|
3342
3410
|
}
|
|
3343
3411
|
async saveAssertions(params) {
|
|
3344
|
-
|
|
3345
|
-
assertions: params.assertions,
|
|
3412
|
+
return this.saveAssertionsAll({
|
|
3413
|
+
updates: [{ traceId: params.traceId, assertions: params.assertions }],
|
|
3414
|
+
source: params.source
|
|
3415
|
+
});
|
|
3416
|
+
}
|
|
3417
|
+
async saveAssertionsAll(params) {
|
|
3418
|
+
if (params.updates.length === 0) {
|
|
3419
|
+
return [];
|
|
3420
|
+
}
|
|
3421
|
+
const response = await this.httpClient.request(ASSERTIONS_PATH, {
|
|
3422
|
+
updates: params.updates,
|
|
3346
3423
|
source: params.source ?? "agent"
|
|
3347
3424
|
});
|
|
3348
3425
|
return response.assertions;
|
|
3349
3426
|
}
|
|
3350
3427
|
async archiveAssertions(params) {
|
|
3351
3428
|
const response = await this.httpClient.request(
|
|
3352
|
-
|
|
3429
|
+
traceAssertionsPath(params.traceId, "/archive"),
|
|
3353
3430
|
{ assertionIds: params.assertionIds }
|
|
3354
3431
|
);
|
|
3355
3432
|
return response.archived;
|
|
@@ -5702,6 +5779,7 @@ function runWithSeedContext(ctx, fn) {
|
|
|
5702
5779
|
|
|
5703
5780
|
// src/client.ts
|
|
5704
5781
|
init_serialize();
|
|
5782
|
+
init_traceMetadata();
|
|
5705
5783
|
|
|
5706
5784
|
// src/tracing.ts
|
|
5707
5785
|
init_constants();
|
|
@@ -6382,8 +6460,7 @@ function getCurrentTrace() {
|
|
|
6382
6460
|
if (typeof metadata !== "object" || metadata === null) {
|
|
6383
6461
|
return;
|
|
6384
6462
|
}
|
|
6385
|
-
|
|
6386
|
-
traceState.metadata = { ...traceState.metadata, ...metadata };
|
|
6463
|
+
recordCallerTraceMetadata(traceId, metadata);
|
|
6387
6464
|
} catch {
|
|
6388
6465
|
}
|
|
6389
6466
|
},
|
|
@@ -7376,7 +7453,7 @@ var Bitfab = class {
|
|
|
7376
7453
|
endedAt,
|
|
7377
7454
|
sessionId: traceState?.sessionId,
|
|
7378
7455
|
name: traceState?.name,
|
|
7379
|
-
metadata:
|
|
7456
|
+
metadata: callerTraceMetadata(traceId),
|
|
7380
7457
|
contexts: traceState?.contexts ?? [],
|
|
7381
7458
|
testRunId: traceState?.testRunId,
|
|
7382
7459
|
inputSourceTraceId: traceState?.inputSourceTraceId,
|
|
@@ -7400,6 +7477,7 @@ var Bitfab = class {
|
|
|
7400
7477
|
}
|
|
7401
7478
|
});
|
|
7402
7479
|
activeTraceStates.delete(traceId);
|
|
7480
|
+
forgetTraceMetadata(traceId);
|
|
7403
7481
|
}
|
|
7404
7482
|
} catch {
|
|
7405
7483
|
}
|
|
@@ -7592,6 +7670,7 @@ var Bitfab = class {
|
|
|
7592
7670
|
} catch (setupError) {
|
|
7593
7671
|
if (registeredTraceId) {
|
|
7594
7672
|
activeTraceStates.delete(registeredTraceId);
|
|
7673
|
+
forgetTraceMetadata(registeredTraceId);
|
|
7595
7674
|
}
|
|
7596
7675
|
if (setupError instanceof MixedTracingError) {
|
|
7597
7676
|
throw setupError;
|
|
@@ -7952,14 +8031,16 @@ var Bitfab = class {
|
|
|
7952
8031
|
}
|
|
7953
8032
|
const traceId = randomUuid();
|
|
7954
8033
|
const startedAt = nowIsoTimestamp();
|
|
8034
|
+
if (options.metadata !== void 0) {
|
|
8035
|
+
recordCallerTraceMetadata(traceId, options.metadata);
|
|
8036
|
+
}
|
|
7955
8037
|
activeTraceStates.set(traceId, {
|
|
7956
8038
|
traceId,
|
|
7957
8039
|
startedAt,
|
|
7958
8040
|
contexts: [],
|
|
7959
8041
|
ingestionType: "seeded",
|
|
7960
8042
|
...options.sessionId !== void 0 && { sessionId: options.sessionId },
|
|
7961
|
-
...options.name !== void 0 && { name: options.name }
|
|
7962
|
-
...options.metadata !== void 0 && { metadata: options.metadata }
|
|
8043
|
+
...options.name !== void 0 && { name: options.name }
|
|
7963
8044
|
});
|
|
7964
8045
|
try {
|
|
7965
8046
|
this.sendWrapperSpan({
|
|
@@ -7982,12 +8063,13 @@ var Bitfab = class {
|
|
|
7982
8063
|
endedAt: startedAt,
|
|
7983
8064
|
sessionId: options.sessionId,
|
|
7984
8065
|
name: options.name,
|
|
7985
|
-
metadata:
|
|
8066
|
+
metadata: callerTraceMetadata(traceId),
|
|
7986
8067
|
contexts: [],
|
|
7987
8068
|
ingestionType: "seeded"
|
|
7988
8069
|
});
|
|
7989
8070
|
} finally {
|
|
7990
8071
|
activeTraceStates.delete(traceId);
|
|
8072
|
+
forgetTraceMetadata(traceId);
|
|
7991
8073
|
}
|
|
7992
8074
|
return traceId;
|
|
7993
8075
|
}
|
|
@@ -8012,14 +8094,16 @@ var Bitfab = class {
|
|
|
8012
8094
|
}
|
|
8013
8095
|
await seedContextReady;
|
|
8014
8096
|
const traceId = randomUuid();
|
|
8097
|
+
if (options?.metadata !== void 0) {
|
|
8098
|
+
recordCallerTraceMetadata(traceId, options.metadata);
|
|
8099
|
+
}
|
|
8015
8100
|
activeTraceStates.set(traceId, {
|
|
8016
8101
|
traceId,
|
|
8017
8102
|
startedAt: nowIsoTimestamp(),
|
|
8018
8103
|
contexts: [],
|
|
8019
8104
|
ingestionType: "seeded",
|
|
8020
8105
|
...options?.sessionId !== void 0 && { sessionId: options.sessionId },
|
|
8021
|
-
...options?.name !== void 0 && { name: options.name }
|
|
8022
|
-
...options?.metadata !== void 0 && { metadata: options.metadata }
|
|
8106
|
+
...options?.name !== void 0 && { name: options.name }
|
|
8023
8107
|
});
|
|
8024
8108
|
const args = options?.args ?? [];
|
|
8025
8109
|
let unrecorded = true;
|
|
@@ -8031,6 +8115,7 @@ var Bitfab = class {
|
|
|
8031
8115
|
await flushTraces2(3e4);
|
|
8032
8116
|
} finally {
|
|
8033
8117
|
unrecorded = activeTraceStates.delete(traceId);
|
|
8118
|
+
forgetTraceMetadata(traceId);
|
|
8034
8119
|
}
|
|
8035
8120
|
}
|
|
8036
8121
|
if (unrecorded) {
|