@brizz/sdk 0.1.53 → 0.1.55
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 +39 -1
- package/dist/{chunk-TEY6FAVZ.js → chunk-B5IY6O4N.js} +7 -0
- package/dist/{chunk-STTOBCTP.cjs → chunk-CF4CXFQP.cjs} +1 -1
- package/dist/chunk-DC2MFO65.cjs +121 -0
- package/dist/{chunk-KFETJN5M.cjs → chunk-RD4XCYKT.cjs} +7 -0
- package/dist/chunk-TDPQDITP.js +121 -0
- package/dist/{chunk-XV3ZJO5K.js → chunk-WJZSFRB4.js} +1 -1
- package/dist/{google-genai-T7I4FFIP.js → google-genai-3ERJNC7Q.js} +2 -1
- package/dist/google-genai-GVCKSJMR.cjs +11 -0
- package/dist/google-genai.cjs +3 -2
- package/dist/google-genai.js +2 -1
- package/dist/index.cjs +236 -63
- package/dist/index.js +217 -44
- package/dist/{mcp-KH5LOG5H.cjs → mcp-CYQ3TGCK.cjs} +39 -16
- package/dist/{mcp-DBLN5ZBE.js → mcp-LLYYMR5M.js} +29 -6
- package/dist/types/cjs/index.d.ts +3 -3
- package/dist/types/cjs/internal/config.d.ts +2 -1
- package/dist/types/cjs/internal/instrumentation/langchain.d.ts +1 -1
- package/dist/types/cjs/internal/instrumentation/openai.d.ts +5 -0
- package/dist/types/cjs/internal/instrumentation/vercel-ai/interrupt.d.ts +1 -1
- package/dist/types/cjs/internal/log/logging.d.ts +6 -5
- package/dist/types/cjs/internal/log/processors/log-processor.d.ts +4 -4
- package/dist/types/cjs/internal/metric/metrics.d.ts +1 -0
- package/dist/types/cjs/internal/sdk.d.ts +4 -1
- package/dist/types/cjs/internal/trace/exporters/eve-trace-exporter.d.ts +1 -1
- package/dist/types/cjs/internal/trace/exporters/span-exporter.d.ts +1 -1
- package/dist/types/cjs/internal/trace/index.d.ts +1 -0
- package/dist/types/cjs/internal/trace/processors/eve-session-processor.d.ts +1 -1
- package/dist/types/cjs/internal/trace/processors/span-processor.d.ts +1 -1
- package/dist/types/cjs/internal/trace/provider.d.ts +16 -0
- package/dist/types/cjs/internal/trace/tracing.d.ts +3 -2
- package/dist/types/esm/index.d.ts +3 -3
- package/dist/types/esm/internal/config.d.ts +2 -1
- package/dist/types/esm/internal/instrumentation/langchain.d.ts +1 -1
- package/dist/types/esm/internal/instrumentation/openai.d.ts +5 -0
- package/dist/types/esm/internal/instrumentation/vercel-ai/interrupt.d.ts +1 -1
- package/dist/types/esm/internal/log/logging.d.ts +6 -5
- package/dist/types/esm/internal/log/processors/log-processor.d.ts +4 -4
- package/dist/types/esm/internal/metric/metrics.d.ts +1 -0
- package/dist/types/esm/internal/sdk.d.ts +4 -1
- package/dist/types/esm/internal/trace/exporters/eve-trace-exporter.d.ts +1 -1
- package/dist/types/esm/internal/trace/exporters/span-exporter.d.ts +1 -1
- package/dist/types/esm/internal/trace/index.d.ts +1 -0
- package/dist/types/esm/internal/trace/processors/eve-session-processor.d.ts +1 -1
- package/dist/types/esm/internal/trace/processors/span-processor.d.ts +1 -1
- package/dist/types/esm/internal/trace/provider.d.ts +16 -0
- package/dist/types/esm/internal/trace/tracing.d.ts +3 -2
- package/package.json +29 -30
- package/dist/google-genai-LMEZ62FB.cjs +0 -10
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,17 @@ var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkCF4CXFQPcjs = require('./chunk-CF4CXFQP.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var _chunkDC2MFO65cjs = require('./chunk-DC2MFO65.cjs');
|
|
9
19
|
|
|
10
20
|
|
|
11
21
|
|
|
@@ -83,7 +93,6 @@ var _chunkRV7JIIDGcjs = require('./chunk-RV7JIIDG.cjs');
|
|
|
83
93
|
var _chunkOBGZSXTJcjs = require('./chunk-OBGZSXTJ.cjs');
|
|
84
94
|
|
|
85
95
|
// src/internal/instrumentation/auto-init.ts
|
|
86
|
-
var _openinferenceinstrumentationopenai = require('@arizeai/openinference-instrumentation-openai');
|
|
87
96
|
var _instrumentation = require('@opentelemetry/instrumentation');
|
|
88
97
|
var _instrumentationanthropic = require('@traceloop/instrumentation-anthropic');
|
|
89
98
|
var _instrumentationbedrock = require('@traceloop/instrumentation-bedrock');
|
|
@@ -104,7 +113,7 @@ var _api = require('@opentelemetry/api');
|
|
|
104
113
|
|
|
105
114
|
// src/internal/instrumentation/langgraph/attributes.ts
|
|
106
115
|
var INSTRUMENTATION_NAME = "@brizz/sdk/langgraph";
|
|
107
|
-
var INSTRUMENTATION_VERSION =
|
|
116
|
+
var INSTRUMENTATION_VERSION = _chunkCF4CXFQPcjs.getSDKVersion.call(void 0, );
|
|
108
117
|
var MODULE_NAME = "@langchain/langgraph";
|
|
109
118
|
var SUPPORTED_VERSIONS = [">=0.2.0 <2"];
|
|
110
119
|
function isSupportedVersion(version) {
|
|
@@ -174,6 +183,7 @@ var parentRecorded = /* @__PURE__ */ new WeakSet();
|
|
|
174
183
|
var LangGraphInstrumentation = class extends _instrumentation.InstrumentationBase {
|
|
175
184
|
constructor(config = {}) {
|
|
176
185
|
super(INSTRUMENTATION_NAME, INSTRUMENTATION_VERSION, config);
|
|
186
|
+
this.setTracerProvider(_chunkDC2MFO65cjs.brizzTracerProvider);
|
|
177
187
|
}
|
|
178
188
|
init() {
|
|
179
189
|
return [
|
|
@@ -426,6 +436,14 @@ function attachRunToIteration(stream, run) {
|
|
|
426
436
|
return iterable;
|
|
427
437
|
}
|
|
428
438
|
|
|
439
|
+
// src/internal/instrumentation/openai.ts
|
|
440
|
+
var _openinferenceinstrumentationopenai = require('@arizeai/openinference-instrumentation-openai');
|
|
441
|
+
var BrizzOpenAIInstrumentation = class extends _openinferenceinstrumentationopenai.OpenAIInstrumentation {
|
|
442
|
+
get tracer() {
|
|
443
|
+
return _chunkDC2MFO65cjs.brizzTracerProvider.getTracer(this.instrumentationName, this.instrumentationVersion);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
|
|
429
447
|
// src/internal/instrumentation/typesafe.ts
|
|
430
448
|
|
|
431
449
|
|
|
@@ -451,7 +469,8 @@ var ATTR_ANSWERS = "typesafe.answers";
|
|
|
451
469
|
var PATCHED_FLAG2 = /* @__PURE__ */ Symbol.for("brizz.typesafe.patched");
|
|
452
470
|
var TypeSafeInstrumentation = class extends _instrumentation.InstrumentationBase {
|
|
453
471
|
constructor(config = {}) {
|
|
454
|
-
super(INSTRUMENTATION_NAME2,
|
|
472
|
+
super(INSTRUMENTATION_NAME2, _chunkCF4CXFQPcjs.getSDKVersion.call(void 0, ), config);
|
|
473
|
+
this.setTracerProvider(_chunkDC2MFO65cjs.brizzTracerProvider);
|
|
455
474
|
}
|
|
456
475
|
init() {
|
|
457
476
|
return [
|
|
@@ -644,7 +663,7 @@ var exceptionLogger = (error) => {
|
|
|
644
663
|
function loadGenAIInstrumentations() {
|
|
645
664
|
const instrumentations = [];
|
|
646
665
|
try {
|
|
647
|
-
instrumentations.push(new (
|
|
666
|
+
instrumentations.push(new BrizzOpenAIInstrumentation());
|
|
648
667
|
_chunkWC573FCIcjs.logger.debug("Auto-loaded OpenAI instrumentation");
|
|
649
668
|
} catch (error) {
|
|
650
669
|
_chunkWC573FCIcjs.logger.error(`Failed to auto-load OpenAI instrumentation: ${String(error)}`);
|
|
@@ -669,7 +688,7 @@ function loadGenAIInstrumentations() {
|
|
|
669
688
|
}
|
|
670
689
|
}
|
|
671
690
|
try {
|
|
672
|
-
_instrumentation.registerInstrumentations.call(void 0, { instrumentations });
|
|
691
|
+
_instrumentation.registerInstrumentations.call(void 0, { instrumentations, tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider });
|
|
673
692
|
_chunkWC573FCIcjs.logger.info(`Auto-registered ${instrumentations.length} GenAI instrumentations`);
|
|
674
693
|
} catch (error) {
|
|
675
694
|
_chunkWC573FCIcjs.logger.error(`Failed to register GenAI instrumentations: ${String(error)}`);
|
|
@@ -679,9 +698,9 @@ function loadGenAIInstrumentations() {
|
|
|
679
698
|
function loadMCPInstrumentation() {
|
|
680
699
|
void (async () => {
|
|
681
700
|
try {
|
|
682
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
701
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-CYQ3TGCK.cjs")));
|
|
683
702
|
const mcp = new MCPInstrumentation({ exceptionLogger });
|
|
684
|
-
_instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp] });
|
|
703
|
+
_instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp], tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider });
|
|
685
704
|
_chunkWC573FCIcjs.logger.debug("Auto-loaded MCP instrumentation");
|
|
686
705
|
} catch (error) {
|
|
687
706
|
_chunkWC573FCIcjs.logger.debug(
|
|
@@ -692,7 +711,10 @@ function loadMCPInstrumentation() {
|
|
|
692
711
|
}
|
|
693
712
|
function loadLangGraphInstrumentation() {
|
|
694
713
|
try {
|
|
695
|
-
_instrumentation.registerInstrumentations.call(void 0, {
|
|
714
|
+
_instrumentation.registerInstrumentations.call(void 0, {
|
|
715
|
+
instrumentations: [new LangGraphInstrumentation()],
|
|
716
|
+
tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider
|
|
717
|
+
});
|
|
696
718
|
_chunkWC573FCIcjs.logger.debug("Auto-loaded LangGraph instrumentation");
|
|
697
719
|
} catch (error) {
|
|
698
720
|
_chunkWC573FCIcjs.logger.debug(`LangGraph instrumentation not loaded: ${String(error)}`);
|
|
@@ -700,7 +722,10 @@ function loadLangGraphInstrumentation() {
|
|
|
700
722
|
}
|
|
701
723
|
function loadTypeSafeInstrumentation() {
|
|
702
724
|
try {
|
|
703
|
-
_instrumentation.registerInstrumentations.call(void 0, {
|
|
725
|
+
_instrumentation.registerInstrumentations.call(void 0, {
|
|
726
|
+
instrumentations: [new TypeSafeInstrumentation()],
|
|
727
|
+
tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider
|
|
728
|
+
});
|
|
704
729
|
_chunkWC573FCIcjs.logger.debug("Auto-loaded TypeSafe instrumentation");
|
|
705
730
|
} catch (error) {
|
|
706
731
|
_chunkWC573FCIcjs.logger.debug(`TypeSafe instrumentation not loaded: ${String(error)}`);
|
|
@@ -711,7 +736,10 @@ function loadVertexAIInstrumentation() {
|
|
|
711
736
|
try {
|
|
712
737
|
const { VertexAIInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("@traceloop/instrumentation-vertexai")));
|
|
713
738
|
const vertexAI = new VertexAIInstrumentation({ exceptionLogger });
|
|
714
|
-
_instrumentation.registerInstrumentations.call(void 0, {
|
|
739
|
+
_instrumentation.registerInstrumentations.call(void 0, {
|
|
740
|
+
instrumentations: [vertexAI],
|
|
741
|
+
tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider
|
|
742
|
+
});
|
|
715
743
|
_chunkWC573FCIcjs.logger.debug("Auto-loaded Vertex AI instrumentation");
|
|
716
744
|
} catch (error) {
|
|
717
745
|
_chunkWC573FCIcjs.logger.debug(
|
|
@@ -723,9 +751,12 @@ function loadVertexAIInstrumentation() {
|
|
|
723
751
|
function loadGoogleGenAIInstrumentation() {
|
|
724
752
|
void (async () => {
|
|
725
753
|
try {
|
|
726
|
-
const { GoogleGenAIInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./google-genai-
|
|
754
|
+
const { GoogleGenAIInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./google-genai-GVCKSJMR.cjs")));
|
|
727
755
|
const googleGenAI = new GoogleGenAIInstrumentation({ exceptionLogger });
|
|
728
|
-
_instrumentation.registerInstrumentations.call(void 0, {
|
|
756
|
+
_instrumentation.registerInstrumentations.call(void 0, {
|
|
757
|
+
instrumentations: [googleGenAI],
|
|
758
|
+
tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider
|
|
759
|
+
});
|
|
729
760
|
_chunkWC573FCIcjs.logger.debug("Auto-loaded Google GenAI instrumentation");
|
|
730
761
|
} catch (error) {
|
|
731
762
|
_chunkWC573FCIcjs.logger.debug(
|
|
@@ -757,7 +788,9 @@ function loadVercelAITelemetry() {
|
|
|
757
788
|
try {
|
|
758
789
|
const otel = await Promise.resolve().then(() => _interopRequireWildcard(require("@ai-sdk/otel")));
|
|
759
790
|
if (typeof otel.LegacyOpenTelemetry === "function") {
|
|
760
|
-
integrations.push(
|
|
791
|
+
integrations.push(
|
|
792
|
+
new otel.LegacyOpenTelemetry({ tracer: _chunkDC2MFO65cjs.brizzTracerProvider.getTracer("ai") })
|
|
793
|
+
);
|
|
761
794
|
otelCollectorLoaded = true;
|
|
762
795
|
}
|
|
763
796
|
} catch (e) {
|
|
@@ -811,9 +844,22 @@ var autoInstrumentationsLoaded = autoInitializeInstrumentations();
|
|
|
811
844
|
|
|
812
845
|
var _resources2 = require('@opentelemetry/resources');
|
|
813
846
|
var _sdkmetrics = require('@opentelemetry/sdk-metrics');
|
|
814
|
-
var
|
|
847
|
+
var _sdktrace = require('@opentelemetry/sdk-trace');
|
|
848
|
+
|
|
815
849
|
|
|
816
850
|
// src/internal/config.ts
|
|
851
|
+
function parseBoolEnv(name) {
|
|
852
|
+
const raw = process.env[name];
|
|
853
|
+
if (raw === void 0) {
|
|
854
|
+
return void 0;
|
|
855
|
+
}
|
|
856
|
+
const value = raw.trim().toLowerCase();
|
|
857
|
+
if (value === "true" || value === "false") {
|
|
858
|
+
return value === "true";
|
|
859
|
+
}
|
|
860
|
+
_chunkWC573FCIcjs.logger.warn(`Brizz: ignoring ${name}=${raw}; expected true or false.`);
|
|
861
|
+
return void 0;
|
|
862
|
+
}
|
|
817
863
|
function resolveConfig(options) {
|
|
818
864
|
const envLogLevel = process.env["BRIZZ_LOG_LEVEL"] || _optionalChain([options, 'access', _28 => _28.logLevel, 'optionalAccess', _29 => _29.toString, 'call', _30 => _30()]) || _chunkWC573FCIcjs.DEFAULT_LOG_LEVEL.toString();
|
|
819
865
|
let resolvedLogLevel;
|
|
@@ -865,7 +911,8 @@ function resolveConfig(options) {
|
|
|
865
911
|
disableSpanExporter: process.env["BRIZZ_DISABLE_SPAN_EXPORTER"] === "true" || !!options.disableSpanExporter,
|
|
866
912
|
environment: process.env["BRIZZ_ENVIRONMENT"] || options.environment,
|
|
867
913
|
logLevel: resolvedLogLevel,
|
|
868
|
-
masking: resolvedMasking
|
|
914
|
+
masking: resolvedMasking,
|
|
915
|
+
setGlobalTracerProvider: _nullishCoalesce(_nullishCoalesce(parseBoolEnv("BRIZZ_SET_GLOBAL_TRACER_PROVIDER"), () => ( options.setGlobalTracerProvider)), () => ( true))
|
|
869
916
|
};
|
|
870
917
|
const dsnInput = process.env["BRIZZ_DSN"] || options.dsn;
|
|
871
918
|
let parsedDSN = null;
|
|
@@ -935,6 +982,7 @@ function resolveConfig(options) {
|
|
|
935
982
|
hasApiKey: !!resolvedConfig.apiKey,
|
|
936
983
|
dsnProvided: !!dsnInput,
|
|
937
984
|
disableBatch: resolvedConfig.disableBatch,
|
|
985
|
+
setGlobalTracerProvider: resolvedConfig.setGlobalTracerProvider,
|
|
938
986
|
envOverrides: {
|
|
939
987
|
hasEnvApiKey: !!process.env["BRIZZ_API_KEY"],
|
|
940
988
|
hasEnvBaseUrl: !!process.env["BRIZZ_BASE_URL"],
|
|
@@ -961,7 +1009,6 @@ var SDK_LANGUAGE = "typescript";
|
|
|
961
1009
|
|
|
962
1010
|
|
|
963
1011
|
|
|
964
|
-
|
|
965
1012
|
// src/internal/instrumentation/langchain.ts
|
|
966
1013
|
|
|
967
1014
|
|
|
@@ -1101,9 +1148,11 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1101
1148
|
*/
|
|
1102
1149
|
loadInstrumentation(InstrumentationClass, name, manualModule, exceptionLogger2) {
|
|
1103
1150
|
try {
|
|
1104
|
-
const inst =
|
|
1105
|
-
|
|
1106
|
-
|
|
1151
|
+
const inst = _chunkDC2MFO65cjs.bindToBrizz.call(void 0,
|
|
1152
|
+
new InstrumentationClass({
|
|
1153
|
+
exceptionLogger: exceptionLogger2 || ((error) => _chunkWC573FCIcjs.logger.error(`Exception in instrumentation: ${String(error)}`))
|
|
1154
|
+
})
|
|
1155
|
+
);
|
|
1107
1156
|
if (manualModule) {
|
|
1108
1157
|
inst.manuallyInstrument(manualModule);
|
|
1109
1158
|
_chunkWC573FCIcjs.logger.debug(`Manual instrumentation enabled for ${name}`);
|
|
@@ -1121,7 +1170,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1121
1170
|
loadManualInstrumentations(instrumentations, exceptionLogger2) {
|
|
1122
1171
|
if (_optionalChain([this, 'access', _34 => _34.manualModules, 'optionalAccess', _35 => _35.openAI])) {
|
|
1123
1172
|
try {
|
|
1124
|
-
const openAIInst = new (
|
|
1173
|
+
const openAIInst = new BrizzOpenAIInstrumentation();
|
|
1125
1174
|
openAIInst.manuallyInstrument(this.manualModules.openAI);
|
|
1126
1175
|
instrumentations.push(openAIInst);
|
|
1127
1176
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for OpenAI");
|
|
@@ -1162,7 +1211,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1162
1211
|
void (async () => {
|
|
1163
1212
|
try {
|
|
1164
1213
|
const { LangChainInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("@arizeai/openinference-instrumentation-langchain")));
|
|
1165
|
-
const lcInst = new LangChainInstrumentation();
|
|
1214
|
+
const lcInst = new LangChainInstrumentation({ tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider });
|
|
1166
1215
|
lcInst.manuallyInstrument(callbackManagerModule);
|
|
1167
1216
|
patchCallbackManagerModule(callbackManagerModule);
|
|
1168
1217
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for LangChain");
|
|
@@ -1194,7 +1243,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1194
1243
|
void (async () => {
|
|
1195
1244
|
try {
|
|
1196
1245
|
const { VertexAIInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("@traceloop/instrumentation-vertexai")));
|
|
1197
|
-
const vertexInst = new VertexAIInstrumentation({ exceptionLogger: exceptionLogger2 });
|
|
1246
|
+
const vertexInst = _chunkDC2MFO65cjs.bindToBrizz.call(void 0, new VertexAIInstrumentation({ exceptionLogger: exceptionLogger2 }));
|
|
1198
1247
|
vertexInst.manuallyInstrument(vertexModule);
|
|
1199
1248
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for Vertex AI");
|
|
1200
1249
|
} catch (error) {
|
|
@@ -1208,7 +1257,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1208
1257
|
const genaiModule = this.manualModules.google_genai;
|
|
1209
1258
|
void (async () => {
|
|
1210
1259
|
try {
|
|
1211
|
-
const { GoogleGenAIInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./google-genai-
|
|
1260
|
+
const { GoogleGenAIInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./google-genai-GVCKSJMR.cjs")));
|
|
1212
1261
|
const genaiInst = new GoogleGenAIInstrumentation({ exceptionLogger: exceptionLogger2 });
|
|
1213
1262
|
genaiInst.manuallyInstrument(genaiModule);
|
|
1214
1263
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for Google GenAI");
|
|
@@ -1223,7 +1272,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1223
1272
|
const mcpModules = this.manualModules.mcp;
|
|
1224
1273
|
void (async () => {
|
|
1225
1274
|
try {
|
|
1226
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
1275
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-CYQ3TGCK.cjs")));
|
|
1227
1276
|
const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
|
|
1228
1277
|
instrumentation.manuallyInstrument(mcpModules);
|
|
1229
1278
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
|
|
@@ -1260,13 +1309,14 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1260
1309
|
}, _class);
|
|
1261
1310
|
|
|
1262
1311
|
// src/internal/log/logging.ts
|
|
1263
|
-
|
|
1312
|
+
|
|
1264
1313
|
var _exporterlogsotlphttp = require('@opentelemetry/exporter-logs-otlp-http');
|
|
1265
1314
|
|
|
1266
1315
|
var _sdklogs = require('@opentelemetry/sdk-logs');
|
|
1267
1316
|
|
|
1268
1317
|
// src/internal/trace/session.ts
|
|
1269
1318
|
|
|
1319
|
+
var sessionTracer = _chunkDC2MFO65cjs.brizzTracerProvider.getTracer("@brizz/sdk");
|
|
1270
1320
|
function setCurrentSpanCustomProperties(properties) {
|
|
1271
1321
|
const current = _api.trace.getActiveSpan();
|
|
1272
1322
|
if (!current || !current.isRecording()) {
|
|
@@ -1898,8 +1948,7 @@ function recordMetricImpl(options) {
|
|
|
1898
1948
|
function startSession(sessionId, callback, extraProperties, options) {
|
|
1899
1949
|
const isTitle = _optionalChain([options, 'optionalAccess', _89 => _89.mode]) === "title";
|
|
1900
1950
|
const spanName = isTitle ? _chunkRV7JIIDGcjs.SESSION_TITLE_SPAN_NAME : _chunkRV7JIIDGcjs.SESSION_SPAN_NAME;
|
|
1901
|
-
|
|
1902
|
-
return tracer.startActiveSpan(spanName, (span) => {
|
|
1951
|
+
return sessionTracer.startActiveSpan(spanName, (span) => {
|
|
1903
1952
|
span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.SESSION_ID}`, sessionId);
|
|
1904
1953
|
if (extraProperties) {
|
|
1905
1954
|
for (const [key, value] of Object.entries(extraProperties)) {
|
|
@@ -1946,8 +1995,7 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
1946
1995
|
}
|
|
1947
1996
|
function startSessionTitle(callback, options) {
|
|
1948
1997
|
const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _90 => _90.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _91 => _91(), 'optionalAccess', _92 => _92.sessionId])));
|
|
1949
|
-
|
|
1950
|
-
return tracer.startActiveSpan(_chunkRV7JIIDGcjs.SESSION_TITLE_SPAN_NAME, (span) => {
|
|
1998
|
+
return sessionTracer.startActiveSpan(_chunkRV7JIIDGcjs.SESSION_TITLE_SPAN_NAME, (span) => {
|
|
1951
1999
|
if (resolvedSessionId) {
|
|
1952
2000
|
span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.SESSION_ID}`, resolvedSessionId);
|
|
1953
2001
|
}
|
|
@@ -2547,7 +2595,7 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
|
|
|
2547
2595
|
const resourceAttributes = {
|
|
2548
2596
|
...config.resourceAttributes,
|
|
2549
2597
|
"service.name": serviceName,
|
|
2550
|
-
[BRIZZ_SDK_VERSION]:
|
|
2598
|
+
[BRIZZ_SDK_VERSION]: _chunkCF4CXFQPcjs.getSDKVersion.call(void 0, ),
|
|
2551
2599
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2552
2600
|
};
|
|
2553
2601
|
if (config.environment) {
|
|
@@ -2594,7 +2642,7 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
|
|
|
2594
2642
|
/**
|
|
2595
2643
|
* Emit a custom event to the telemetry pipeline
|
|
2596
2644
|
*/
|
|
2597
|
-
emitEvent(name, attributes, body, severityNumber =
|
|
2645
|
+
emitEvent(name, attributes, body, severityNumber = _api.SeverityNumber.INFO) {
|
|
2598
2646
|
_chunkWC573FCIcjs.logger.debug("Attempting to emit event", {
|
|
2599
2647
|
name,
|
|
2600
2648
|
hasAttributes: !!attributes,
|
|
@@ -2646,6 +2694,11 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
|
|
|
2646
2694
|
getLoggerProvider() {
|
|
2647
2695
|
return this.loggerProvider;
|
|
2648
2696
|
}
|
|
2697
|
+
async forceFlush() {
|
|
2698
|
+
await Promise.all(
|
|
2699
|
+
[...this.scopedProviders.values(), this.loggerProvider].map(async (p) => _optionalChain([p, 'optionalAccess', _101 => _101.forceFlush, 'call', _102 => _102()]))
|
|
2700
|
+
);
|
|
2701
|
+
}
|
|
2649
2702
|
/**
|
|
2650
2703
|
* Shutdown the logging module
|
|
2651
2704
|
*/
|
|
@@ -2664,10 +2717,10 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
|
|
|
2664
2717
|
_chunkWC573FCIcjs.logger.debug("Logging module shutdown completed");
|
|
2665
2718
|
}
|
|
2666
2719
|
}, _class3.__initStatic(), _class3);
|
|
2667
|
-
function emitEvent(name, attributes, body, severityNumber =
|
|
2720
|
+
function emitEvent(name, attributes, body, severityNumber = _api.SeverityNumber.INFO) {
|
|
2668
2721
|
return LoggingModule.getInstance().emitEvent(name, attributes, body, severityNumber);
|
|
2669
2722
|
}
|
|
2670
|
-
function emitEventWithSessionId(sessionId, name, attributes, body, severityNumber =
|
|
2723
|
+
function emitEventWithSessionId(sessionId, name, attributes, body, severityNumber = _api.SeverityNumber.INFO) {
|
|
2671
2724
|
return callWithSessionId(sessionId, () => {
|
|
2672
2725
|
LoggingModule.getInstance().emitEvent(name, attributes, body, severityNumber);
|
|
2673
2726
|
});
|
|
@@ -2755,6 +2808,9 @@ var MetricsModule = (_class4 = class _MetricsModule {constructor() { _class4.pro
|
|
|
2755
2808
|
}
|
|
2756
2809
|
return this.metricsReader;
|
|
2757
2810
|
}
|
|
2811
|
+
async forceFlush() {
|
|
2812
|
+
await _optionalChain([this, 'access', _103 => _103.metricsReader, 'optionalAccess', _104 => _104.forceFlush, 'call', _105 => _105()]);
|
|
2813
|
+
}
|
|
2758
2814
|
/**
|
|
2759
2815
|
* Shutdown the metrics module
|
|
2760
2816
|
*/
|
|
@@ -2796,7 +2852,7 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2796
2852
|
const resourceAttrs = {
|
|
2797
2853
|
...config.resourceAttributes,
|
|
2798
2854
|
"service.name": config.appName,
|
|
2799
|
-
[BRIZZ_SDK_VERSION]:
|
|
2855
|
+
[BRIZZ_SDK_VERSION]: _chunkCF4CXFQPcjs.getSDKVersion.call(void 0, ),
|
|
2800
2856
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2801
2857
|
};
|
|
2802
2858
|
if (config.environment) {
|
|
@@ -2923,8 +2979,8 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2923
2979
|
}
|
|
2924
2980
|
async forceFlush() {
|
|
2925
2981
|
await Promise.all([
|
|
2926
|
-
_optionalChain([this, 'access',
|
|
2927
|
-
...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access',
|
|
2982
|
+
_optionalChain([this, 'access', _106 => _106._delegate, 'access', _107 => _107.forceFlush, 'optionalCall', _108 => _108()]),
|
|
2983
|
+
...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access', _109 => _109.forceFlush, 'optionalCall', _110 => _110()]))
|
|
2928
2984
|
]);
|
|
2929
2985
|
}
|
|
2930
2986
|
}, _class5);
|
|
@@ -2934,7 +2990,7 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2934
2990
|
|
|
2935
2991
|
|
|
2936
2992
|
|
|
2937
|
-
|
|
2993
|
+
|
|
2938
2994
|
function applyContextAttributes(span) {
|
|
2939
2995
|
const sessionProperties = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
|
|
2940
2996
|
if (sessionProperties) {
|
|
@@ -2956,7 +3012,10 @@ var LIBRARY_ID_ATTRIBUTES = [
|
|
|
2956
3012
|
"langsmith.metadata.thread_id",
|
|
2957
3013
|
"langsmith.metadata.session_id",
|
|
2958
3014
|
"langsmith.metadata.conversation_id",
|
|
2959
|
-
"langsmith.trace.session_id"
|
|
3015
|
+
"langsmith.trace.session_id",
|
|
3016
|
+
// User-id aliases the streamer copies into brizz.user.id (userIDAliases).
|
|
3017
|
+
"user.id",
|
|
3018
|
+
"langfuse.user.id"
|
|
2960
3019
|
];
|
|
2961
3020
|
var DEFAULT_RULE_ATTRIBUTES = String.raw`^(?!brizz\.(?!session\.(?:input|output)(?:\.context)?$|session\.title$|internal\.intent$)` + `|(?:${LIBRARY_ID_ATTRIBUTES.map((key) => key.replaceAll(".", String.raw`\.`)).join("|")})$)`;
|
|
2962
3021
|
var isText = (value) => typeof value === "string" || Array.isArray(value) && value.some((item) => typeof item === "string");
|
|
@@ -2967,10 +3026,10 @@ var DEFAULT_MASKING_RULES = [
|
|
|
2967
3026
|
patterns: DEFAULT_PII_PATTERNS
|
|
2968
3027
|
}
|
|
2969
3028
|
];
|
|
2970
|
-
var BrizzSimpleSpanProcessor = class extends
|
|
3029
|
+
var BrizzSimpleSpanProcessor = class extends _sdktrace.SimpleSpanProcessor {
|
|
2971
3030
|
|
|
2972
3031
|
constructor(spanExporter, config) {
|
|
2973
|
-
super(spanExporter);
|
|
3032
|
+
super({ exporter: spanExporter });
|
|
2974
3033
|
this.config = config;
|
|
2975
3034
|
}
|
|
2976
3035
|
onStart(span, parentContext) {
|
|
@@ -2979,17 +3038,17 @@ var BrizzSimpleSpanProcessor = class extends _sdktracebase.SimpleSpanProcessor {
|
|
|
2979
3038
|
}
|
|
2980
3039
|
onEnd(span) {
|
|
2981
3040
|
restampLangChainSpan(span);
|
|
2982
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
3041
|
+
const maskingConfig = _optionalChain([this, 'access', _111 => _111.config, 'access', _112 => _112.masking, 'optionalAccess', _113 => _113.spanMasking]);
|
|
2983
3042
|
if (maskingConfig) {
|
|
2984
3043
|
maskReadableSpan(span, maskingConfig);
|
|
2985
3044
|
}
|
|
2986
3045
|
super.onEnd(span);
|
|
2987
3046
|
}
|
|
2988
3047
|
};
|
|
2989
|
-
var BrizzBatchSpanProcessor = class extends
|
|
3048
|
+
var BrizzBatchSpanProcessor = class extends _sdktrace.BatchSpanProcessor {
|
|
2990
3049
|
|
|
2991
3050
|
constructor(spanExporter, config) {
|
|
2992
|
-
super(spanExporter);
|
|
3051
|
+
super({ exporter: spanExporter });
|
|
2993
3052
|
this.config = config;
|
|
2994
3053
|
}
|
|
2995
3054
|
onStart(span, parentContext) {
|
|
@@ -2998,7 +3057,7 @@ var BrizzBatchSpanProcessor = class extends _sdktracebase.BatchSpanProcessor {
|
|
|
2998
3057
|
}
|
|
2999
3058
|
onEnd(span) {
|
|
3000
3059
|
restampLangChainSpan(span);
|
|
3001
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
3060
|
+
const maskingConfig = _optionalChain([this, 'access', _114 => _114.config, 'access', _115 => _115.masking, 'optionalAccess', _116 => _116.spanMasking]);
|
|
3002
3061
|
if (maskingConfig) {
|
|
3003
3062
|
maskReadableSpan(span, maskingConfig);
|
|
3004
3063
|
}
|
|
@@ -3015,7 +3074,7 @@ function maskReadableSpan(span, config) {
|
|
|
3015
3074
|
for (const [k, v] of Object.entries(attrs)) {
|
|
3016
3075
|
masked[k] = v;
|
|
3017
3076
|
}
|
|
3018
|
-
if (_optionalChain([config, 'access',
|
|
3077
|
+
if (_optionalChain([config, 'access', _117 => _117.rules, 'optionalAccess', _118 => _118.length])) {
|
|
3019
3078
|
masked = maskAttributes(masked, config.rules);
|
|
3020
3079
|
}
|
|
3021
3080
|
if (!config.disableDefaultRules) {
|
|
@@ -3087,7 +3146,7 @@ var TracingModule = (_class6 = class _TracingModule {constructor() { _class6.pro
|
|
|
3087
3146
|
}
|
|
3088
3147
|
_chunkWC573FCIcjs.logger.debug("Initializing span processor", {
|
|
3089
3148
|
disableBatch: config.disableBatch,
|
|
3090
|
-
hasMasking: !!_optionalChain([config, 'access',
|
|
3149
|
+
hasMasking: !!_optionalChain([config, 'access', _119 => _119.masking, 'optionalAccess', _120 => _120.spanMasking])
|
|
3091
3150
|
});
|
|
3092
3151
|
const spanProcessor = config.disableBatch ? new BrizzSimpleSpanProcessor(this.spanExporter, config) : new BrizzBatchSpanProcessor(this.spanExporter, config);
|
|
3093
3152
|
_chunkWC573FCIcjs.logger.debug("Span processor initialized successfully");
|
|
@@ -3130,6 +3189,9 @@ var TracingModule = (_class6 = class _TracingModule {constructor() { _class6.pro
|
|
|
3130
3189
|
}
|
|
3131
3190
|
return this.spanProcessor;
|
|
3132
3191
|
}
|
|
3192
|
+
async forceFlush() {
|
|
3193
|
+
await _optionalChain([this, 'access', _121 => _121.spanProcessor, 'optionalAccess', _122 => _122.forceFlush, 'call', _123 => _123()]);
|
|
3194
|
+
}
|
|
3133
3195
|
async shutdown() {
|
|
3134
3196
|
_chunkWC573FCIcjs.logger.debug("Shutting down tracing module");
|
|
3135
3197
|
if (this.spanProcessor) {
|
|
@@ -3173,7 +3235,7 @@ function encodeToken(agent) {
|
|
|
3173
3235
|
function currentTraceparent() {
|
|
3174
3236
|
const carrier = {};
|
|
3175
3237
|
try {
|
|
3176
|
-
|
|
3238
|
+
_chunkDC2MFO65cjs.injectTraceContext.call(void 0, _api.context.active(), carrier);
|
|
3177
3239
|
} catch (e6) {
|
|
3178
3240
|
}
|
|
3179
3241
|
return _nullishCoalesce(carrier["traceparent"], () => ( ""));
|
|
@@ -3234,7 +3296,7 @@ function resolveAgent(agent) {
|
|
|
3234
3296
|
sessionId = decoded.sessionId;
|
|
3235
3297
|
if (decoded.traceparent) {
|
|
3236
3298
|
try {
|
|
3237
|
-
parentContext =
|
|
3299
|
+
parentContext = _chunkDC2MFO65cjs.extractTraceContext.call(void 0, parentContext, { traceparent: decoded.traceparent });
|
|
3238
3300
|
} catch (e8) {
|
|
3239
3301
|
}
|
|
3240
3302
|
}
|
|
@@ -3287,6 +3349,11 @@ function resolveMcpSessionTracking(configured) {
|
|
|
3287
3349
|
const enabled = fromEnv === "true";
|
|
3288
3350
|
return typeof configured === "object" ? { ...configured, enabled } : enabled;
|
|
3289
3351
|
}
|
|
3352
|
+
var BRIZZ_OWNED = /* @__PURE__ */ Symbol.for("brizz.sdk.ownedTracerProvider");
|
|
3353
|
+
function globalTracerDelegate() {
|
|
3354
|
+
const global = _api.trace.getTracerProvider();
|
|
3355
|
+
return typeof global.getDelegate === "function" ? global.getDelegate() : global;
|
|
3356
|
+
}
|
|
3290
3357
|
var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init15.call(this);_class7.prototype.__init16.call(this);_class7.prototype.__init17.call(this); }
|
|
3291
3358
|
static __initStatic4() {this.instance = null}
|
|
3292
3359
|
static getInstance() {
|
|
@@ -3307,7 +3374,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3307
3374
|
*/
|
|
3308
3375
|
setupInstrumentation(options) {
|
|
3309
3376
|
const registry = InstrumentationRegistry.getInstance();
|
|
3310
|
-
|
|
3377
|
+
_chunkCF4CXFQPcjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
|
|
3311
3378
|
patchInstalledCallbackManager();
|
|
3312
3379
|
patchInstalledLangGraph();
|
|
3313
3380
|
patchInstalledTypeSafe();
|
|
@@ -3324,8 +3391,17 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3324
3391
|
const registry = InstrumentationRegistry.getInstance();
|
|
3325
3392
|
const manualInstrumentations = registry.getManualInstrumentations();
|
|
3326
3393
|
if (options.disableNodeSdk) {
|
|
3394
|
+
_chunkDC2MFO65cjs.setPrivateTracerProvider.call(void 0, null);
|
|
3395
|
+
if (!resolvedConfig.setGlobalTracerProvider) {
|
|
3396
|
+
_chunkWC573FCIcjs.logger.warn(
|
|
3397
|
+
"Brizz: setGlobalTracerProvider: false has no effect with disableNodeSdk: true. Brizz creates no TracerProvider, so spans follow the provider you register with getSpanProcessor()."
|
|
3398
|
+
);
|
|
3399
|
+
}
|
|
3327
3400
|
if (manualInstrumentations.length > 0) {
|
|
3328
|
-
_instrumentation.registerInstrumentations.call(void 0, {
|
|
3401
|
+
_instrumentation.registerInstrumentations.call(void 0, {
|
|
3402
|
+
instrumentations: manualInstrumentations,
|
|
3403
|
+
tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider
|
|
3404
|
+
});
|
|
3329
3405
|
}
|
|
3330
3406
|
_chunkWC573FCIcjs.logger.info("NodeSDK disabled - only telemetry modules initialized");
|
|
3331
3407
|
return;
|
|
@@ -3333,7 +3409,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3333
3409
|
const resourceAttributes = {
|
|
3334
3410
|
...resolvedConfig.resourceAttributes,
|
|
3335
3411
|
"service.name": resolvedConfig.appName,
|
|
3336
|
-
[BRIZZ_SDK_VERSION]:
|
|
3412
|
+
[BRIZZ_SDK_VERSION]: _chunkCF4CXFQPcjs.getSDKVersion.call(void 0, ),
|
|
3337
3413
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
3338
3414
|
};
|
|
3339
3415
|
if (resolvedConfig.environment) {
|
|
@@ -3343,15 +3419,34 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3343
3419
|
resourceAttributes["service.version"] = resolvedConfig.appVersion;
|
|
3344
3420
|
}
|
|
3345
3421
|
const resource = _resources2.defaultResource.call(void 0, ).merge(_resources2.detectResources.call(void 0, { detectors: [_resources2.envDetector, _resources2.hostDetector, _resources2.processDetector] })).merge(_resources2.resourceFromAttributes.call(void 0, resourceAttributes));
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3422
|
+
const spanProcessors = resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkO2IBZJOJcjs.InterruptPropagator)(), getSpanProcessor()];
|
|
3423
|
+
if (resolvedConfig.setGlobalTracerProvider) {
|
|
3424
|
+
this._tracerProvider = new (0, _sdktrace.TracerProvider)({ resource, spanProcessors });
|
|
3425
|
+
this.registerGlobalTracerProvider(this._tracerProvider);
|
|
3426
|
+
} else {
|
|
3427
|
+
this._tracerProvider = new (0, _sdktrace.TracerProvider)({
|
|
3428
|
+
resource,
|
|
3429
|
+
spanProcessors,
|
|
3430
|
+
sampler: new (0, _sdktrace.AlwaysOnSampler)()
|
|
3431
|
+
});
|
|
3432
|
+
if (_chunkDC2MFO65cjs.ensureContextManager.call(void 0, ) === "failed") {
|
|
3433
|
+
_chunkWC573FCIcjs.logger.warn(
|
|
3434
|
+
"Brizz: no OpenTelemetry context manager is active and Brizz could not install one; span parenting and session/user propagation will not work."
|
|
3435
|
+
);
|
|
3436
|
+
}
|
|
3437
|
+
_chunkDC2MFO65cjs.setPrivateTracerProvider.call(void 0, this._tracerProvider);
|
|
3438
|
+
_chunkWC573FCIcjs.logger.info(
|
|
3439
|
+
"Brizz: using a private TracerProvider; Brizz spans are exported to Brizz only and the global TracerProvider is left untouched."
|
|
3440
|
+
);
|
|
3441
|
+
}
|
|
3442
|
+
Reflect.set(this._tracerProvider, BRIZZ_OWNED, true);
|
|
3351
3443
|
this._meterProvider = new (0, _sdkmetrics.MeterProvider)({ resource, readers: [getMetricsReader()] });
|
|
3352
3444
|
_api.metrics.setGlobalMeterProvider(this._meterProvider);
|
|
3353
3445
|
if (manualInstrumentations.length > 0) {
|
|
3354
|
-
_instrumentation.registerInstrumentations.call(void 0, {
|
|
3446
|
+
_instrumentation.registerInstrumentations.call(void 0, {
|
|
3447
|
+
instrumentations: manualInstrumentations,
|
|
3448
|
+
tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider
|
|
3449
|
+
});
|
|
3355
3450
|
_chunkWC573FCIcjs.logger.info(
|
|
3356
3451
|
`Telemetry providers started with ${manualInstrumentations.length} manual instrumentations`
|
|
3357
3452
|
);
|
|
@@ -3361,6 +3456,27 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3361
3456
|
);
|
|
3362
3457
|
}
|
|
3363
3458
|
}
|
|
3459
|
+
/**
|
|
3460
|
+
* Register `provider` globally and say so when another provider already
|
|
3461
|
+
* holds the slot: OpenTelemetry refuses the second registration without a
|
|
3462
|
+
* word, and every Brizz span then goes to the other provider.
|
|
3463
|
+
* @private
|
|
3464
|
+
*/
|
|
3465
|
+
registerGlobalTracerProvider(provider) {
|
|
3466
|
+
_chunkDC2MFO65cjs.setPrivateTracerProvider.call(void 0, null);
|
|
3467
|
+
_chunkDC2MFO65cjs.registerTracerProvider.call(void 0, provider);
|
|
3468
|
+
const registered = globalTracerDelegate();
|
|
3469
|
+
if (registered === provider) {
|
|
3470
|
+
return;
|
|
3471
|
+
}
|
|
3472
|
+
if (Reflect.get(registered, BRIZZ_OWNED) === true) {
|
|
3473
|
+
_chunkWC573FCIcjs.logger.debug("A TracerProvider from an earlier Brizz.initialize() is still registered");
|
|
3474
|
+
return;
|
|
3475
|
+
}
|
|
3476
|
+
_chunkWC573FCIcjs.logger.warn(
|
|
3477
|
+
"Brizz: another OpenTelemetry TracerProvider is already registered globally, so Brizz could not register its own. Spans from Brizz instrumentations will go to that provider, not to Brizz. Pass setGlobalTracerProvider: false to Brizz.initialize() (or set BRIZZ_SET_GLOBAL_TRACER_PROVIDER=false) to send them to Brizz on a separate provider."
|
|
3478
|
+
);
|
|
3479
|
+
}
|
|
3364
3480
|
/**
|
|
3365
3481
|
* Initialize telemetry modules.
|
|
3366
3482
|
*
|
|
@@ -3459,6 +3575,62 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3459
3575
|
throw new Error(`Failed to initialize SDK: ${String(error)}`, { cause: error });
|
|
3460
3576
|
}
|
|
3461
3577
|
}
|
|
3578
|
+
/**
|
|
3579
|
+
* Send the telemetry Brizz has queued, without shutting down.
|
|
3580
|
+
*
|
|
3581
|
+
* On serverless platforms that throttle CPU once a response is sent (Cloud
|
|
3582
|
+
* Run, Lambda), await it before responding: the batch timer may not fire
|
|
3583
|
+
* again before the instance is frozen or recycled. Never throws.
|
|
3584
|
+
*
|
|
3585
|
+
* @param timeoutMillis - How long to wait. Defaults to 5000.
|
|
3586
|
+
* @returns `true` when everything was sent within the budget; `false` on a
|
|
3587
|
+
* timeout, an export error, or before `initialize()`.
|
|
3588
|
+
*
|
|
3589
|
+
* @example
|
|
3590
|
+
* ```typescript
|
|
3591
|
+
* await Brizz.flush();
|
|
3592
|
+
* res.send(reply);
|
|
3593
|
+
* ```
|
|
3594
|
+
*/
|
|
3595
|
+
async flush(timeoutMillis = 5e3) {
|
|
3596
|
+
if (!this._initialized) {
|
|
3597
|
+
_chunkWC573FCIcjs.logger.debug("Brizz.flush called before Brizz.initialize; nothing to flush");
|
|
3598
|
+
return false;
|
|
3599
|
+
}
|
|
3600
|
+
const settle = async (name, flush) => {
|
|
3601
|
+
try {
|
|
3602
|
+
await flush();
|
|
3603
|
+
return true;
|
|
3604
|
+
} catch (error) {
|
|
3605
|
+
_chunkWC573FCIcjs.logger.debug(`Brizz.flush: flushing ${name} failed: ${String(error)}`);
|
|
3606
|
+
return false;
|
|
3607
|
+
}
|
|
3608
|
+
};
|
|
3609
|
+
const work = Promise.all([
|
|
3610
|
+
settle("spans", () => TracingModule.getInstance().forceFlush()),
|
|
3611
|
+
settle("logs", () => LoggingModule.getInstance().forceFlush()),
|
|
3612
|
+
// Under disableNodeSdk the reader belongs to whatever MeterProvider the
|
|
3613
|
+
// app registered, if any; an unbound reader cannot flush.
|
|
3614
|
+
...this._meterProvider ? [settle("metrics", () => MetricsModule.getInstance().forceFlush())] : []
|
|
3615
|
+
]).then((results) => results.every(Boolean));
|
|
3616
|
+
let timer;
|
|
3617
|
+
const timedOut = new Promise((resolve) => {
|
|
3618
|
+
timer = setTimeout(() => resolve("timeout"), timeoutMillis);
|
|
3619
|
+
timer.unref();
|
|
3620
|
+
});
|
|
3621
|
+
try {
|
|
3622
|
+
const result = await Promise.race([work, timedOut]);
|
|
3623
|
+
if (result === "timeout") {
|
|
3624
|
+
_chunkWC573FCIcjs.logger.warn(
|
|
3625
|
+
`Brizz.flush did not finish within ${timeoutMillis}ms; telemetry still queued will be sent with the next batch.`
|
|
3626
|
+
);
|
|
3627
|
+
return false;
|
|
3628
|
+
}
|
|
3629
|
+
return result;
|
|
3630
|
+
} finally {
|
|
3631
|
+
clearTimeout(timer);
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3462
3634
|
/**
|
|
3463
3635
|
* Gracefully shutdown the Brizz SDK.
|
|
3464
3636
|
*
|
|
@@ -3481,10 +3653,10 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3481
3653
|
}
|
|
3482
3654
|
try {
|
|
3483
3655
|
await this.shutdownModules();
|
|
3484
|
-
await _optionalChain([this, 'access',
|
|
3485
|
-
await _optionalChain([this, 'access',
|
|
3486
|
-
await _optionalChain([this, 'access',
|
|
3487
|
-
await _optionalChain([this, 'access',
|
|
3656
|
+
await _optionalChain([this, 'access', _124 => _124._tracerProvider, 'optionalAccess', _125 => _125.forceFlush, 'call', _126 => _126()]);
|
|
3657
|
+
await _optionalChain([this, 'access', _127 => _127._tracerProvider, 'optionalAccess', _128 => _128.shutdown, 'call', _129 => _129()]);
|
|
3658
|
+
await _optionalChain([this, 'access', _130 => _130._meterProvider, 'optionalAccess', _131 => _131.forceFlush, 'call', _132 => _132()]);
|
|
3659
|
+
await _optionalChain([this, 'access', _133 => _133._meterProvider, 'optionalAccess', _134 => _134.shutdown, 'call', _135 => _135()]);
|
|
3488
3660
|
this._initialized = false;
|
|
3489
3661
|
this._tracerProvider = null;
|
|
3490
3662
|
this._meterProvider = null;
|
|
@@ -3551,4 +3723,5 @@ var Brizz = new _Brizz();
|
|
|
3551
3723
|
|
|
3552
3724
|
|
|
3553
3725
|
|
|
3554
|
-
|
|
3726
|
+
|
|
3727
|
+
exports.Brizz = Brizz; exports.DEFAULT_PII_PATTERNS = DEFAULT_PII_PATTERNS; exports.LogLevel = _chunkWC573FCIcjs.LogLevel; exports.Session = Session; exports.SessionTitle = SessionTitle; exports.SeverityNumber = _api.SeverityNumber; exports.addExternalLink = addExternalLink; exports.callWithMessageId = callWithMessageId; exports.callWithMute = callWithMute; exports.callWithOrganization = callWithOrganization; exports.callWithProperties = callWithProperties; exports.callWithServiceName = callWithServiceName; exports.callWithSessionId = callWithSessionId; exports.callWithUser = callWithUser; exports.emitEvent = emitEvent; exports.emitEventWithSessionId = emitEventWithSessionId; exports.getActiveSession = getActiveSession; exports.getLogLevel = _chunkWC573FCIcjs.getLogLevel; exports.getMetricsExporter = getMetricsExporter; exports.getMetricsReader = getMetricsReader; exports.getSpanExporter = getSpanExporter; exports.getSpanProcessor = getSpanProcessor; exports.getTracerProvider = _chunkDC2MFO65cjs.getTracerProvider; exports.logger = _chunkWC573FCIcjs.logger; exports.maskAttributes = maskAttributes; exports.maskValue = maskValue; exports.recordFeedback = recordFeedback; exports.recordMetric = recordMetric; exports.setAgent = setAgent; exports.setCurrentSpanCustomProperties = setCurrentSpanCustomProperties; exports.setLogLevel = _chunkWC573FCIcjs.setLogLevel; exports.setMessageId = setMessageId; exports.setOrganization = setOrganization; exports.setServiceName = setServiceName; exports.setSessionId = setSessionId; exports.setUser = setUser; exports.startAgent = startAgent; exports.startSession = startSession; exports.startSessionTitle = startSessionTitle; exports.withAgent = withAgent; exports.withMessageId = withMessageId; exports.withMute = withMute; exports.withOrganization = withOrganization; exports.withProperties = withProperties; exports.withServiceName = withServiceName; exports.withSessionId = withSessionId; exports.withUser = withUser;
|