@brizz/sdk 0.1.42 → 0.1.44
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 +44 -0
- package/dist/{chunk-QUV5HYJ2.cjs → chunk-3IGBYXLR.cjs} +4 -4
- package/dist/{chunk-FORVS4QW.cjs → chunk-5WBPX342.cjs} +7 -1
- package/dist/chunk-A3HH5OUL.cjs +240 -0
- package/dist/chunk-AELIATPI.js +240 -0
- package/dist/{chunk-Y7NMZAQT.js → chunk-AOT5NJDV.js} +6 -0
- package/dist/{chunk-7FQQHF5U.js → chunk-APOYOP7D.js} +1 -1
- package/dist/index.cjs +270 -128
- package/dist/index.js +154 -12
- package/dist/{interrupt-ERCX5RXR.js → interrupt-A6O7N72X.js} +2 -2
- package/dist/interrupt-IKOUBQGN.cjs +12 -0
- package/dist/{mcp-GVGTOWHP.cjs → mcp-5FSUXYHM.cjs} +97 -100
- package/dist/{mcp-5BFXKN63.js → mcp-7EJXVCPI.js} +83 -86
- package/dist/types/cjs/index.d.ts +2 -2
- package/dist/types/cjs/internal/instrumentation/mcp/client-session.d.ts +24 -0
- package/dist/types/cjs/internal/instrumentation/mcp/session.d.ts +3 -1
- package/dist/types/cjs/internal/sdk.d.ts +2 -0
- package/dist/types/cjs/internal/semantic-conventions.d.ts +3 -0
- package/dist/types/cjs/internal/trace/agent.d.ts +18 -0
- package/dist/types/cjs/internal/trace/index.d.ts +2 -0
- package/dist/types/cjs/internal/trace/session.d.ts +2 -1
- package/dist/types/esm/index.d.ts +2 -2
- package/dist/types/esm/internal/instrumentation/mcp/client-session.d.ts +24 -0
- package/dist/types/esm/internal/instrumentation/mcp/session.d.ts +3 -1
- package/dist/types/esm/internal/sdk.d.ts +2 -0
- package/dist/types/esm/internal/semantic-conventions.d.ts +3 -0
- package/dist/types/esm/internal/trace/agent.d.ts +18 -0
- package/dist/types/esm/internal/trace/index.d.ts +2 -0
- package/dist/types/esm/internal/trace/session.d.ts +2 -1
- package/package.json +10 -10
- package/dist/chunk-K3NPYISB.cjs +0 -8
- package/dist/chunk-KVOGOKOB.js +0 -8
- package/dist/interrupt-3NXOTY4N.cjs +0 -12
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
var _chunkA3HH5OULcjs = require('./chunk-A3HH5OUL.cjs');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
@@ -15,7 +16,9 @@ var _chunkK3NPYISBcjs = require('./chunk-K3NPYISB.cjs');
|
|
|
15
16
|
var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
var
|
|
19
|
+
var _chunk3IGBYXLRcjs = require('./chunk-3IGBYXLR.cjs');
|
|
20
|
+
|
|
21
|
+
|
|
19
22
|
|
|
20
23
|
|
|
21
24
|
|
|
@@ -69,7 +72,8 @@ var _chunkQUV5HYJ2cjs = require('./chunk-QUV5HYJ2.cjs');
|
|
|
69
72
|
|
|
70
73
|
|
|
71
74
|
|
|
72
|
-
|
|
75
|
+
|
|
76
|
+
var _chunk5WBPX342cjs = require('./chunk-5WBPX342.cjs');
|
|
73
77
|
|
|
74
78
|
|
|
75
79
|
var _chunkOBGZSXTJcjs = require('./chunk-OBGZSXTJ.cjs');
|
|
@@ -126,7 +130,7 @@ function loadGenAIInstrumentations() {
|
|
|
126
130
|
function loadMCPInstrumentation() {
|
|
127
131
|
void (async () => {
|
|
128
132
|
try {
|
|
129
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
133
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-5FSUXYHM.cjs")));
|
|
130
134
|
const mcp = new MCPInstrumentation({ exceptionLogger });
|
|
131
135
|
_instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp] });
|
|
132
136
|
_chunkWC573FCIcjs.logger.debug("Auto-loaded MCP instrumentation");
|
|
@@ -182,7 +186,7 @@ function loadVercelAITelemetry() {
|
|
|
182
186
|
}
|
|
183
187
|
const isV7 = typeof ai.registerTelemetry === "function";
|
|
184
188
|
const integrations = [];
|
|
185
|
-
const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-
|
|
189
|
+
const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-IKOUBQGN.cjs")));
|
|
186
190
|
integrations.push(createInterruptIntegration());
|
|
187
191
|
let otelCollectorLoaded = false;
|
|
188
192
|
try {
|
|
@@ -509,7 +513,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
509
513
|
const mcpModules = this.manualModules.mcp;
|
|
510
514
|
void (async () => {
|
|
511
515
|
try {
|
|
512
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
516
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-5FSUXYHM.cjs")));
|
|
513
517
|
const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
|
|
514
518
|
instrumentation.manuallyInstrument(mcpModules);
|
|
515
519
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
|
|
@@ -560,16 +564,16 @@ function setCurrentSpanCustomProperties(properties) {
|
|
|
560
564
|
}
|
|
561
565
|
for (const [key, value] of Object.entries(properties)) {
|
|
562
566
|
try {
|
|
563
|
-
current.setAttribute(`${
|
|
567
|
+
current.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
|
|
564
568
|
} catch (e2) {
|
|
565
569
|
}
|
|
566
570
|
}
|
|
567
571
|
}
|
|
568
572
|
function callWithProperties(properties, fn, thisArg, ...args) {
|
|
569
573
|
const base = _api.context.active();
|
|
570
|
-
const prev = base.getValue(
|
|
574
|
+
const prev = base.getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
571
575
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
572
|
-
const next = base.setValue(
|
|
576
|
+
const next = base.setValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY, merged);
|
|
573
577
|
return _api.context.with(next, fn, thisArg, ...args);
|
|
574
578
|
}
|
|
575
579
|
function withProperties(properties, fn, thisArg) {
|
|
@@ -582,7 +586,7 @@ function withProperties(properties, fn, thisArg) {
|
|
|
582
586
|
);
|
|
583
587
|
};
|
|
584
588
|
}
|
|
585
|
-
function propagatePropertiesImperatively(properties) {
|
|
589
|
+
function propagatePropertiesImperatively(properties, base = _api.context.active()) {
|
|
586
590
|
try {
|
|
587
591
|
const manager = _api.context;
|
|
588
592
|
const mgr = _optionalChain([manager, 'access', _32 => _32._getContextManager, 'optionalCall', _33 => _33()]);
|
|
@@ -590,26 +594,25 @@ function propagatePropertiesImperatively(properties) {
|
|
|
590
594
|
if (!store || typeof store.enterWith !== "function") {
|
|
591
595
|
return;
|
|
592
596
|
}
|
|
593
|
-
const
|
|
594
|
-
const prev = base.getValue(_chunkFORVS4QWcjs.PROPERTIES_CONTEXT_KEY);
|
|
597
|
+
const prev = base.getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
595
598
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
596
|
-
store.enterWith(base.setValue(
|
|
599
|
+
store.enterWith(base.setValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY, merged));
|
|
597
600
|
} catch (e3) {
|
|
598
601
|
}
|
|
599
602
|
}
|
|
600
603
|
function setUser(user) {
|
|
601
|
-
const properties = { [
|
|
604
|
+
const properties = { [_chunk5WBPX342cjs.USER_ID]: user.id };
|
|
602
605
|
if (user.email !== void 0) {
|
|
603
|
-
properties[
|
|
606
|
+
properties[_chunk5WBPX342cjs.USER_EMAIL] = user.email;
|
|
604
607
|
}
|
|
605
608
|
if (user.name !== void 0) {
|
|
606
|
-
properties[
|
|
609
|
+
properties[_chunk5WBPX342cjs.USER_NAME] = user.name;
|
|
607
610
|
}
|
|
608
611
|
if (user.role !== void 0) {
|
|
609
|
-
properties[
|
|
612
|
+
properties[_chunk5WBPX342cjs.USER_ROLE] = user.role;
|
|
610
613
|
}
|
|
611
614
|
if (user.plan !== void 0) {
|
|
612
|
-
properties[
|
|
615
|
+
properties[_chunk5WBPX342cjs.USER_PLAN] = user.plan;
|
|
613
616
|
}
|
|
614
617
|
if (user.traits) {
|
|
615
618
|
for (const [key, value] of Object.entries(user.traits)) {
|
|
@@ -623,15 +626,15 @@ function setUser(user) {
|
|
|
623
626
|
propagatePropertiesImperatively(properties);
|
|
624
627
|
}
|
|
625
628
|
function setOrganization(org) {
|
|
626
|
-
const properties = { [
|
|
629
|
+
const properties = { [_chunk5WBPX342cjs.ORGANIZATION_ID]: org.id };
|
|
627
630
|
if (org.name !== void 0) {
|
|
628
|
-
properties[
|
|
631
|
+
properties[_chunk5WBPX342cjs.ORGANIZATION_NAME] = org.name;
|
|
629
632
|
}
|
|
630
633
|
if (org.plan !== void 0) {
|
|
631
|
-
properties[
|
|
634
|
+
properties[_chunk5WBPX342cjs.ORGANIZATION_PLAN] = org.plan;
|
|
632
635
|
}
|
|
633
636
|
if (org.domain !== void 0) {
|
|
634
|
-
properties[
|
|
637
|
+
properties[_chunk5WBPX342cjs.ORGANIZATION_DOMAIN] = org.domain;
|
|
635
638
|
}
|
|
636
639
|
if (org.traits) {
|
|
637
640
|
for (const [key, value] of Object.entries(org.traits)) {
|
|
@@ -645,12 +648,12 @@ function setOrganization(org) {
|
|
|
645
648
|
propagatePropertiesImperatively(properties);
|
|
646
649
|
}
|
|
647
650
|
function setMessageId(id) {
|
|
648
|
-
const properties = { [
|
|
651
|
+
const properties = { [_chunk5WBPX342cjs.MESSAGE_ID]: id };
|
|
649
652
|
setCurrentSpanCustomProperties(properties);
|
|
650
653
|
propagatePropertiesImperatively(properties);
|
|
651
654
|
}
|
|
652
655
|
function setSessionId(id) {
|
|
653
|
-
const properties = { [
|
|
656
|
+
const properties = { [_chunk5WBPX342cjs.SESSION_ID]: id };
|
|
654
657
|
setCurrentSpanCustomProperties(properties);
|
|
655
658
|
propagatePropertiesImperatively(properties);
|
|
656
659
|
}
|
|
@@ -673,7 +676,7 @@ function serviceNameProperties(name) {
|
|
|
673
676
|
);
|
|
674
677
|
return {};
|
|
675
678
|
}
|
|
676
|
-
return { [
|
|
679
|
+
return { [_chunk5WBPX342cjs.SERVICE_NAME]: name };
|
|
677
680
|
}
|
|
678
681
|
function setServiceName(name) {
|
|
679
682
|
const properties = serviceNameProperties(name);
|
|
@@ -687,22 +690,22 @@ function withServiceName(name, fn, thisArg) {
|
|
|
687
690
|
return withProperties(serviceNameProperties(name), fn, thisArg);
|
|
688
691
|
}
|
|
689
692
|
function resolveServiceNameFromContext() {
|
|
690
|
-
const props = _api.context.active().getValue(
|
|
691
|
-
return _optionalChain([props, 'optionalAccess', _35 => _35[
|
|
693
|
+
const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
694
|
+
return _optionalChain([props, 'optionalAccess', _35 => _35[_chunk5WBPX342cjs.SERVICE_NAME]]);
|
|
692
695
|
}
|
|
693
696
|
function userProperties(user) {
|
|
694
|
-
const properties = { [
|
|
697
|
+
const properties = { [_chunk5WBPX342cjs.USER_ID]: user.id };
|
|
695
698
|
if (user.email !== void 0) {
|
|
696
|
-
properties[
|
|
699
|
+
properties[_chunk5WBPX342cjs.USER_EMAIL] = user.email;
|
|
697
700
|
}
|
|
698
701
|
if (user.name !== void 0) {
|
|
699
|
-
properties[
|
|
702
|
+
properties[_chunk5WBPX342cjs.USER_NAME] = user.name;
|
|
700
703
|
}
|
|
701
704
|
if (user.role !== void 0) {
|
|
702
|
-
properties[
|
|
705
|
+
properties[_chunk5WBPX342cjs.USER_ROLE] = user.role;
|
|
703
706
|
}
|
|
704
707
|
if (user.plan !== void 0) {
|
|
705
|
-
properties[
|
|
708
|
+
properties[_chunk5WBPX342cjs.USER_PLAN] = user.plan;
|
|
706
709
|
}
|
|
707
710
|
if (user.traits) {
|
|
708
711
|
for (const [key, value] of Object.entries(user.traits)) {
|
|
@@ -715,15 +718,15 @@ function userProperties(user) {
|
|
|
715
718
|
return properties;
|
|
716
719
|
}
|
|
717
720
|
function organizationProperties(org) {
|
|
718
|
-
const properties = { [
|
|
721
|
+
const properties = { [_chunk5WBPX342cjs.ORGANIZATION_ID]: org.id };
|
|
719
722
|
if (org.name !== void 0) {
|
|
720
|
-
properties[
|
|
723
|
+
properties[_chunk5WBPX342cjs.ORGANIZATION_NAME] = org.name;
|
|
721
724
|
}
|
|
722
725
|
if (org.plan !== void 0) {
|
|
723
|
-
properties[
|
|
726
|
+
properties[_chunk5WBPX342cjs.ORGANIZATION_PLAN] = org.plan;
|
|
724
727
|
}
|
|
725
728
|
if (org.domain !== void 0) {
|
|
726
|
-
properties[
|
|
729
|
+
properties[_chunk5WBPX342cjs.ORGANIZATION_DOMAIN] = org.domain;
|
|
727
730
|
}
|
|
728
731
|
if (org.traits) {
|
|
729
732
|
for (const [key, value] of Object.entries(org.traits)) {
|
|
@@ -748,32 +751,32 @@ function withOrganization(org, fn, thisArg) {
|
|
|
748
751
|
return withProperties(organizationProperties(org), fn, thisArg);
|
|
749
752
|
}
|
|
750
753
|
function callWithMessageId(id, fn, thisArg, ...args) {
|
|
751
|
-
return callWithProperties({ [
|
|
754
|
+
return callWithProperties({ [_chunk5WBPX342cjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
|
|
752
755
|
}
|
|
753
756
|
function withMessageId(id, fn, thisArg) {
|
|
754
|
-
return withProperties({ [
|
|
757
|
+
return withProperties({ [_chunk5WBPX342cjs.MESSAGE_ID]: id }, fn, thisArg);
|
|
755
758
|
}
|
|
756
759
|
function inheritedMuteTools() {
|
|
757
|
-
const properties = _api.context.active().getValue(
|
|
758
|
-
return _optionalChain([properties, 'optionalAccess', _36 => _36[
|
|
760
|
+
const properties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
761
|
+
return _optionalChain([properties, 'optionalAccess', _36 => _36[_chunk5WBPX342cjs.MUTE_TOOLS]]);
|
|
759
762
|
}
|
|
760
763
|
function muteProperties(options) {
|
|
761
764
|
const { input = true, output = true, tools = output } = options;
|
|
762
765
|
const properties = {};
|
|
763
766
|
if (input) {
|
|
764
|
-
properties[
|
|
767
|
+
properties[_chunk5WBPX342cjs.MUTE_INPUT] = "true";
|
|
765
768
|
}
|
|
766
769
|
if (output) {
|
|
767
|
-
properties[
|
|
770
|
+
properties[_chunk5WBPX342cjs.MUTE_OUTPUT] = "true";
|
|
768
771
|
}
|
|
769
772
|
if (tools !== output) {
|
|
770
|
-
properties[
|
|
773
|
+
properties[_chunk5WBPX342cjs.MUTE_TOOLS] = String(tools);
|
|
771
774
|
} else {
|
|
772
775
|
const inherited = inheritedMuteTools();
|
|
773
776
|
if (tools && inherited === "false") {
|
|
774
|
-
properties[
|
|
777
|
+
properties[_chunk5WBPX342cjs.MUTE_TOOLS] = "true";
|
|
775
778
|
} else if (options.tools === false && inherited === "true") {
|
|
776
|
-
properties[
|
|
779
|
+
properties[_chunk5WBPX342cjs.MUTE_TOOLS] = "false";
|
|
777
780
|
}
|
|
778
781
|
}
|
|
779
782
|
return properties;
|
|
@@ -785,11 +788,11 @@ function withMute(options, fn, thisArg) {
|
|
|
785
788
|
return withProperties(muteProperties(options), fn, thisArg);
|
|
786
789
|
}
|
|
787
790
|
function withSessionId(sessionId, fn, thisArg, extraProperties) {
|
|
788
|
-
const properties = { [
|
|
791
|
+
const properties = { [_chunk5WBPX342cjs.SESSION_ID]: sessionId, ...extraProperties };
|
|
789
792
|
return withProperties(properties, fn, thisArg);
|
|
790
793
|
}
|
|
791
794
|
function callWithSessionId(sessionId, fn, thisArg, ...args) {
|
|
792
|
-
return callWithProperties({ [
|
|
795
|
+
return callWithProperties({ [_chunk5WBPX342cjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
|
|
793
796
|
}
|
|
794
797
|
var Session = (_class2 = class {
|
|
795
798
|
|
|
@@ -814,11 +817,11 @@ var Session = (_class2 = class {
|
|
|
814
817
|
* @param text - Text to append (null becomes a null/"hide marker")
|
|
815
818
|
* @param context - Optional per-turn context bag to attach to this turn
|
|
816
819
|
*/
|
|
817
|
-
setInput(text,
|
|
820
|
+
setInput(text, context5) {
|
|
818
821
|
this.inputs.push(text);
|
|
819
|
-
this.inputContexts.push(_nullishCoalesce(
|
|
820
|
-
this.span.setAttribute(
|
|
821
|
-
this.span.setAttribute(
|
|
822
|
+
this.inputContexts.push(_nullishCoalesce(context5, () => ( {})));
|
|
823
|
+
this.span.setAttribute(_chunk5WBPX342cjs.SESSION_INPUT, JSON.stringify(this.inputs));
|
|
824
|
+
this.span.setAttribute(_chunk5WBPX342cjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
|
|
822
825
|
}
|
|
823
826
|
/**
|
|
824
827
|
* Append an assistant turn to session output tracking.
|
|
@@ -830,11 +833,11 @@ var Session = (_class2 = class {
|
|
|
830
833
|
* @param text - Text to append (null becomes a null/"hide marker")
|
|
831
834
|
* @param context - Optional per-turn context bag to attach to this turn
|
|
832
835
|
*/
|
|
833
|
-
setOutput(text,
|
|
836
|
+
setOutput(text, context5) {
|
|
834
837
|
this.outputs.push(text);
|
|
835
|
-
this.outputContexts.push(_nullishCoalesce(
|
|
836
|
-
this.span.setAttribute(
|
|
837
|
-
this.span.setAttribute(
|
|
838
|
+
this.outputContexts.push(_nullishCoalesce(context5, () => ( {})));
|
|
839
|
+
this.span.setAttribute(_chunk5WBPX342cjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
|
|
840
|
+
this.span.setAttribute(_chunk5WBPX342cjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
|
|
838
841
|
}
|
|
839
842
|
/**
|
|
840
843
|
* Set the session title on the span.
|
|
@@ -842,7 +845,7 @@ var Session = (_class2 = class {
|
|
|
842
845
|
* @param title - The generated title string
|
|
843
846
|
*/
|
|
844
847
|
setTitle(title) {
|
|
845
|
-
this.span.setAttribute(
|
|
848
|
+
this.span.setAttribute(_chunk5WBPX342cjs.SESSION_TITLE, title);
|
|
846
849
|
}
|
|
847
850
|
/**
|
|
848
851
|
* Update custom properties on the session span.
|
|
@@ -852,7 +855,7 @@ var Session = (_class2 = class {
|
|
|
852
855
|
*/
|
|
853
856
|
updateProperties(properties) {
|
|
854
857
|
for (const [key, value] of Object.entries(properties)) {
|
|
855
|
-
this.span.setAttribute(`${
|
|
858
|
+
this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
|
|
856
859
|
}
|
|
857
860
|
}
|
|
858
861
|
/**
|
|
@@ -864,21 +867,21 @@ var Session = (_class2 = class {
|
|
|
864
867
|
setUser(user) {
|
|
865
868
|
if (user.traits) {
|
|
866
869
|
for (const [key, value] of Object.entries(user.traits)) {
|
|
867
|
-
this.span.setAttribute(`${
|
|
870
|
+
this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.user.${key}`, value);
|
|
868
871
|
}
|
|
869
872
|
}
|
|
870
|
-
this.span.setAttribute(`${
|
|
873
|
+
this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_ID}`, user.id);
|
|
871
874
|
if (user.email !== void 0) {
|
|
872
|
-
this.span.setAttribute(`${
|
|
875
|
+
this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_EMAIL}`, user.email);
|
|
873
876
|
}
|
|
874
877
|
if (user.name !== void 0) {
|
|
875
|
-
this.span.setAttribute(`${
|
|
878
|
+
this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_NAME}`, user.name);
|
|
876
879
|
}
|
|
877
880
|
if (user.role !== void 0) {
|
|
878
|
-
this.span.setAttribute(`${
|
|
881
|
+
this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_ROLE}`, user.role);
|
|
879
882
|
}
|
|
880
883
|
if (user.plan !== void 0) {
|
|
881
|
-
this.span.setAttribute(`${
|
|
884
|
+
this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_PLAN}`, user.plan);
|
|
882
885
|
}
|
|
883
886
|
}
|
|
884
887
|
/**
|
|
@@ -890,18 +893,18 @@ var Session = (_class2 = class {
|
|
|
890
893
|
setOrganization(org) {
|
|
891
894
|
if (org.traits) {
|
|
892
895
|
for (const [key, value] of Object.entries(org.traits)) {
|
|
893
|
-
this.span.setAttribute(`${
|
|
896
|
+
this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.organization.${key}`, value);
|
|
894
897
|
}
|
|
895
898
|
}
|
|
896
|
-
this.span.setAttribute(`${
|
|
899
|
+
this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_ID}`, org.id);
|
|
897
900
|
if (org.name !== void 0) {
|
|
898
|
-
this.span.setAttribute(`${
|
|
901
|
+
this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_NAME}`, org.name);
|
|
899
902
|
}
|
|
900
903
|
if (org.plan !== void 0) {
|
|
901
|
-
this.span.setAttribute(`${
|
|
904
|
+
this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_PLAN}`, org.plan);
|
|
902
905
|
}
|
|
903
906
|
if (org.domain !== void 0) {
|
|
904
|
-
this.span.setAttribute(`${
|
|
907
|
+
this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_DOMAIN}`, org.domain);
|
|
905
908
|
}
|
|
906
909
|
}
|
|
907
910
|
/**
|
|
@@ -931,30 +934,30 @@ var SessionTitle = class {
|
|
|
931
934
|
* @param title - The generated title string
|
|
932
935
|
*/
|
|
933
936
|
setTitle(title) {
|
|
934
|
-
this.span.setAttribute(
|
|
937
|
+
this.span.setAttribute(_chunk5WBPX342cjs.SESSION_TITLE, title);
|
|
935
938
|
}
|
|
936
939
|
};
|
|
937
940
|
function getActiveSession() {
|
|
938
|
-
return _api.context.active().getValue(
|
|
941
|
+
return _api.context.active().getValue(_chunk5WBPX342cjs.SESSION_OBJECT_CONTEXT_KEY);
|
|
939
942
|
}
|
|
940
943
|
function resolveSessionIdFromContext() {
|
|
941
944
|
const active = getActiveSession();
|
|
942
945
|
if (active) {
|
|
943
946
|
return active.sessionId;
|
|
944
947
|
}
|
|
945
|
-
const props = _api.context.active().getValue(
|
|
946
|
-
return _optionalChain([props, 'optionalAccess', _39 => _39[
|
|
948
|
+
const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
949
|
+
return _optionalChain([props, 'optionalAccess', _39 => _39[_chunk5WBPX342cjs.SESSION_ID]]);
|
|
947
950
|
}
|
|
948
951
|
function resolveMessageIdFromContext() {
|
|
949
|
-
const props = _api.context.active().getValue(
|
|
950
|
-
return _optionalChain([props, 'optionalAccess', _40 => _40[
|
|
952
|
+
const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
953
|
+
return _optionalChain([props, 'optionalAccess', _40 => _40[_chunk5WBPX342cjs.MESSAGE_ID]]);
|
|
951
954
|
}
|
|
952
955
|
function emitExternalLink(sessionId, url, title, linkType) {
|
|
953
956
|
try {
|
|
954
|
-
emitEventWithSessionId(sessionId,
|
|
955
|
-
[
|
|
956
|
-
[
|
|
957
|
-
[
|
|
957
|
+
emitEventWithSessionId(sessionId, _chunk5WBPX342cjs.EXTERNAL_LINK_EVENT_NAME, {
|
|
958
|
+
[_chunk5WBPX342cjs.EXTERNAL_LINK_URL]: url,
|
|
959
|
+
[_chunk5WBPX342cjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
|
|
960
|
+
[_chunk5WBPX342cjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
|
|
958
961
|
});
|
|
959
962
|
} catch (error) {
|
|
960
963
|
_chunkWC573FCIcjs.logger.warn("addExternalLink: failed to emit external link", error);
|
|
@@ -971,22 +974,22 @@ function addExternalLink(url, options) {
|
|
|
971
974
|
emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _42 => _42.title]), _optionalChain([options, 'optionalAccess', _43 => _43.linkType]));
|
|
972
975
|
}
|
|
973
976
|
function recordFeedback(type, options) {
|
|
974
|
-
const eventAttributes = { [
|
|
977
|
+
const eventAttributes = { [_chunk5WBPX342cjs.FEEDBACK_TYPE]: type };
|
|
975
978
|
if (_optionalChain([options, 'optionalAccess', _44 => _44.score]) !== void 0) {
|
|
976
|
-
eventAttributes[
|
|
979
|
+
eventAttributes[_chunk5WBPX342cjs.FEEDBACK_SCORE] = options.score;
|
|
977
980
|
}
|
|
978
981
|
if (_optionalChain([options, 'optionalAccess', _45 => _45.reason]) !== void 0) {
|
|
979
|
-
eventAttributes[
|
|
982
|
+
eventAttributes[_chunk5WBPX342cjs.FEEDBACK_REASON] = options.reason;
|
|
980
983
|
}
|
|
981
984
|
if (_optionalChain([options, 'optionalAccess', _46 => _46.comment]) !== void 0) {
|
|
982
|
-
eventAttributes[
|
|
985
|
+
eventAttributes[_chunk5WBPX342cjs.FEEDBACK_COMMENT] = options.comment;
|
|
983
986
|
}
|
|
984
987
|
if (_optionalChain([options, 'optionalAccess', _47 => _47.source]) !== void 0) {
|
|
985
|
-
eventAttributes[
|
|
988
|
+
eventAttributes[_chunk5WBPX342cjs.FEEDBACK_SOURCE] = options.source;
|
|
986
989
|
}
|
|
987
990
|
if (_optionalChain([options, 'optionalAccess', _48 => _48.attributes])) {
|
|
988
991
|
for (const [key, value] of Object.entries(options.attributes)) {
|
|
989
|
-
const k = `${
|
|
992
|
+
const k = `${_chunk5WBPX342cjs.FEEDBACK_ATTR_PREFIX}${key}`;
|
|
990
993
|
if (eventAttributes[k] === void 0) {
|
|
991
994
|
eventAttributes[k] = value;
|
|
992
995
|
}
|
|
@@ -1001,16 +1004,16 @@ function recordFeedback(type, options) {
|
|
|
1001
1004
|
}
|
|
1002
1005
|
const anchor = {};
|
|
1003
1006
|
if (messageId !== void 0) {
|
|
1004
|
-
anchor[
|
|
1007
|
+
anchor[_chunk5WBPX342cjs.MESSAGE_ID] = messageId;
|
|
1005
1008
|
}
|
|
1006
1009
|
if (sessionId !== void 0) {
|
|
1007
|
-
anchor[
|
|
1010
|
+
anchor[_chunk5WBPX342cjs.SESSION_ID] = sessionId;
|
|
1008
1011
|
}
|
|
1009
1012
|
try {
|
|
1010
1013
|
if (Object.keys(anchor).length === 0) {
|
|
1011
|
-
emitEvent(
|
|
1014
|
+
emitEvent(_chunk5WBPX342cjs.FEEDBACK_EVENT_NAME, eventAttributes);
|
|
1012
1015
|
} else {
|
|
1013
|
-
callWithProperties(anchor, () => emitEvent(
|
|
1016
|
+
callWithProperties(anchor, () => emitEvent(_chunk5WBPX342cjs.FEEDBACK_EVENT_NAME, eventAttributes));
|
|
1014
1017
|
}
|
|
1015
1018
|
} catch (error) {
|
|
1016
1019
|
_chunkWC573FCIcjs.logger.warn("recordFeedback: failed to emit feedback event", error);
|
|
@@ -1035,7 +1038,7 @@ function recordMetricImpl(options) {
|
|
|
1035
1038
|
);
|
|
1036
1039
|
return;
|
|
1037
1040
|
}
|
|
1038
|
-
if (
|
|
1041
|
+
if (_chunk5WBPX342cjs.RESERVED_METRIC_NAMES.has(name)) {
|
|
1039
1042
|
_chunkWC573FCIcjs.logger.warn(
|
|
1040
1043
|
`recordMetric called with the reserved name ${JSON.stringify(name)}; metric dropped. Brizz computes this metric itself \u2014 pick a different name.`
|
|
1041
1044
|
);
|
|
@@ -1054,17 +1057,17 @@ function recordMetricImpl(options) {
|
|
|
1054
1057
|
return;
|
|
1055
1058
|
}
|
|
1056
1059
|
const eventAttributes = {
|
|
1057
|
-
[
|
|
1058
|
-
[
|
|
1060
|
+
[_chunk5WBPX342cjs.METRIC_NAME]: name,
|
|
1061
|
+
[_chunk5WBPX342cjs.METRIC_VALUE]: numericValue
|
|
1059
1062
|
};
|
|
1060
1063
|
if (options.unit !== void 0) {
|
|
1061
|
-
eventAttributes[
|
|
1064
|
+
eventAttributes[_chunk5WBPX342cjs.METRIC_UNIT] = options.unit;
|
|
1062
1065
|
}
|
|
1063
1066
|
if (options.minValue !== void 0) {
|
|
1064
|
-
eventAttributes[
|
|
1067
|
+
eventAttributes[_chunk5WBPX342cjs.METRIC_MIN] = options.minValue;
|
|
1065
1068
|
}
|
|
1066
1069
|
if (options.maxValue !== void 0) {
|
|
1067
|
-
eventAttributes[
|
|
1070
|
+
eventAttributes[_chunk5WBPX342cjs.METRIC_MAX] = options.maxValue;
|
|
1068
1071
|
}
|
|
1069
1072
|
if (options.comment !== void 0) {
|
|
1070
1073
|
let comment = options.comment;
|
|
@@ -1074,21 +1077,21 @@ function recordMetricImpl(options) {
|
|
|
1074
1077
|
);
|
|
1075
1078
|
comment = comment.slice(0, METRIC_COMMENT_MAX_LEN);
|
|
1076
1079
|
}
|
|
1077
|
-
eventAttributes[
|
|
1080
|
+
eventAttributes[_chunk5WBPX342cjs.METRIC_COMMENT] = comment;
|
|
1078
1081
|
}
|
|
1079
1082
|
if (options.polarity !== void 0) {
|
|
1080
1083
|
const polarity = options.polarity;
|
|
1081
|
-
if (polarity ===
|
|
1082
|
-
eventAttributes[
|
|
1084
|
+
if (polarity === _chunk5WBPX342cjs.METRIC_POLARITY_POSITIVE || polarity === _chunk5WBPX342cjs.METRIC_POLARITY_NEGATIVE) {
|
|
1085
|
+
eventAttributes[_chunk5WBPX342cjs.METRIC_POLARITY] = polarity;
|
|
1083
1086
|
} else {
|
|
1084
1087
|
_chunkWC573FCIcjs.logger.warn(
|
|
1085
|
-
`recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${
|
|
1088
|
+
`recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${_chunk5WBPX342cjs.METRIC_POLARITY_POSITIVE}' or '${_chunk5WBPX342cjs.METRIC_POLARITY_NEGATIVE}'. Emitting the metric without it.`
|
|
1086
1089
|
);
|
|
1087
1090
|
}
|
|
1088
1091
|
}
|
|
1089
1092
|
if (options.timestamp !== void 0) {
|
|
1090
1093
|
if (Number.isFinite(options.timestamp.getTime())) {
|
|
1091
|
-
eventAttributes[
|
|
1094
|
+
eventAttributes[_chunk5WBPX342cjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
|
|
1092
1095
|
} else {
|
|
1093
1096
|
_chunkWC573FCIcjs.logger.warn(
|
|
1094
1097
|
`recordMetric(${name}) called with an invalid timestamp; emitting the metric without it.`
|
|
@@ -1118,7 +1121,7 @@ function recordMetricImpl(options) {
|
|
|
1118
1121
|
);
|
|
1119
1122
|
text = text.slice(0, METRIC_ATTRIBUTE_VALUE_MAX_LEN);
|
|
1120
1123
|
}
|
|
1121
|
-
eventAttributes[`${
|
|
1124
|
+
eventAttributes[`${_chunk5WBPX342cjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
|
|
1122
1125
|
accepted += 1;
|
|
1123
1126
|
}
|
|
1124
1127
|
}
|
|
@@ -1131,8 +1134,8 @@ function recordMetricImpl(options) {
|
|
|
1131
1134
|
}
|
|
1132
1135
|
try {
|
|
1133
1136
|
callWithProperties(
|
|
1134
|
-
{ [
|
|
1135
|
-
() => emitEvent(
|
|
1137
|
+
{ [_chunk5WBPX342cjs.SESSION_ID]: sessionId },
|
|
1138
|
+
() => emitEvent(_chunk5WBPX342cjs.METRIC_EVENT_NAME, eventAttributes)
|
|
1136
1139
|
);
|
|
1137
1140
|
} catch (error) {
|
|
1138
1141
|
_chunkWC573FCIcjs.logger.warn("recordMetric: failed to emit metric event", error);
|
|
@@ -1140,19 +1143,19 @@ function recordMetricImpl(options) {
|
|
|
1140
1143
|
}
|
|
1141
1144
|
function startSession(sessionId, callback, extraProperties, options) {
|
|
1142
1145
|
const isTitle = _optionalChain([options, 'optionalAccess', _52 => _52.mode]) === "title";
|
|
1143
|
-
const spanName = isTitle ?
|
|
1146
|
+
const spanName = isTitle ? _chunk5WBPX342cjs.SESSION_TITLE_SPAN_NAME : _chunk5WBPX342cjs.SESSION_SPAN_NAME;
|
|
1144
1147
|
const tracer = _api.trace.getTracer("@brizz/sdk");
|
|
1145
1148
|
return tracer.startActiveSpan(spanName, (span) => {
|
|
1146
|
-
span.setAttribute(`${
|
|
1149
|
+
span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.SESSION_ID}`, sessionId);
|
|
1147
1150
|
if (extraProperties) {
|
|
1148
1151
|
for (const [key, value] of Object.entries(extraProperties)) {
|
|
1149
|
-
span.setAttribute(`${
|
|
1152
|
+
span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
|
|
1150
1153
|
}
|
|
1151
1154
|
}
|
|
1152
1155
|
const session = new Session(sessionId, span);
|
|
1153
|
-
const contextProperties = { [
|
|
1156
|
+
const contextProperties = { [_chunk5WBPX342cjs.SESSION_ID]: sessionId };
|
|
1154
1157
|
if (isTitle) {
|
|
1155
|
-
contextProperties[
|
|
1158
|
+
contextProperties[_chunk5WBPX342cjs.SESSION_TITLE_GENERATION] = "true";
|
|
1156
1159
|
}
|
|
1157
1160
|
if (extraProperties) {
|
|
1158
1161
|
for (const [key, value] of Object.entries(extraProperties)) {
|
|
@@ -1160,7 +1163,7 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
1160
1163
|
}
|
|
1161
1164
|
}
|
|
1162
1165
|
return callWithProperties(contextProperties, () => {
|
|
1163
|
-
const sessionCtx = _api.context.active().setValue(
|
|
1166
|
+
const sessionCtx = _api.context.active().setValue(_chunk5WBPX342cjs.SESSION_OBJECT_CONTEXT_KEY, session);
|
|
1164
1167
|
return _api.context.with(sessionCtx, () => {
|
|
1165
1168
|
try {
|
|
1166
1169
|
const result = callback(session);
|
|
@@ -1190,14 +1193,14 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
1190
1193
|
function startSessionTitle(callback, options) {
|
|
1191
1194
|
const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _53 => _53.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _54 => _54(), 'optionalAccess', _55 => _55.sessionId])));
|
|
1192
1195
|
const tracer = _api.trace.getTracer("@brizz/sdk");
|
|
1193
|
-
return tracer.startActiveSpan(
|
|
1196
|
+
return tracer.startActiveSpan(_chunk5WBPX342cjs.SESSION_TITLE_SPAN_NAME, (span) => {
|
|
1194
1197
|
if (resolvedSessionId) {
|
|
1195
|
-
span.setAttribute(`${
|
|
1198
|
+
span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.SESSION_ID}`, resolvedSessionId);
|
|
1196
1199
|
}
|
|
1197
1200
|
const sessionTitle = new SessionTitle(span);
|
|
1198
|
-
const properties = { [
|
|
1201
|
+
const properties = { [_chunk5WBPX342cjs.SESSION_TITLE_GENERATION]: "true" };
|
|
1199
1202
|
if (resolvedSessionId) {
|
|
1200
|
-
properties[
|
|
1203
|
+
properties[_chunk5WBPX342cjs.SESSION_ID] = resolvedSessionId;
|
|
1201
1204
|
}
|
|
1202
1205
|
return callWithProperties(properties, () => {
|
|
1203
1206
|
try {
|
|
@@ -1664,10 +1667,10 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
|
|
|
1664
1667
|
if (maskingConfig) {
|
|
1665
1668
|
maskLog(logRecord, maskingConfig);
|
|
1666
1669
|
}
|
|
1667
|
-
const associationProperties = _api.context.active().getValue(
|
|
1670
|
+
const associationProperties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
1668
1671
|
if (associationProperties) {
|
|
1669
1672
|
for (const [key, value] of Object.entries(associationProperties)) {
|
|
1670
|
-
logRecord.setAttribute(`${
|
|
1673
|
+
logRecord.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
|
|
1671
1674
|
}
|
|
1672
1675
|
}
|
|
1673
1676
|
super.onEmit(logRecord);
|
|
@@ -1684,10 +1687,10 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
|
|
|
1684
1687
|
if (maskingConfig) {
|
|
1685
1688
|
maskLog(logRecord, maskingConfig);
|
|
1686
1689
|
}
|
|
1687
|
-
const associationProperties = _api.context.active().getValue(
|
|
1690
|
+
const associationProperties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
1688
1691
|
if (associationProperties) {
|
|
1689
1692
|
for (const [key, value] of Object.entries(associationProperties)) {
|
|
1690
|
-
logRecord.setAttribute(`${
|
|
1693
|
+
logRecord.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
|
|
1691
1694
|
}
|
|
1692
1695
|
}
|
|
1693
1696
|
super.onEmit(logRecord);
|
|
@@ -1714,7 +1717,7 @@ function maskLog(logRecord, config) {
|
|
|
1714
1717
|
newAttributes[key] = value;
|
|
1715
1718
|
}
|
|
1716
1719
|
for (const [key, value] of Object.entries(logRecord.attributes)) {
|
|
1717
|
-
if (key.startsWith(
|
|
1720
|
+
if (key.startsWith(_chunk5WBPX342cjs.INTERNAL_EVENT_PREFIX)) {
|
|
1718
1721
|
newAttributes[key] = value;
|
|
1719
1722
|
}
|
|
1720
1723
|
}
|
|
@@ -1779,7 +1782,7 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
|
|
|
1779
1782
|
const resourceAttributes = {
|
|
1780
1783
|
...config.resourceAttributes,
|
|
1781
1784
|
"service.name": serviceName,
|
|
1782
|
-
[BRIZZ_SDK_VERSION]:
|
|
1785
|
+
[BRIZZ_SDK_VERSION]: _chunkA3HH5OULcjs.getSDKVersion.call(void 0, ),
|
|
1783
1786
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
1784
1787
|
};
|
|
1785
1788
|
if (config.environment) {
|
|
@@ -2028,7 +2031,7 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2028
2031
|
const resourceAttrs = {
|
|
2029
2032
|
...config.resourceAttributes,
|
|
2030
2033
|
"service.name": config.appName,
|
|
2031
|
-
[BRIZZ_SDK_VERSION]:
|
|
2034
|
+
[BRIZZ_SDK_VERSION]: _chunkA3HH5OULcjs.getSDKVersion.call(void 0, ),
|
|
2032
2035
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2033
2036
|
};
|
|
2034
2037
|
if (config.environment) {
|
|
@@ -2042,7 +2045,7 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2042
2045
|
}
|
|
2043
2046
|
/** The service a span reports under: its scoped override, else the configured appName. */
|
|
2044
2047
|
_serviceNameOf(span) {
|
|
2045
|
-
const value = span.attributes[
|
|
2048
|
+
const value = span.attributes[_chunk5WBPX342cjs.SERVICE_NAME_ATTRIBUTE];
|
|
2046
2049
|
return typeof value === "string" && value !== "" ? value : this._defaultServiceName;
|
|
2047
2050
|
}
|
|
2048
2051
|
_resourceFor(serviceName) {
|
|
@@ -2168,10 +2171,10 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2168
2171
|
|
|
2169
2172
|
var _sdktracebase = require('@opentelemetry/sdk-trace-base');
|
|
2170
2173
|
function applyContextAttributes(span) {
|
|
2171
|
-
const sessionProperties = _api.context.active().getValue(
|
|
2174
|
+
const sessionProperties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
2172
2175
|
if (sessionProperties) {
|
|
2173
2176
|
for (const [key, value] of Object.entries(sessionProperties)) {
|
|
2174
|
-
span.setAttribute(`${
|
|
2177
|
+
span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
|
|
2175
2178
|
}
|
|
2176
2179
|
}
|
|
2177
2180
|
}
|
|
@@ -2361,7 +2364,142 @@ function getSpanProcessor() {
|
|
|
2361
2364
|
return TracingModule.getInstance().getSpanProcessor();
|
|
2362
2365
|
}
|
|
2363
2366
|
|
|
2367
|
+
// src/internal/trace/agent.ts
|
|
2368
|
+
var _crypto = require('crypto');
|
|
2369
|
+
|
|
2370
|
+
function newInstanceId() {
|
|
2371
|
+
return _crypto.randomUUID.call(void 0, ).replaceAll("-", "").slice(0, 8);
|
|
2372
|
+
}
|
|
2373
|
+
function activeProperties() {
|
|
2374
|
+
return _nullishCoalesce(_api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY), () => ( {}));
|
|
2375
|
+
}
|
|
2376
|
+
function encodeToken(agent) {
|
|
2377
|
+
const payload = {
|
|
2378
|
+
id: agent.id,
|
|
2379
|
+
parentId: agent.parentId,
|
|
2380
|
+
name: agent.name,
|
|
2381
|
+
traceparent: agent.traceparent,
|
|
2382
|
+
sessionId: agent.sessionId
|
|
2383
|
+
};
|
|
2384
|
+
return Buffer.from(JSON.stringify(payload), "utf8").toString("base64url");
|
|
2385
|
+
}
|
|
2386
|
+
function currentTraceparent() {
|
|
2387
|
+
const carrier = {};
|
|
2388
|
+
try {
|
|
2389
|
+
_api.propagation.inject(_api.context.active(), carrier);
|
|
2390
|
+
} catch (e4) {
|
|
2391
|
+
}
|
|
2392
|
+
return _nullishCoalesce(carrier["traceparent"], () => ( ""));
|
|
2393
|
+
}
|
|
2394
|
+
function agentHandle(id, parentId, name) {
|
|
2395
|
+
const opened = {
|
|
2396
|
+
id,
|
|
2397
|
+
parentId,
|
|
2398
|
+
name,
|
|
2399
|
+
traceparent: currentTraceparent(),
|
|
2400
|
+
sessionId: _nullishCoalesce(activeProperties()[_chunk5WBPX342cjs.SESSION_ID], () => ( ""))
|
|
2401
|
+
};
|
|
2402
|
+
return {
|
|
2403
|
+
...opened,
|
|
2404
|
+
get token() {
|
|
2405
|
+
return encodeToken(opened);
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
function decodeToken(token) {
|
|
2410
|
+
try {
|
|
2411
|
+
const payload = JSON.parse(Buffer.from(token, "base64url").toString("utf8"));
|
|
2412
|
+
return payload.id ? payload : void 0;
|
|
2413
|
+
} catch (e5) {
|
|
2414
|
+
return void 0;
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
function unreadableAgent(agent) {
|
|
2418
|
+
return {
|
|
2419
|
+
id: "",
|
|
2420
|
+
parentId: "",
|
|
2421
|
+
name: "",
|
|
2422
|
+
traceparent: "",
|
|
2423
|
+
sessionId: "",
|
|
2424
|
+
token: typeof agent === "string" ? "" : _nullishCoalesce(agent.token, () => ( ""))
|
|
2425
|
+
};
|
|
2426
|
+
}
|
|
2427
|
+
function resolveAgent(agent) {
|
|
2428
|
+
const options = typeof agent === "string" ? { name: agent } : agent;
|
|
2429
|
+
let id;
|
|
2430
|
+
let parentId;
|
|
2431
|
+
let name;
|
|
2432
|
+
let sessionId = "";
|
|
2433
|
+
let parentContext = _api.context.active();
|
|
2434
|
+
if (options.token === void 0) {
|
|
2435
|
+
id = options.id || newInstanceId();
|
|
2436
|
+
parentId = options.parentId || activeProperties()[_chunk5WBPX342cjs.AGENT_ID] || "";
|
|
2437
|
+
name = _nullishCoalesce(options.name, () => ( ""));
|
|
2438
|
+
} else {
|
|
2439
|
+
const decoded = decodeToken(options.token);
|
|
2440
|
+
if (!decoded) {
|
|
2441
|
+
_chunkWC573FCIcjs.logger.warn("Brizz: ignoring an unreadable agent token");
|
|
2442
|
+
return void 0;
|
|
2443
|
+
}
|
|
2444
|
+
id = decoded.id;
|
|
2445
|
+
parentId = decoded.parentId;
|
|
2446
|
+
name = decoded.name;
|
|
2447
|
+
sessionId = decoded.sessionId;
|
|
2448
|
+
if (decoded.traceparent) {
|
|
2449
|
+
try {
|
|
2450
|
+
parentContext = _api.propagation.extract(parentContext, { traceparent: decoded.traceparent });
|
|
2451
|
+
} catch (e6) {
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
const properties = { [_chunk5WBPX342cjs.AGENT_ID]: id, [_chunk5WBPX342cjs.AGENT_NAME]: name };
|
|
2456
|
+
if (parentId) {
|
|
2457
|
+
properties[_chunk5WBPX342cjs.AGENT_PARENT_ID] = parentId;
|
|
2458
|
+
}
|
|
2459
|
+
if (sessionId) {
|
|
2460
|
+
properties[_chunk5WBPX342cjs.SESSION_ID] = sessionId;
|
|
2461
|
+
}
|
|
2462
|
+
return { id, parentId, name, properties, parentContext };
|
|
2463
|
+
}
|
|
2464
|
+
function startAgent(agent, callback) {
|
|
2465
|
+
const resolved = resolveAgent(agent);
|
|
2466
|
+
if (!resolved) {
|
|
2467
|
+
return callback(unreadableAgent(agent));
|
|
2468
|
+
}
|
|
2469
|
+
const { id, parentId, name, properties, parentContext } = resolved;
|
|
2470
|
+
return _api.context.with(
|
|
2471
|
+
parentContext,
|
|
2472
|
+
() => callWithProperties(properties, () => callback(agentHandle(id, parentId, name)))
|
|
2473
|
+
);
|
|
2474
|
+
}
|
|
2475
|
+
function withAgent(agent, fn, thisArg) {
|
|
2476
|
+
return function wrapped(...args) {
|
|
2477
|
+
return startAgent(
|
|
2478
|
+
agent,
|
|
2479
|
+
() => fn.apply(thisArg !== void 0 ? thisArg : this, args)
|
|
2480
|
+
);
|
|
2481
|
+
};
|
|
2482
|
+
}
|
|
2483
|
+
function setAgent(agent) {
|
|
2484
|
+
const resolved = resolveAgent(agent);
|
|
2485
|
+
if (!resolved) {
|
|
2486
|
+
return unreadableAgent(agent);
|
|
2487
|
+
}
|
|
2488
|
+
const { id, parentId, name, properties, parentContext } = resolved;
|
|
2489
|
+
setCurrentSpanCustomProperties(properties);
|
|
2490
|
+
propagatePropertiesImperatively(properties, parentContext);
|
|
2491
|
+
return agentHandle(id, parentId, name);
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2364
2494
|
// src/internal/sdk.ts
|
|
2495
|
+
function resolveMcpSessionTracking(configured) {
|
|
2496
|
+
const fromEnv = process.env["BRIZZ_MCP_SESSION_TRACKING"];
|
|
2497
|
+
if (fromEnv === void 0) {
|
|
2498
|
+
return configured;
|
|
2499
|
+
}
|
|
2500
|
+
const enabled = fromEnv === "true";
|
|
2501
|
+
return typeof configured === "object" ? { ...configured, enabled } : enabled;
|
|
2502
|
+
}
|
|
2365
2503
|
var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init15.call(this);_class7.prototype.__init16.call(this);_class7.prototype.__init17.call(this); }
|
|
2366
2504
|
static __initStatic4() {this.instance = null}
|
|
2367
2505
|
static getInstance() {
|
|
@@ -2382,6 +2520,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
2382
2520
|
*/
|
|
2383
2521
|
setupInstrumentation(options) {
|
|
2384
2522
|
const registry = InstrumentationRegistry.getInstance();
|
|
2523
|
+
_chunkA3HH5OULcjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
|
|
2385
2524
|
if (options.instrumentModules && Object.keys(options.instrumentModules).length > 0) {
|
|
2386
2525
|
registry.setManualModules(options.instrumentModules);
|
|
2387
2526
|
}
|
|
@@ -2404,7 +2543,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
2404
2543
|
const resourceAttributes = {
|
|
2405
2544
|
...resolvedConfig.resourceAttributes,
|
|
2406
2545
|
"service.name": resolvedConfig.appName,
|
|
2407
|
-
[BRIZZ_SDK_VERSION]:
|
|
2546
|
+
[BRIZZ_SDK_VERSION]: _chunkA3HH5OULcjs.getSDKVersion.call(void 0, ),
|
|
2408
2547
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2409
2548
|
};
|
|
2410
2549
|
if (resolvedConfig.environment) {
|
|
@@ -2416,7 +2555,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
2416
2555
|
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));
|
|
2417
2556
|
this._tracerProvider = new (0, _sdktracenode.NodeTracerProvider)({
|
|
2418
2557
|
resource,
|
|
2419
|
-
spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0,
|
|
2558
|
+
spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunk3IGBYXLRcjs.InterruptPropagator)(), getSpanProcessor()]
|
|
2420
2559
|
});
|
|
2421
2560
|
this._tracerProvider.register();
|
|
2422
2561
|
this._meterProvider = new (0, _sdkmetrics.MeterProvider)({ resource, readers: [getMetricsReader()] });
|
|
@@ -2474,19 +2613,19 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
2474
2613
|
try {
|
|
2475
2614
|
const tracingModule = TracingModule.getInstance();
|
|
2476
2615
|
await tracingModule.shutdown();
|
|
2477
|
-
} catch (
|
|
2616
|
+
} catch (e7) {
|
|
2478
2617
|
_chunkWC573FCIcjs.logger.debug("Tracing module already shut down or not initialized");
|
|
2479
2618
|
}
|
|
2480
2619
|
try {
|
|
2481
2620
|
const metricsModule = MetricsModule.getInstance();
|
|
2482
2621
|
metricsModule.shutdown();
|
|
2483
|
-
} catch (
|
|
2622
|
+
} catch (e8) {
|
|
2484
2623
|
_chunkWC573FCIcjs.logger.debug("Metrics module already shut down or not initialized");
|
|
2485
2624
|
}
|
|
2486
2625
|
try {
|
|
2487
2626
|
const loggingModule = LoggingModule.getInstance();
|
|
2488
2627
|
await loggingModule.shutdown();
|
|
2489
|
-
} catch (
|
|
2628
|
+
} catch (e9) {
|
|
2490
2629
|
_chunkWC573FCIcjs.logger.debug("Logging module already shut down or not initialized");
|
|
2491
2630
|
}
|
|
2492
2631
|
_chunkWC573FCIcjs.logger.info("All telemetry modules shut down successfully");
|
|
@@ -2619,4 +2758,7 @@ var Brizz = new _Brizz();
|
|
|
2619
2758
|
|
|
2620
2759
|
|
|
2621
2760
|
|
|
2622
|
-
|
|
2761
|
+
|
|
2762
|
+
|
|
2763
|
+
|
|
2764
|
+
exports.Brizz = Brizz; exports.DEFAULT_PII_PATTERNS = DEFAULT_PII_PATTERNS; exports.LogLevel = _chunkWC573FCIcjs.LogLevel; exports.Session = Session; exports.SessionTitle = SessionTitle; exports.SeverityNumber = _apilogs.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.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;
|