@brizz/sdk 0.1.25 → 0.1.27
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 +172 -56
- package/dist/index.js +154 -38
- package/dist/preload.cjs +59 -20
- package/dist/preload.js +52 -13
- package/package.json +5 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/preload.cjs.map +0 -1
- package/dist/preload.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -180,31 +180,9 @@ var init_logger = __esm({
|
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
// src/internal/semantic-conventions.ts
|
|
184
|
-
var import_api2, BRIZZ, PROPERTIES, SESSION_ID, PROPERTIES_CONTEXT_KEY, SESSION_OBJECT_CONTEXT_KEY, SESSION_INPUT, SESSION_OUTPUT, SESSION_INPUT_CONTEXT, SESSION_OUTPUT_CONTEXT, SESSION_SPAN_NAME, SESSION_TITLE_SPAN_NAME, SESSION_TITLE_GENERATION, SESSION_TITLE;
|
|
185
|
-
var init_semantic_conventions = __esm({
|
|
186
|
-
"src/internal/semantic-conventions.ts"() {
|
|
187
|
-
"use strict";
|
|
188
|
-
import_api2 = require("@opentelemetry/api");
|
|
189
|
-
BRIZZ = "brizz";
|
|
190
|
-
PROPERTIES = "properties";
|
|
191
|
-
SESSION_ID = "session.id";
|
|
192
|
-
PROPERTIES_CONTEXT_KEY = (0, import_api2.createContextKey)(PROPERTIES);
|
|
193
|
-
SESSION_OBJECT_CONTEXT_KEY = (0, import_api2.createContextKey)("brizz.session.object");
|
|
194
|
-
SESSION_INPUT = "brizz.session.input";
|
|
195
|
-
SESSION_OUTPUT = "brizz.session.output";
|
|
196
|
-
SESSION_INPUT_CONTEXT = "brizz.session.input.context";
|
|
197
|
-
SESSION_OUTPUT_CONTEXT = "brizz.session.output.context";
|
|
198
|
-
SESSION_SPAN_NAME = "brizz.start_session";
|
|
199
|
-
SESSION_TITLE_SPAN_NAME = "brizz.session_title";
|
|
200
|
-
SESSION_TITLE_GENERATION = "session.title_generation";
|
|
201
|
-
SESSION_TITLE = "brizz.session.title";
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
|
|
205
183
|
// src/internal/instrumentation/mcp/semantic-conventions.ts
|
|
206
184
|
var MCP_TOOL_NAME, MCP_TOOL_ARGUMENTS, MCP_TOOL_RESULT, MCP_COMPONENT_TYPE, MCP_COMPONENT_TOOL, MCP_COMPONENT_TOOL_SCHEMA, MCP_TOOL_SCHEMA_PARAMETERS, MCP_TOOL_SCHEMA_OUTPUT, MCP_TOOL_DESCRIPTION, SPAN_NAME_TOOL_REGISTER, MCP_METHOD_NAME, MCP_REQUEST_ID, MCP_SESSION_ID, MCP_PROTOCOL_VERSION, MCP_RESOURCE_URI, RPC_SYSTEM, RPC_SYSTEM_MCP, RPC_RESPONSE_STATUS_CODE, GEN_AI_TOOL_NAME, GEN_AI_PROMPT_NAME, GEN_AI_OPERATION_NAME, GEN_AI_OPERATION_EXECUTE_TOOL, NETWORK_TRANSPORT, ERROR_TYPE, ERROR_TYPE_TOOL, JSONRPC_REQUEST_ID, SPAN_NAME_TOOLS_CALL, MAX_ATTRIBUTE_LENGTH, TRUNCATION_SUFFIX, METHOD_TOOLS_CALL, METHOD_TOOLS_LIST, METHOD_RESOURCES_READ, METHOD_PROMPTS_GET, METHOD_INITIALIZE;
|
|
207
|
-
var
|
|
185
|
+
var init_semantic_conventions = __esm({
|
|
208
186
|
"src/internal/instrumentation/mcp/semantic-conventions.ts"() {
|
|
209
187
|
"use strict";
|
|
210
188
|
MCP_TOOL_NAME = "mcp.tool.name";
|
|
@@ -275,11 +253,11 @@ function emitSchemaSpansFromListResponse(result, transportSessionId, tracer) {
|
|
|
275
253
|
continue;
|
|
276
254
|
}
|
|
277
255
|
const span = tracer.startSpan(`${SPAN_NAME_TOOL_REGISTER} ${name}`, {
|
|
278
|
-
kind:
|
|
256
|
+
kind: import_api2.SpanKind.INTERNAL
|
|
279
257
|
});
|
|
280
258
|
try {
|
|
281
259
|
stampSchemaAttributes(span, name, transportSessionId, tool);
|
|
282
|
-
span.setStatus({ code:
|
|
260
|
+
span.setStatus({ code: import_api2.SpanStatusCode.OK });
|
|
283
261
|
} finally {
|
|
284
262
|
span.end();
|
|
285
263
|
}
|
|
@@ -298,7 +276,6 @@ function stampSchemaAttributes(span, toolName, transportSessionId, tool) {
|
|
|
298
276
|
span.setAttribute(RPC_SYSTEM, RPC_SYSTEM_MCP);
|
|
299
277
|
span.setAttribute(MCP_COMPONENT_TYPE, MCP_COMPONENT_TOOL_SCHEMA);
|
|
300
278
|
span.setAttribute(MCP_SESSION_ID, transportSessionId);
|
|
301
|
-
span.setAttribute(`${BRIZZ}.${SESSION_ID}`, transportSessionId);
|
|
302
279
|
span.setAttribute(MCP_TOOL_NAME, toolName);
|
|
303
280
|
span.setAttribute(MCP_TOOL_SCHEMA_PARAMETERS, parameters);
|
|
304
281
|
span.setAttribute(MCP_TOOL_SCHEMA_OUTPUT, outputSchema);
|
|
@@ -316,18 +293,40 @@ function extractTools(result) {
|
|
|
316
293
|
(t) => t !== null && typeof t === "object"
|
|
317
294
|
);
|
|
318
295
|
}
|
|
319
|
-
var
|
|
296
|
+
var import_api2, _MAX_SCHEMA_ATTR_BYTES;
|
|
320
297
|
var init_schemas = __esm({
|
|
321
298
|
"src/internal/instrumentation/mcp/schemas.ts"() {
|
|
322
299
|
"use strict";
|
|
323
|
-
|
|
300
|
+
import_api2 = require("@opentelemetry/api");
|
|
324
301
|
init_logger();
|
|
325
302
|
init_semantic_conventions();
|
|
326
|
-
init_semantic_conventions2();
|
|
327
303
|
_MAX_SCHEMA_ATTR_BYTES = 4e3;
|
|
328
304
|
}
|
|
329
305
|
});
|
|
330
306
|
|
|
307
|
+
// src/internal/semantic-conventions.ts
|
|
308
|
+
var import_api3, BRIZZ, PROPERTIES, SESSION_ID, PROPERTIES_CONTEXT_KEY, SESSION_OBJECT_CONTEXT_KEY, SESSION_INPUT, SESSION_OUTPUT, SESSION_INPUT_CONTEXT, SESSION_OUTPUT_CONTEXT, SESSION_SPAN_NAME, SESSION_TITLE_SPAN_NAME, SESSION_TITLE_GENERATION, SESSION_TITLE, INTERRUPT_TOOLS;
|
|
309
|
+
var init_semantic_conventions2 = __esm({
|
|
310
|
+
"src/internal/semantic-conventions.ts"() {
|
|
311
|
+
"use strict";
|
|
312
|
+
import_api3 = require("@opentelemetry/api");
|
|
313
|
+
BRIZZ = "brizz";
|
|
314
|
+
PROPERTIES = "properties";
|
|
315
|
+
SESSION_ID = "session.id";
|
|
316
|
+
PROPERTIES_CONTEXT_KEY = (0, import_api3.createContextKey)(PROPERTIES);
|
|
317
|
+
SESSION_OBJECT_CONTEXT_KEY = (0, import_api3.createContextKey)("brizz.session.object");
|
|
318
|
+
SESSION_INPUT = "brizz.session.input";
|
|
319
|
+
SESSION_OUTPUT = "brizz.session.output";
|
|
320
|
+
SESSION_INPUT_CONTEXT = "brizz.session.input.context";
|
|
321
|
+
SESSION_OUTPUT_CONTEXT = "brizz.session.output.context";
|
|
322
|
+
SESSION_SPAN_NAME = "brizz.start_session";
|
|
323
|
+
SESSION_TITLE_SPAN_NAME = "brizz.session_title";
|
|
324
|
+
SESSION_TITLE_GENERATION = "session.title_generation";
|
|
325
|
+
SESSION_TITLE = "brizz.session.title";
|
|
326
|
+
INTERRUPT_TOOLS = "brizz.internal.interrupt";
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
|
|
331
330
|
// src/internal/instrumentation/mcp/session.ts
|
|
332
331
|
function stampAndPropagateSession(span, sessionId, baseContext = import_api4.context.active()) {
|
|
333
332
|
if (!sessionId) {
|
|
@@ -360,7 +359,7 @@ var init_session = __esm({
|
|
|
360
359
|
"use strict";
|
|
361
360
|
import_api4 = require("@opentelemetry/api");
|
|
362
361
|
init_logger();
|
|
363
|
-
|
|
362
|
+
init_semantic_conventions2();
|
|
364
363
|
}
|
|
365
364
|
});
|
|
366
365
|
|
|
@@ -558,7 +557,7 @@ var init_attributes = __esm({
|
|
|
558
557
|
"src/internal/instrumentation/mcp/patches/attributes.ts"() {
|
|
559
558
|
"use strict";
|
|
560
559
|
import_api5 = require("@opentelemetry/api");
|
|
561
|
-
|
|
560
|
+
init_semantic_conventions();
|
|
562
561
|
}
|
|
563
562
|
});
|
|
564
563
|
|
|
@@ -783,7 +782,7 @@ var init_protocol = __esm({
|
|
|
783
782
|
import_api6 = require("@opentelemetry/api");
|
|
784
783
|
init_logger();
|
|
785
784
|
init_schemas();
|
|
786
|
-
|
|
785
|
+
init_semantic_conventions();
|
|
787
786
|
init_session();
|
|
788
787
|
init_attributes();
|
|
789
788
|
PATCHED_FLAG = /* @__PURE__ */ Symbol("brizz.mcp.protocol-patched");
|
|
@@ -792,7 +791,7 @@ var init_protocol = __esm({
|
|
|
792
791
|
|
|
793
792
|
// src/internal/version.ts
|
|
794
793
|
function getSDKVersion() {
|
|
795
|
-
return "0.1.
|
|
794
|
+
return "0.1.27";
|
|
796
795
|
}
|
|
797
796
|
var init_version = __esm({
|
|
798
797
|
"src/internal/version.ts"() {
|
|
@@ -974,6 +973,100 @@ var init_mcp = __esm({
|
|
|
974
973
|
}
|
|
975
974
|
});
|
|
976
975
|
|
|
976
|
+
// src/internal/instrumentation/vercel-ai/interrupt.ts
|
|
977
|
+
var interrupt_exports = {};
|
|
978
|
+
__export(interrupt_exports, {
|
|
979
|
+
InterruptPropagator: () => InterruptPropagator,
|
|
980
|
+
_resetInterruptState: () => _resetInterruptState,
|
|
981
|
+
createInterruptIntegration: () => createInterruptIntegration
|
|
982
|
+
});
|
|
983
|
+
function isInnerLLMSpan(span) {
|
|
984
|
+
if (INNER_OPERATION_IDS.has(span.name)) {
|
|
985
|
+
return true;
|
|
986
|
+
}
|
|
987
|
+
const opId = span.attributes["ai.operationId"];
|
|
988
|
+
return typeof opId === "string" && INNER_OPERATION_IDS.has(opId);
|
|
989
|
+
}
|
|
990
|
+
function setPending(parentSpanId, value) {
|
|
991
|
+
pendingByParentSpanId.set(parentSpanId, value);
|
|
992
|
+
while (pendingByParentSpanId.size > MAX_PENDING_ENTRIES) {
|
|
993
|
+
const oldest = pendingByParentSpanId.keys().next().value;
|
|
994
|
+
if (oldest === void 0) {
|
|
995
|
+
break;
|
|
996
|
+
}
|
|
997
|
+
pendingByParentSpanId.delete(oldest);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
function extractInterruptTools(tools) {
|
|
1001
|
+
if (!tools || typeof tools !== "object") {
|
|
1002
|
+
return [];
|
|
1003
|
+
}
|
|
1004
|
+
return Object.entries(tools).filter(
|
|
1005
|
+
([, t]) => !!t && typeof t === "object" && t.needsApproval
|
|
1006
|
+
).map(([name]) => name);
|
|
1007
|
+
}
|
|
1008
|
+
function createInterruptIntegration() {
|
|
1009
|
+
const onStepStart = (event) => {
|
|
1010
|
+
const names = extractInterruptTools(event.tools);
|
|
1011
|
+
if (names.length === 0) {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
const value = JSON.stringify(names);
|
|
1015
|
+
const span = import_api8.trace.getActiveSpan();
|
|
1016
|
+
if (!span) {
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
span.setAttribute(INTERRUPT_TOOLS, value);
|
|
1020
|
+
setPending(span.spanContext().spanId, value);
|
|
1021
|
+
};
|
|
1022
|
+
return {
|
|
1023
|
+
onStepStart
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
function _resetInterruptState() {
|
|
1027
|
+
if (process.env["NODE_ENV"] !== "test") {
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
1030
|
+
pendingByParentSpanId.clear();
|
|
1031
|
+
}
|
|
1032
|
+
var import_api8, INNER_OPERATION_IDS, MAX_PENDING_ENTRIES, pendingByParentSpanId, InterruptPropagator;
|
|
1033
|
+
var init_interrupt = __esm({
|
|
1034
|
+
"src/internal/instrumentation/vercel-ai/interrupt.ts"() {
|
|
1035
|
+
"use strict";
|
|
1036
|
+
import_api8 = require("@opentelemetry/api");
|
|
1037
|
+
init_semantic_conventions2();
|
|
1038
|
+
INNER_OPERATION_IDS = /* @__PURE__ */ new Set([
|
|
1039
|
+
"ai.generateText.doGenerate",
|
|
1040
|
+
"ai.streamText.doStream"
|
|
1041
|
+
]);
|
|
1042
|
+
MAX_PENDING_ENTRIES = 1024;
|
|
1043
|
+
pendingByParentSpanId = /* @__PURE__ */ new Map();
|
|
1044
|
+
InterruptPropagator = class {
|
|
1045
|
+
onStart(span, _parentContext) {
|
|
1046
|
+
if (!isInnerLLMSpan(span)) {
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
const parentSpanId = span.parentSpanContext?.spanId;
|
|
1050
|
+
if (!parentSpanId) {
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
const value = pendingByParentSpanId.get(parentSpanId);
|
|
1054
|
+
if (!value) {
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
span.setAttribute(INTERRUPT_TOOLS, value);
|
|
1058
|
+
pendingByParentSpanId.delete(parentSpanId);
|
|
1059
|
+
}
|
|
1060
|
+
onEnd() {
|
|
1061
|
+
}
|
|
1062
|
+
async shutdown() {
|
|
1063
|
+
}
|
|
1064
|
+
async forceFlush() {
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
|
|
977
1070
|
// src/index.ts
|
|
978
1071
|
var src_exports = {};
|
|
979
1072
|
__export(src_exports, {
|
|
@@ -1086,6 +1179,26 @@ function loadMCPInstrumentation() {
|
|
|
1086
1179
|
}
|
|
1087
1180
|
})();
|
|
1088
1181
|
}
|
|
1182
|
+
function loadVercelAIInterruptIntegration() {
|
|
1183
|
+
void (async () => {
|
|
1184
|
+
try {
|
|
1185
|
+
const ai = await import("ai");
|
|
1186
|
+
if (typeof ai.registerTelemetryIntegration !== "function") {
|
|
1187
|
+
logger.debug(
|
|
1188
|
+
"AI SDK present but lacks registerTelemetryIntegration (needs ai@>=6); skipping interrupt bridge"
|
|
1189
|
+
);
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
const { createInterruptIntegration: createInterruptIntegration2 } = await Promise.resolve().then(() => (init_interrupt(), interrupt_exports));
|
|
1193
|
+
ai.registerTelemetryIntegration(createInterruptIntegration2());
|
|
1194
|
+
logger.debug("Auto-loaded Vercel AI interrupt bridge");
|
|
1195
|
+
} catch (error) {
|
|
1196
|
+
logger.debug(
|
|
1197
|
+
`Vercel AI interrupt bridge not loaded (install ai@>=6 if you want HITL attribution): ${String(error)}`
|
|
1198
|
+
);
|
|
1199
|
+
}
|
|
1200
|
+
})();
|
|
1201
|
+
}
|
|
1089
1202
|
function autoInitializeInstrumentations() {
|
|
1090
1203
|
if (autoInstrumentationsLoaded) {
|
|
1091
1204
|
return;
|
|
@@ -1094,6 +1207,7 @@ function autoInitializeInstrumentations() {
|
|
|
1094
1207
|
const nodeInstrumentations = loadNodeAutoInstrumentations();
|
|
1095
1208
|
const genAIInstrumentations = loadGenAIInstrumentations();
|
|
1096
1209
|
loadMCPInstrumentation();
|
|
1210
|
+
loadVercelAIInterruptIntegration();
|
|
1097
1211
|
autoInstrumentationsLoaded = true;
|
|
1098
1212
|
logger.info(
|
|
1099
1213
|
`Auto-initialization complete: ${nodeInstrumentations.length} node + ${genAIInstrumentations.length} GenAI instrumentations`
|
|
@@ -1408,6 +1522,9 @@ var InstrumentationRegistry = class _InstrumentationRegistry {
|
|
|
1408
1522
|
}
|
|
1409
1523
|
};
|
|
1410
1524
|
|
|
1525
|
+
// src/internal/sdk.ts
|
|
1526
|
+
init_interrupt();
|
|
1527
|
+
|
|
1411
1528
|
// src/internal/log/logging.ts
|
|
1412
1529
|
var import_api_logs = require("@opentelemetry/api-logs");
|
|
1413
1530
|
var import_exporter_logs_otlp_http = require("@opentelemetry/exporter-logs-otlp-http");
|
|
@@ -1417,7 +1534,7 @@ init_logger();
|
|
|
1417
1534
|
init_version();
|
|
1418
1535
|
|
|
1419
1536
|
// src/internal/log/processors/log-processor.ts
|
|
1420
|
-
var
|
|
1537
|
+
var import_api9 = require("@opentelemetry/api");
|
|
1421
1538
|
var import_sdk_logs = require("@opentelemetry/sdk-logs");
|
|
1422
1539
|
init_logger();
|
|
1423
1540
|
|
|
@@ -1830,7 +1947,7 @@ function maskAttributes(attributes, rules, outputOriginalValue = false) {
|
|
|
1830
1947
|
}
|
|
1831
1948
|
|
|
1832
1949
|
// src/internal/log/processors/log-processor.ts
|
|
1833
|
-
|
|
1950
|
+
init_semantic_conventions2();
|
|
1834
1951
|
var DEFAULT_LOG_MASKING_RULES = [
|
|
1835
1952
|
{
|
|
1836
1953
|
mode: "partial",
|
|
@@ -1849,7 +1966,7 @@ var BrizzSimpleLogRecordProcessor = class extends import_sdk_logs.SimpleLogRecor
|
|
|
1849
1966
|
if (maskingConfig) {
|
|
1850
1967
|
maskLog(logRecord, maskingConfig);
|
|
1851
1968
|
}
|
|
1852
|
-
const associationProperties =
|
|
1969
|
+
const associationProperties = import_api9.context.active().getValue(PROPERTIES_CONTEXT_KEY);
|
|
1853
1970
|
if (associationProperties) {
|
|
1854
1971
|
for (const [key, value] of Object.entries(associationProperties)) {
|
|
1855
1972
|
logRecord.setAttribute(`${BRIZZ}.${key}`, value);
|
|
@@ -1869,7 +1986,7 @@ var BrizzBatchLogRecordProcessor = class extends import_sdk_logs.BatchLogRecordP
|
|
|
1869
1986
|
if (maskingConfig) {
|
|
1870
1987
|
maskLog(logRecord, maskingConfig);
|
|
1871
1988
|
}
|
|
1872
|
-
const associationProperties =
|
|
1989
|
+
const associationProperties = import_api9.context.active().getValue(PROPERTIES_CONTEXT_KEY);
|
|
1873
1990
|
if (associationProperties) {
|
|
1874
1991
|
for (const [key, value] of Object.entries(associationProperties)) {
|
|
1875
1992
|
logRecord.setAttribute(`${BRIZZ}.${key}`, value);
|
|
@@ -2269,12 +2386,12 @@ var BrizzSpanExporter = class {
|
|
|
2269
2386
|
};
|
|
2270
2387
|
|
|
2271
2388
|
// src/internal/trace/processors/span-processor.ts
|
|
2272
|
-
var
|
|
2389
|
+
var import_api10 = require("@opentelemetry/api");
|
|
2273
2390
|
var import_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
|
|
2274
2391
|
init_logger();
|
|
2275
|
-
|
|
2392
|
+
init_semantic_conventions2();
|
|
2276
2393
|
function applyContextAttributes(span) {
|
|
2277
|
-
const sessionProperties =
|
|
2394
|
+
const sessionProperties = import_api10.context.active().getValue(PROPERTIES_CONTEXT_KEY);
|
|
2278
2395
|
if (sessionProperties) {
|
|
2279
2396
|
for (const [key, value] of Object.entries(sessionProperties)) {
|
|
2280
2397
|
span.setAttribute(`${BRIZZ}.${key}`, value);
|
|
@@ -2460,10 +2577,10 @@ function getSpanProcessor() {
|
|
|
2460
2577
|
}
|
|
2461
2578
|
|
|
2462
2579
|
// src/internal/trace/session.ts
|
|
2463
|
-
var
|
|
2464
|
-
|
|
2580
|
+
var import_api11 = require("@opentelemetry/api");
|
|
2581
|
+
init_semantic_conventions2();
|
|
2465
2582
|
function setCurrentSpanCustomProperties(properties) {
|
|
2466
|
-
const current =
|
|
2583
|
+
const current = import_api11.trace.getActiveSpan();
|
|
2467
2584
|
if (!current || !current.isRecording()) {
|
|
2468
2585
|
return;
|
|
2469
2586
|
}
|
|
@@ -2475,11 +2592,11 @@ function setCurrentSpanCustomProperties(properties) {
|
|
|
2475
2592
|
}
|
|
2476
2593
|
}
|
|
2477
2594
|
function callWithProperties(properties, fn, thisArg, ...args) {
|
|
2478
|
-
const base =
|
|
2595
|
+
const base = import_api11.context.active();
|
|
2479
2596
|
const prev = base.getValue(PROPERTIES_CONTEXT_KEY);
|
|
2480
2597
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
2481
2598
|
const next = base.setValue(PROPERTIES_CONTEXT_KEY, merged);
|
|
2482
|
-
return
|
|
2599
|
+
return import_api11.context.with(next, fn, thisArg, ...args);
|
|
2483
2600
|
}
|
|
2484
2601
|
function withProperties(properties, fn, thisArg) {
|
|
2485
2602
|
return function wrapped(...args) {
|
|
@@ -2578,12 +2695,12 @@ var SessionTitle = class {
|
|
|
2578
2695
|
}
|
|
2579
2696
|
};
|
|
2580
2697
|
function getActiveSession() {
|
|
2581
|
-
return
|
|
2698
|
+
return import_api11.context.active().getValue(SESSION_OBJECT_CONTEXT_KEY);
|
|
2582
2699
|
}
|
|
2583
2700
|
function startSession(sessionId, callback, extraProperties, options) {
|
|
2584
2701
|
const isTitle = options?.mode === "title";
|
|
2585
2702
|
const spanName = isTitle ? SESSION_TITLE_SPAN_NAME : SESSION_SPAN_NAME;
|
|
2586
|
-
const tracer =
|
|
2703
|
+
const tracer = import_api11.trace.getTracer("@brizz/sdk");
|
|
2587
2704
|
return tracer.startActiveSpan(spanName, (span) => {
|
|
2588
2705
|
span.setAttribute(`${BRIZZ}.${SESSION_ID}`, sessionId);
|
|
2589
2706
|
if (extraProperties) {
|
|
@@ -2602,8 +2719,8 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
2602
2719
|
}
|
|
2603
2720
|
}
|
|
2604
2721
|
return callWithProperties(contextProperties, () => {
|
|
2605
|
-
const sessionCtx =
|
|
2606
|
-
return
|
|
2722
|
+
const sessionCtx = import_api11.context.active().setValue(SESSION_OBJECT_CONTEXT_KEY, session);
|
|
2723
|
+
return import_api11.context.with(sessionCtx, () => {
|
|
2607
2724
|
try {
|
|
2608
2725
|
const result = callback(session);
|
|
2609
2726
|
if (result && typeof result.then === "function") {
|
|
@@ -2612,7 +2729,7 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
2612
2729
|
return value;
|
|
2613
2730
|
}).catch((error) => {
|
|
2614
2731
|
span.recordException(error);
|
|
2615
|
-
span.setStatus({ code:
|
|
2732
|
+
span.setStatus({ code: import_api11.SpanStatusCode.ERROR });
|
|
2616
2733
|
span.end();
|
|
2617
2734
|
throw error;
|
|
2618
2735
|
});
|
|
@@ -2621,7 +2738,7 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
2621
2738
|
return result;
|
|
2622
2739
|
} catch (error) {
|
|
2623
2740
|
span.recordException(error);
|
|
2624
|
-
span.setStatus({ code:
|
|
2741
|
+
span.setStatus({ code: import_api11.SpanStatusCode.ERROR });
|
|
2625
2742
|
span.end();
|
|
2626
2743
|
throw error;
|
|
2627
2744
|
}
|
|
@@ -2631,7 +2748,7 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
2631
2748
|
}
|
|
2632
2749
|
function startSessionTitle(callback, options) {
|
|
2633
2750
|
const resolvedSessionId = options?.sessionId ?? getActiveSession()?.sessionId;
|
|
2634
|
-
const tracer =
|
|
2751
|
+
const tracer = import_api11.trace.getTracer("@brizz/sdk");
|
|
2635
2752
|
return tracer.startActiveSpan(SESSION_TITLE_SPAN_NAME, (span) => {
|
|
2636
2753
|
if (resolvedSessionId) {
|
|
2637
2754
|
span.setAttribute(`${BRIZZ}.${SESSION_ID}`, resolvedSessionId);
|
|
@@ -2650,7 +2767,7 @@ function startSessionTitle(callback, options) {
|
|
|
2650
2767
|
return value;
|
|
2651
2768
|
}).catch((error) => {
|
|
2652
2769
|
span.recordException(error);
|
|
2653
|
-
span.setStatus({ code:
|
|
2770
|
+
span.setStatus({ code: import_api11.SpanStatusCode.ERROR });
|
|
2654
2771
|
span.end();
|
|
2655
2772
|
throw error;
|
|
2656
2773
|
});
|
|
@@ -2659,7 +2776,7 @@ function startSessionTitle(callback, options) {
|
|
|
2659
2776
|
return result;
|
|
2660
2777
|
} catch (error) {
|
|
2661
2778
|
span.recordException(error);
|
|
2662
|
-
span.setStatus({ code:
|
|
2779
|
+
span.setStatus({ code: import_api11.SpanStatusCode.ERROR });
|
|
2663
2780
|
span.end();
|
|
2664
2781
|
throw error;
|
|
2665
2782
|
}
|
|
@@ -2751,7 +2868,7 @@ var _Brizz = class __Brizz {
|
|
|
2751
2868
|
resourceAttributes["service.version"] = resolvedConfig.appVersion;
|
|
2752
2869
|
}
|
|
2753
2870
|
this._sdk = new import_sdk_node.NodeSDK({
|
|
2754
|
-
spanProcessors: resolvedConfig.disableSpanExporter ? [] : [getSpanProcessor()],
|
|
2871
|
+
spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new InterruptPropagator(), getSpanProcessor()],
|
|
2755
2872
|
metricReader: getMetricsReader(),
|
|
2756
2873
|
resource: (0, import_resources3.resourceFromAttributes)(resourceAttributes),
|
|
2757
2874
|
instrumentations: manualInstrumentations
|
|
@@ -2947,4 +3064,3 @@ var init_exports = {};
|
|
|
2947
3064
|
withProperties,
|
|
2948
3065
|
withSessionId
|
|
2949
3066
|
});
|
|
2950
|
-
//# sourceMappingURL=index.cjs.map
|