@brizz/sdk 0.1.41 → 0.1.43
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 +25 -0
- package/dist/chunk-5SWAZUC5.js +240 -0
- package/dist/{chunk-EC3MYSRM.js → chunk-7FQQHF5U.js} +1 -1
- package/dist/{chunk-77UGZGMP.cjs → chunk-FORVS4QW.cjs} +5 -1
- package/dist/{chunk-EVRCHF74.cjs → chunk-QUV5HYJ2.cjs} +4 -4
- package/dist/chunk-WTQTF57J.cjs +240 -0
- package/dist/{chunk-WII4R5RE.js → chunk-Y7NMZAQT.js} +4 -0
- package/dist/index.cjs +360 -229
- package/dist/index.js +215 -84
- package/dist/interrupt-3NXOTY4N.cjs +12 -0
- package/dist/{interrupt-YJVZK4VC.js → interrupt-ERCX5RXR.js} +2 -2
- package/dist/{mcp-TI3IDGUJ.js → mcp-6R6KZ5U3.js} +83 -86
- package/dist/{mcp-DU7AUWUH.cjs → mcp-UJD6KF7G.cjs} +97 -100
- package/dist/types/cjs/index.d.ts +1 -1
- 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/log/logging.d.ts +5 -5
- package/dist/types/cjs/internal/sdk.d.ts +2 -0
- package/dist/types/cjs/internal/semantic-conventions.d.ts +2 -0
- package/dist/types/cjs/internal/trace/exporters/span-exporter.d.ts +11 -2
- package/dist/types/cjs/internal/trace/index.d.ts +1 -1
- package/dist/types/cjs/internal/trace/session.d.ts +4 -0
- package/dist/types/esm/index.d.ts +1 -1
- 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/log/logging.d.ts +5 -5
- package/dist/types/esm/internal/sdk.d.ts +2 -0
- package/dist/types/esm/internal/semantic-conventions.d.ts +2 -0
- package/dist/types/esm/internal/trace/exporters/span-exporter.d.ts +11 -2
- package/dist/types/esm/internal/trace/index.d.ts +1 -1
- package/dist/types/esm/internal/trace/session.d.ts +4 -0
- package/package.json +13 -13
- package/dist/chunk-3QYP2SDN.cjs +0 -8
- package/dist/chunk-QRHMDRW6.js +0 -8
- package/dist/interrupt-DM3AWSBX.cjs +0 -12
package/dist/index.js
CHANGED
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
parseDSN
|
|
4
4
|
} from "./chunk-7SUF4VVI.js";
|
|
5
5
|
import {
|
|
6
|
+
configure,
|
|
6
7
|
getSDKVersion
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5SWAZUC5.js";
|
|
8
9
|
import {
|
|
9
10
|
DEFAULT_LOG_LEVEL,
|
|
10
11
|
LogLevel,
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
} from "./chunk-Y4HNUX3Q.js";
|
|
16
17
|
import {
|
|
17
18
|
InterruptPropagator
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-7FQQHF5U.js";
|
|
19
20
|
import {
|
|
20
21
|
BRIZZ,
|
|
21
22
|
EXTERNAL_LINK_EVENT_NAME,
|
|
@@ -52,6 +53,8 @@ import {
|
|
|
52
53
|
ORGANIZATION_PLAN,
|
|
53
54
|
PROPERTIES_CONTEXT_KEY,
|
|
54
55
|
RESERVED_METRIC_NAMES,
|
|
56
|
+
SERVICE_NAME,
|
|
57
|
+
SERVICE_NAME_ATTRIBUTE,
|
|
55
58
|
SESSION_ID,
|
|
56
59
|
SESSION_INPUT,
|
|
57
60
|
SESSION_INPUT_CONTEXT,
|
|
@@ -67,7 +70,7 @@ import {
|
|
|
67
70
|
USER_NAME,
|
|
68
71
|
USER_PLAN,
|
|
69
72
|
USER_ROLE
|
|
70
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-Y7NMZAQT.js";
|
|
71
74
|
import {
|
|
72
75
|
__require
|
|
73
76
|
} from "./chunk-3RG5ZIWI.js";
|
|
@@ -124,7 +127,7 @@ function loadGenAIInstrumentations() {
|
|
|
124
127
|
function loadMCPInstrumentation() {
|
|
125
128
|
void (async () => {
|
|
126
129
|
try {
|
|
127
|
-
const { MCPInstrumentation } = await import("./mcp-
|
|
130
|
+
const { MCPInstrumentation } = await import("./mcp-6R6KZ5U3.js");
|
|
128
131
|
const mcp = new MCPInstrumentation({ exceptionLogger });
|
|
129
132
|
registerInstrumentations({ instrumentations: [mcp] });
|
|
130
133
|
logger.debug("Auto-loaded MCP instrumentation");
|
|
@@ -180,7 +183,7 @@ function loadVercelAITelemetry() {
|
|
|
180
183
|
}
|
|
181
184
|
const isV7 = typeof ai.registerTelemetry === "function";
|
|
182
185
|
const integrations = [];
|
|
183
|
-
const { createInterruptIntegration } = await import("./interrupt-
|
|
186
|
+
const { createInterruptIntegration } = await import("./interrupt-ERCX5RXR.js");
|
|
184
187
|
integrations.push(createInterruptIntegration());
|
|
185
188
|
let otelCollectorLoaded = false;
|
|
186
189
|
try {
|
|
@@ -507,7 +510,7 @@ var InstrumentationRegistry = class _InstrumentationRegistry {
|
|
|
507
510
|
const mcpModules = this.manualModules.mcp;
|
|
508
511
|
void (async () => {
|
|
509
512
|
try {
|
|
510
|
-
const { MCPInstrumentation } = await import("./mcp-
|
|
513
|
+
const { MCPInstrumentation } = await import("./mcp-6R6KZ5U3.js");
|
|
511
514
|
const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
|
|
512
515
|
instrumentation.manuallyInstrument(mcpModules);
|
|
513
516
|
logger.debug("Manual instrumentation enabled for MCP");
|
|
@@ -547,9 +550,7 @@ var InstrumentationRegistry = class _InstrumentationRegistry {
|
|
|
547
550
|
import { SeverityNumber } from "@opentelemetry/api-logs";
|
|
548
551
|
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
|
|
549
552
|
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
550
|
-
import {
|
|
551
|
-
LoggerProvider
|
|
552
|
-
} from "@opentelemetry/sdk-logs";
|
|
553
|
+
import { LoggerProvider } from "@opentelemetry/sdk-logs";
|
|
553
554
|
|
|
554
555
|
// src/internal/trace/session.ts
|
|
555
556
|
import { context, trace, SpanStatusCode } from "@opentelemetry/api";
|
|
@@ -654,6 +655,42 @@ function setSessionId(id) {
|
|
|
654
655
|
setCurrentSpanCustomProperties(properties);
|
|
655
656
|
propagatePropertiesImperatively(properties);
|
|
656
657
|
}
|
|
658
|
+
var SERVICE_NAME_MAX_BYTES = 256;
|
|
659
|
+
function serviceNameProperties(name) {
|
|
660
|
+
if (typeof name !== "string" || name === "") {
|
|
661
|
+
logger.warn("Service name must be a non-empty string; keeping the configured appName.");
|
|
662
|
+
return {};
|
|
663
|
+
}
|
|
664
|
+
if (/[\r\n\0]/.test(name)) {
|
|
665
|
+
logger.warn(
|
|
666
|
+
`Service name ${JSON.stringify(name)} contains CR, LF, or NUL; keeping the configured appName.`
|
|
667
|
+
);
|
|
668
|
+
return {};
|
|
669
|
+
}
|
|
670
|
+
const byteLength = new globalThis.TextEncoder().encode(name).length;
|
|
671
|
+
if (byteLength > SERVICE_NAME_MAX_BYTES) {
|
|
672
|
+
logger.warn(
|
|
673
|
+
`Service name is ${byteLength} bytes, over the ${SERVICE_NAME_MAX_BYTES}-byte limit; keeping the configured appName.`
|
|
674
|
+
);
|
|
675
|
+
return {};
|
|
676
|
+
}
|
|
677
|
+
return { [SERVICE_NAME]: name };
|
|
678
|
+
}
|
|
679
|
+
function setServiceName(name) {
|
|
680
|
+
const properties = serviceNameProperties(name);
|
|
681
|
+
setCurrentSpanCustomProperties(properties);
|
|
682
|
+
propagatePropertiesImperatively(properties);
|
|
683
|
+
}
|
|
684
|
+
function callWithServiceName(name, fn, thisArg, ...args) {
|
|
685
|
+
return callWithProperties(serviceNameProperties(name), fn, thisArg, ...args);
|
|
686
|
+
}
|
|
687
|
+
function withServiceName(name, fn, thisArg) {
|
|
688
|
+
return withProperties(serviceNameProperties(name), fn, thisArg);
|
|
689
|
+
}
|
|
690
|
+
function resolveServiceNameFromContext() {
|
|
691
|
+
const props = context.active().getValue(PROPERTIES_CONTEXT_KEY);
|
|
692
|
+
return props?.[SERVICE_NAME];
|
|
693
|
+
}
|
|
657
694
|
function userProperties(user) {
|
|
658
695
|
const properties = { [USER_ID]: user.id };
|
|
659
696
|
if (user.email !== void 0) {
|
|
@@ -1708,67 +1745,41 @@ var LoggingModule = class _LoggingModule {
|
|
|
1708
1745
|
}
|
|
1709
1746
|
return this.instance;
|
|
1710
1747
|
}
|
|
1711
|
-
|
|
1712
|
-
logProcessor = null;
|
|
1748
|
+
config = null;
|
|
1713
1749
|
loggerProvider = null;
|
|
1750
|
+
/** Providers for scoped service names, keyed by service name. */
|
|
1751
|
+
scopedProviders = /* @__PURE__ */ new Map();
|
|
1714
1752
|
/**
|
|
1715
|
-
*
|
|
1753
|
+
* Build the log exporter for a service. The service header is fixed per
|
|
1754
|
+
* exporter and the gateway rewrites service.name from it, so each service
|
|
1755
|
+
* needs its own. A custom exporter is used as-is — the resource still
|
|
1756
|
+
* carries the right service.name.
|
|
1716
1757
|
*/
|
|
1717
|
-
|
|
1718
|
-
if (this.logExporter) {
|
|
1719
|
-
logger.debug("Log exporter already initialized, skipping re-initialization");
|
|
1720
|
-
return;
|
|
1721
|
-
}
|
|
1758
|
+
createLogExporter(config, serviceName) {
|
|
1722
1759
|
if (config.customLogExporter) {
|
|
1723
1760
|
logger.debug("Using custom log exporter");
|
|
1724
|
-
|
|
1725
|
-
logger.debug("Custom log exporter initialized successfully");
|
|
1726
|
-
return;
|
|
1761
|
+
return config.customLogExporter;
|
|
1727
1762
|
}
|
|
1728
1763
|
const logsUrl = config.baseUrl.replace(/\/$/, "") + "/v1/logs";
|
|
1729
|
-
logger.debug("Initializing default OTLP log exporter", { url: logsUrl });
|
|
1730
|
-
const headers = { ...config.headers };
|
|
1731
|
-
|
|
1732
|
-
url: logsUrl,
|
|
1733
|
-
headers
|
|
1734
|
-
});
|
|
1735
|
-
logger.debug("OTLP log exporter initialized successfully");
|
|
1764
|
+
logger.debug("Initializing default OTLP log exporter", { url: logsUrl, serviceName });
|
|
1765
|
+
const headers = serviceName === config.appName ? { ...config.headers } : { ...config.headers, [SERVICE_NAME_HEADER]: serviceName };
|
|
1766
|
+
return new OTLPLogExporter({ url: logsUrl, headers });
|
|
1736
1767
|
}
|
|
1737
1768
|
/**
|
|
1738
|
-
*
|
|
1769
|
+
* Build a logger provider reporting under `serviceName`, with its own
|
|
1770
|
+
* exporter and masking-aware processor.
|
|
1739
1771
|
*/
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
return;
|
|
1744
|
-
}
|
|
1745
|
-
if (!this.logExporter) {
|
|
1746
|
-
throw new Error("Log exporter must be initialized before processor");
|
|
1747
|
-
}
|
|
1748
|
-
logger.debug("Initializing log processor", {
|
|
1772
|
+
createLoggerProvider(config, serviceName) {
|
|
1773
|
+
logger.debug("Creating logger provider", {
|
|
1774
|
+
serviceName,
|
|
1749
1775
|
disableBatch: config.disableBatch,
|
|
1750
1776
|
hasMasking: !!config.masking?.eventMasking
|
|
1751
1777
|
});
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
}
|
|
1755
|
-
/**
|
|
1756
|
-
* Initialize the logger provider
|
|
1757
|
-
*/
|
|
1758
|
-
initLoggerProvider(config) {
|
|
1759
|
-
if (this.loggerProvider) {
|
|
1760
|
-
logger.debug("Logger provider already initialized, skipping re-initialization");
|
|
1761
|
-
return;
|
|
1762
|
-
}
|
|
1763
|
-
if (!this.logProcessor) {
|
|
1764
|
-
throw new Error("Log processor must be initialized before logger provider");
|
|
1765
|
-
}
|
|
1766
|
-
logger.debug("Creating resource with service name", {
|
|
1767
|
-
serviceName: config.appName
|
|
1768
|
-
});
|
|
1778
|
+
const exporter = this.createLogExporter(config, serviceName);
|
|
1779
|
+
const processor = config.disableBatch ? new BrizzSimpleLogRecordProcessor(exporter, config) : new BrizzBatchLogRecordProcessor(exporter, config);
|
|
1769
1780
|
const resourceAttributes = {
|
|
1770
1781
|
...config.resourceAttributes,
|
|
1771
|
-
"service.name":
|
|
1782
|
+
"service.name": serviceName,
|
|
1772
1783
|
[BRIZZ_SDK_VERSION]: getSDKVersion(),
|
|
1773
1784
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
1774
1785
|
};
|
|
@@ -1778,22 +1789,38 @@ var LoggingModule = class _LoggingModule {
|
|
|
1778
1789
|
if (config.appVersion) {
|
|
1779
1790
|
resourceAttributes["service.version"] = config.appVersion;
|
|
1780
1791
|
}
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
resource,
|
|
1785
|
-
processors: [this.logProcessor]
|
|
1792
|
+
return new LoggerProvider({
|
|
1793
|
+
resource: resourceFromAttributes(resourceAttributes),
|
|
1794
|
+
processors: [processor]
|
|
1786
1795
|
});
|
|
1787
|
-
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* The provider events emit through: the scoped service name from
|
|
1799
|
+
* `callWithServiceName`, else the configured appName.
|
|
1800
|
+
*/
|
|
1801
|
+
activeLoggerProvider() {
|
|
1802
|
+
const serviceName = resolveServiceNameFromContext();
|
|
1803
|
+
if (!serviceName || !this.config || serviceName === this.config.appName) {
|
|
1804
|
+
return this.loggerProvider;
|
|
1805
|
+
}
|
|
1806
|
+
let provider = this.scopedProviders.get(serviceName);
|
|
1807
|
+
if (!provider) {
|
|
1808
|
+
provider = this.createLoggerProvider(this.config, serviceName);
|
|
1809
|
+
this.scopedProviders.set(serviceName, provider);
|
|
1810
|
+
}
|
|
1811
|
+
return provider;
|
|
1788
1812
|
}
|
|
1789
1813
|
/**
|
|
1790
1814
|
* Initialize the logging module with the provided configuration
|
|
1791
1815
|
*/
|
|
1792
1816
|
setup(config) {
|
|
1793
1817
|
logger.info("Setting up logging module");
|
|
1794
|
-
this.
|
|
1795
|
-
this.
|
|
1796
|
-
|
|
1818
|
+
this.config = config;
|
|
1819
|
+
if (this.loggerProvider) {
|
|
1820
|
+
logger.debug("Logger provider already initialized, skipping re-initialization");
|
|
1821
|
+
} else {
|
|
1822
|
+
this.loggerProvider = this.createLoggerProvider(config, config.appName);
|
|
1823
|
+
}
|
|
1797
1824
|
_LoggingModule.instance = this;
|
|
1798
1825
|
logger.info("Logging module setup completed");
|
|
1799
1826
|
}
|
|
@@ -1808,7 +1835,8 @@ var LoggingModule = class _LoggingModule {
|
|
|
1808
1835
|
hasBody: !!body,
|
|
1809
1836
|
severityNumber
|
|
1810
1837
|
});
|
|
1811
|
-
|
|
1838
|
+
const provider = this.activeLoggerProvider();
|
|
1839
|
+
if (!provider) {
|
|
1812
1840
|
logger.error("Cannot emit event: Logger provider not initialized");
|
|
1813
1841
|
throw new Error("Logging module not initialized");
|
|
1814
1842
|
}
|
|
@@ -1818,7 +1846,7 @@ var LoggingModule = class _LoggingModule {
|
|
|
1818
1846
|
logger.debug("Combined log attributes", { attributes: Object.keys(logAttributes) });
|
|
1819
1847
|
}
|
|
1820
1848
|
logger.debug("Getting logger instance for brizz_events");
|
|
1821
|
-
const eventLogger =
|
|
1849
|
+
const eventLogger = provider.getLogger("brizz.events");
|
|
1822
1850
|
logger.debug("Emitting log record with eventName", { eventName: name });
|
|
1823
1851
|
try {
|
|
1824
1852
|
eventLogger.emit({
|
|
@@ -1860,8 +1888,9 @@ var LoggingModule = class _LoggingModule {
|
|
|
1860
1888
|
await this.loggerProvider.shutdown();
|
|
1861
1889
|
this.loggerProvider = null;
|
|
1862
1890
|
}
|
|
1863
|
-
this.
|
|
1864
|
-
this.
|
|
1891
|
+
await Promise.all([...this.scopedProviders.values()].map(async (p) => p.shutdown()));
|
|
1892
|
+
this.scopedProviders.clear();
|
|
1893
|
+
this.config = null;
|
|
1865
1894
|
if (_LoggingModule.instance === this) {
|
|
1866
1895
|
_LoggingModule.instance = null;
|
|
1867
1896
|
}
|
|
@@ -1987,10 +2016,16 @@ import { ExportResultCode } from "@opentelemetry/core";
|
|
|
1987
2016
|
import { resourceFromAttributes as resourceFromAttributes2 } from "@opentelemetry/resources";
|
|
1988
2017
|
var BrizzSpanExporter = class {
|
|
1989
2018
|
_delegate;
|
|
1990
|
-
|
|
2019
|
+
_delegateFactory;
|
|
2020
|
+
_defaultServiceName;
|
|
2021
|
+
_resourceAttrs;
|
|
2022
|
+
_resources = /* @__PURE__ */ new Map();
|
|
2023
|
+
_delegates = /* @__PURE__ */ new Map();
|
|
1991
2024
|
_beforeSendSpan;
|
|
1992
|
-
constructor(delegate, config) {
|
|
2025
|
+
constructor(delegate, config, factory) {
|
|
1993
2026
|
this._delegate = delegate;
|
|
2027
|
+
this._delegateFactory = factory;
|
|
2028
|
+
this._defaultServiceName = config.appName;
|
|
1994
2029
|
const resourceAttrs = {
|
|
1995
2030
|
...config.resourceAttributes,
|
|
1996
2031
|
"service.name": config.appName,
|
|
@@ -2003,24 +2038,63 @@ var BrizzSpanExporter = class {
|
|
|
2003
2038
|
if (config.appVersion) {
|
|
2004
2039
|
resourceAttrs["service.version"] = config.appVersion;
|
|
2005
2040
|
}
|
|
2006
|
-
this.
|
|
2041
|
+
this._resourceAttrs = resourceAttrs;
|
|
2007
2042
|
this._beforeSendSpan = config.beforeSendSpan;
|
|
2008
2043
|
}
|
|
2044
|
+
/** The service a span reports under: its scoped override, else the configured appName. */
|
|
2045
|
+
_serviceNameOf(span) {
|
|
2046
|
+
const value = span.attributes[SERVICE_NAME_ATTRIBUTE];
|
|
2047
|
+
return typeof value === "string" && value !== "" ? value : this._defaultServiceName;
|
|
2048
|
+
}
|
|
2049
|
+
_resourceFor(serviceName) {
|
|
2050
|
+
let resource = this._resources.get(serviceName);
|
|
2051
|
+
if (!resource) {
|
|
2052
|
+
resource = resourceFromAttributes2({ ...this._resourceAttrs, "service.name": serviceName });
|
|
2053
|
+
this._resources.set(serviceName, resource);
|
|
2054
|
+
}
|
|
2055
|
+
return resource;
|
|
2056
|
+
}
|
|
2057
|
+
/**
|
|
2058
|
+
* Without a factory (a custom exporter, e.g. in tests) every service shares the
|
|
2059
|
+
* one delegate — the patched Resource still carries the right service.name.
|
|
2060
|
+
*/
|
|
2061
|
+
_delegateFor(serviceName) {
|
|
2062
|
+
if (serviceName === this._defaultServiceName || !this._delegateFactory) {
|
|
2063
|
+
return this._delegate;
|
|
2064
|
+
}
|
|
2065
|
+
let delegate = this._delegates.get(serviceName);
|
|
2066
|
+
if (!delegate) {
|
|
2067
|
+
delegate = this._delegateFactory(serviceName);
|
|
2068
|
+
this._delegates.set(serviceName, delegate);
|
|
2069
|
+
}
|
|
2070
|
+
return delegate;
|
|
2071
|
+
}
|
|
2009
2072
|
export(spans, resultCallback) {
|
|
2010
2073
|
if (spans.length === 0) {
|
|
2011
2074
|
resultCallback({ code: ExportResultCode.SUCCESS });
|
|
2012
2075
|
return;
|
|
2013
2076
|
}
|
|
2014
|
-
const
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2077
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2078
|
+
for (const span of spans) {
|
|
2079
|
+
const serviceName = this._serviceNameOf(span);
|
|
2080
|
+
const patched = {
|
|
2081
|
+
...span,
|
|
2082
|
+
resource: span.resource.merge(this._resourceFor(serviceName)),
|
|
2083
|
+
spanContext: span.spanContext.bind(span)
|
|
2084
|
+
};
|
|
2085
|
+
const group = groups.get(serviceName);
|
|
2086
|
+
if (group) {
|
|
2087
|
+
group.push(patched);
|
|
2088
|
+
} else {
|
|
2089
|
+
groups.set(serviceName, [patched]);
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2019
2092
|
const filter = this._beforeSendSpan;
|
|
2020
2093
|
if (!filter) {
|
|
2021
|
-
this.
|
|
2094
|
+
this._exportGroups(groups, resultCallback);
|
|
2022
2095
|
return;
|
|
2023
2096
|
}
|
|
2097
|
+
const patchedSpans = [...groups.values()].flat();
|
|
2024
2098
|
const verdicts = patchedSpans.map((span) => {
|
|
2025
2099
|
try {
|
|
2026
2100
|
return Promise.resolve(filter(span));
|
|
@@ -2030,23 +2104,61 @@ var BrizzSpanExporter = class {
|
|
|
2030
2104
|
}
|
|
2031
2105
|
});
|
|
2032
2106
|
Promise.all(verdicts).then((keep) => {
|
|
2033
|
-
const
|
|
2034
|
-
|
|
2107
|
+
const kept = new Set(patchedSpans.filter((_, i) => keep[i] !== false));
|
|
2108
|
+
const filtered = /* @__PURE__ */ new Map();
|
|
2109
|
+
for (const [serviceName, group] of groups) {
|
|
2110
|
+
const remaining = group.filter((span) => kept.has(span));
|
|
2111
|
+
if (remaining.length > 0) {
|
|
2112
|
+
filtered.set(serviceName, remaining);
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
if (filtered.size === 0) {
|
|
2035
2116
|
resultCallback({ code: ExportResultCode.SUCCESS });
|
|
2036
2117
|
return;
|
|
2037
2118
|
}
|
|
2038
|
-
this.
|
|
2119
|
+
this._exportGroups(filtered, resultCallback);
|
|
2039
2120
|
return;
|
|
2040
2121
|
}).catch((error) => {
|
|
2041
2122
|
logger.warn("beforeSendSpan rejected; all spans will be kept", { error });
|
|
2042
|
-
this.
|
|
2123
|
+
this._exportGroups(groups, resultCallback);
|
|
2043
2124
|
});
|
|
2044
2125
|
}
|
|
2126
|
+
/**
|
|
2127
|
+
* Dispatch each service's spans to its own exporter, reporting the first
|
|
2128
|
+
* failure once every group has answered.
|
|
2129
|
+
*/
|
|
2130
|
+
_exportGroups(groups, resultCallback) {
|
|
2131
|
+
const entries = [...groups.entries()];
|
|
2132
|
+
const only = entries[0];
|
|
2133
|
+
if (entries.length === 1 && only) {
|
|
2134
|
+
this._delegateFor(only[0]).export(only[1], resultCallback);
|
|
2135
|
+
return;
|
|
2136
|
+
}
|
|
2137
|
+
let pending = entries.length;
|
|
2138
|
+
let failure;
|
|
2139
|
+
for (const [serviceName, group] of entries) {
|
|
2140
|
+
this._delegateFor(serviceName).export(group, (result) => {
|
|
2141
|
+
if (result.code !== ExportResultCode.SUCCESS && !failure) {
|
|
2142
|
+
failure = result;
|
|
2143
|
+
}
|
|
2144
|
+
pending -= 1;
|
|
2145
|
+
if (pending === 0) {
|
|
2146
|
+
resultCallback(failure ?? { code: ExportResultCode.SUCCESS });
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2045
2151
|
async shutdown() {
|
|
2046
|
-
|
|
2152
|
+
await Promise.all([
|
|
2153
|
+
this._delegate.shutdown(),
|
|
2154
|
+
...[...this._delegates.values()].map(async (delegate) => delegate.shutdown())
|
|
2155
|
+
]);
|
|
2047
2156
|
}
|
|
2048
2157
|
async forceFlush() {
|
|
2049
|
-
|
|
2158
|
+
await Promise.all([
|
|
2159
|
+
this._delegate.forceFlush?.(),
|
|
2160
|
+
...[...this._delegates.values()].map(async (delegate) => delegate.forceFlush?.())
|
|
2161
|
+
]);
|
|
2050
2162
|
}
|
|
2051
2163
|
};
|
|
2052
2164
|
|
|
@@ -2163,7 +2275,14 @@ var TracingModule = class _TracingModule {
|
|
|
2163
2275
|
url: tracesUrl,
|
|
2164
2276
|
headers: config.headers
|
|
2165
2277
|
});
|
|
2166
|
-
this.spanExporter = new BrizzSpanExporter(
|
|
2278
|
+
this.spanExporter = new BrizzSpanExporter(
|
|
2279
|
+
otlpExporter,
|
|
2280
|
+
config,
|
|
2281
|
+
(serviceName) => new OTLPTraceExporter({
|
|
2282
|
+
url: tracesUrl,
|
|
2283
|
+
headers: { ...config.headers, [SERVICE_NAME_HEADER]: serviceName }
|
|
2284
|
+
})
|
|
2285
|
+
);
|
|
2167
2286
|
logger.debug("OTLP span exporter initialized successfully");
|
|
2168
2287
|
}
|
|
2169
2288
|
/**
|
|
@@ -2244,6 +2363,14 @@ function getSpanProcessor() {
|
|
|
2244
2363
|
}
|
|
2245
2364
|
|
|
2246
2365
|
// src/internal/sdk.ts
|
|
2366
|
+
function resolveMcpSessionTracking(configured) {
|
|
2367
|
+
const fromEnv = process.env["BRIZZ_MCP_SESSION_TRACKING"];
|
|
2368
|
+
if (fromEnv === void 0) {
|
|
2369
|
+
return configured;
|
|
2370
|
+
}
|
|
2371
|
+
const enabled = fromEnv === "true";
|
|
2372
|
+
return typeof configured === "object" ? { ...configured, enabled } : enabled;
|
|
2373
|
+
}
|
|
2247
2374
|
var _Brizz = class __Brizz {
|
|
2248
2375
|
static instance = null;
|
|
2249
2376
|
static getInstance() {
|
|
@@ -2264,6 +2391,7 @@ var _Brizz = class __Brizz {
|
|
|
2264
2391
|
*/
|
|
2265
2392
|
setupInstrumentation(options) {
|
|
2266
2393
|
const registry = InstrumentationRegistry.getInstance();
|
|
2394
|
+
configure(resolveMcpSessionTracking(options.mcpSessionTracking));
|
|
2267
2395
|
if (options.instrumentModules && Object.keys(options.instrumentModules).length > 0) {
|
|
2268
2396
|
registry.setManualModules(options.instrumentModules);
|
|
2269
2397
|
}
|
|
@@ -2469,6 +2597,7 @@ export {
|
|
|
2469
2597
|
callWithMute,
|
|
2470
2598
|
callWithOrganization,
|
|
2471
2599
|
callWithProperties,
|
|
2600
|
+
callWithServiceName,
|
|
2472
2601
|
callWithSessionId,
|
|
2473
2602
|
callWithUser,
|
|
2474
2603
|
emitEvent,
|
|
@@ -2488,6 +2617,7 @@ export {
|
|
|
2488
2617
|
setLogLevel,
|
|
2489
2618
|
setMessageId,
|
|
2490
2619
|
setOrganization,
|
|
2620
|
+
setServiceName,
|
|
2491
2621
|
setSessionId,
|
|
2492
2622
|
setUser,
|
|
2493
2623
|
startSession,
|
|
@@ -2496,6 +2626,7 @@ export {
|
|
|
2496
2626
|
withMute,
|
|
2497
2627
|
withOrganization,
|
|
2498
2628
|
withProperties,
|
|
2629
|
+
withServiceName,
|
|
2499
2630
|
withSessionId,
|
|
2500
2631
|
withUser
|
|
2501
2632
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkQUV5HYJ2cjs = require('./chunk-QUV5HYJ2.cjs');
|
|
6
|
+
require('./chunk-FORVS4QW.cjs');
|
|
7
|
+
require('./chunk-OBGZSXTJ.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.InterruptPropagator = _chunkQUV5HYJ2cjs.InterruptPropagator; exports._resetInterruptState = _chunkQUV5HYJ2cjs._resetInterruptState; exports.createInterruptIntegration = _chunkQUV5HYJ2cjs.createInterruptIntegration;
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
InterruptPropagator,
|
|
3
3
|
_resetInterruptState,
|
|
4
4
|
createInterruptIntegration
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-7FQQHF5U.js";
|
|
6
|
+
import "./chunk-Y7NMZAQT.js";
|
|
7
7
|
import "./chunk-3RG5ZIWI.js";
|
|
8
8
|
export {
|
|
9
9
|
InterruptPropagator,
|