@brizz/sdk 0.1.16 → 0.1.18

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 CHANGED
@@ -20,6 +20,7 @@ libraries including OpenAI, Anthropic, Vercel AI SDK, and more.
20
20
  - [Session Tracking](#session-tracking)
21
21
  - [Custom Events & Logging](#custom-events--logging)
22
22
  - [Environment Variables](#environment-variables)
23
+ - [Disable Span Export](#disable-span-export)
23
24
  - [Advanced Configuration](#advanced-configuration)
24
25
  - [Testing & Development](#testing--development)
25
26
  - [Package.json Examples](#packagejson-examples)
@@ -507,13 +508,26 @@ BRIZZ_BASE_URL=https://telemetry.brizz.dev # Default telemetry endpoint
507
508
  BRIZZ_APP_NAME=my-app # Application name
508
509
  BRIZZ_APP_VERSION=1.0.0 # Application version
509
510
  BRIZZ_ENVIRONMENT=production # Environment (dev, staging, prod)
510
- BRIZZ_LOG_LEVEL=info # SDK log level
511
+ BRIZZ_LOG_LEVEL=info # SDK log level
512
+ BRIZZ_DISABLE_SPAN_EXPORTER=true # Skip span export (see "Disable Span Export")
511
513
 
512
514
  # OpenTelemetry Standard Variables
513
515
  OTEL_SERVICE_NAME=my-service # Service name
514
516
  OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true # Capture AI content
515
517
  ```
516
518
 
519
+ ## Disable Span Export
520
+
521
+ Keep `Brizz.initialize()` in your code without sending any spans — useful for dev/test
522
+ environments. When enabled, the SDK skips span exporter and processor setup, so no
523
+ spans are exported. Metrics and logs continue to work.
524
+
525
+ ```typescript
526
+ Brizz.initialize({ apiKey: 'your-api-key', disableSpanExporter: true });
527
+ ```
528
+
529
+ Or via env var: `BRIZZ_DISABLE_SPAN_EXPORTER=true`.
530
+
517
531
  ## Advanced Configuration
518
532
 
519
533
  ```typescript
package/dist/index.cjs CHANGED
@@ -223,7 +223,14 @@ var exceptionLogger = (error) => {
223
223
  };
224
224
  function loadNodeAutoInstrumentations() {
225
225
  try {
226
- const nodeInstrumentations = (0, import_auto_instrumentations_node.getNodeAutoInstrumentations)();
226
+ const nodeInstrumentations = (0, import_auto_instrumentations_node.getNodeAutoInstrumentations)({
227
+ // Disabled because @traceloop/instrumentation-openai wraps the same OpenAI
228
+ // prototype with richer span attributes (gen_ai.input.messages /
229
+ // gen_ai.output.messages). Leaving both enabled lets the official one win
230
+ // and route content to log events instead of span attributes, leaving the
231
+ // Brizz backend parser with no payload to read.
232
+ "@opentelemetry/instrumentation-openai": { enabled: false }
233
+ });
227
234
  (0, import_instrumentation.registerInstrumentations)({ instrumentations: nodeInstrumentations });
228
235
  return nodeInstrumentations;
229
236
  } catch (error) {
@@ -327,10 +334,12 @@ function resolveConfig(options) {
327
334
  const resolvedConfig = {
328
335
  ...options,
329
336
  appName: process.env["BRIZZ_APP_NAME"] || options.appName || "unknown-app",
337
+ appVersion: process.env["BRIZZ_APP_VERSION"] || options.appVersion,
330
338
  baseUrl: process.env["BRIZZ_BASE_URL"] || options.baseUrl || "https://telemetry.brizz.dev",
331
339
  headers: { ...options.headers },
332
340
  apiKey: process.env["BRIZZ_API_KEY"] || options.apiKey,
333
341
  disableBatch: process.env["BRIZZ_DISABLE_BATCH"] === "true" || !!options.disableBatch,
342
+ disableSpanExporter: process.env["BRIZZ_DISABLE_SPAN_EXPORTER"] === "true" || !!options.disableSpanExporter,
334
343
  environment: process.env["BRIZZ_ENVIRONMENT"] || options.environment,
335
344
  logLevel: resolvedLogLevel,
336
345
  masking: resolvedMasking
@@ -496,7 +505,7 @@ var import_sdk_logs2 = require("@opentelemetry/sdk-logs");
496
505
 
497
506
  // src/internal/version.ts
498
507
  function getSDKVersion() {
499
- return "0.1.16";
508
+ return "0.1.18";
500
509
  }
501
510
 
502
511
  // src/internal/log/processors/log-processor.ts
@@ -1305,6 +1314,7 @@ var LoggingModule = class _LoggingModule {
1305
1314
  serviceName: config.appName
1306
1315
  });
1307
1316
  const resourceAttributes = {
1317
+ ...config.resourceAttributes,
1308
1318
  "service.name": config.appName,
1309
1319
  [BRIZZ_SDK_VERSION]: getSDKVersion(),
1310
1320
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
@@ -1312,6 +1322,9 @@ var LoggingModule = class _LoggingModule {
1312
1322
  if (config.environment) {
1313
1323
  resourceAttributes["deployment.environment"] = config.environment;
1314
1324
  }
1325
+ if (config.appVersion) {
1326
+ resourceAttributes["service.version"] = config.appVersion;
1327
+ }
1315
1328
  const resource = (0, import_resources.resourceFromAttributes)(resourceAttributes);
1316
1329
  logger.debug("Creating logger provider with resource");
1317
1330
  this.loggerProvider = new import_sdk_logs2.LoggerProvider({
@@ -1501,13 +1514,16 @@ function getMetricsReader() {
1501
1514
  var import_exporter_trace_otlp_proto = require("@opentelemetry/exporter-trace-otlp-proto");
1502
1515
 
1503
1516
  // src/internal/trace/exporters/span-exporter.ts
1517
+ var import_core = require("@opentelemetry/core");
1504
1518
  var import_resources2 = require("@opentelemetry/resources");
1505
1519
  var BrizzSpanExporter = class {
1506
1520
  _delegate;
1507
1521
  _brizzResource;
1522
+ _beforeSendSpan;
1508
1523
  constructor(delegate, config) {
1509
1524
  this._delegate = delegate;
1510
1525
  const resourceAttrs = {
1526
+ ...config.resourceAttributes,
1511
1527
  "service.name": config.appName,
1512
1528
  [BRIZZ_SDK_VERSION]: getSDKVersion(),
1513
1529
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
@@ -1515,15 +1531,47 @@ var BrizzSpanExporter = class {
1515
1531
  if (config.environment) {
1516
1532
  resourceAttrs["deployment.environment"] = config.environment;
1517
1533
  }
1534
+ if (config.appVersion) {
1535
+ resourceAttrs["service.version"] = config.appVersion;
1536
+ }
1518
1537
  this._brizzResource = (0, import_resources2.resourceFromAttributes)(resourceAttrs);
1538
+ this._beforeSendSpan = config.beforeSendSpan;
1519
1539
  }
1520
1540
  export(spans, resultCallback) {
1541
+ if (spans.length === 0) {
1542
+ resultCallback({ code: import_core.ExportResultCode.SUCCESS });
1543
+ return;
1544
+ }
1521
1545
  const patchedSpans = spans.map((span) => ({
1522
1546
  ...span,
1523
1547
  resource: span.resource.merge(this._brizzResource),
1524
1548
  spanContext: span.spanContext.bind(span)
1525
1549
  }));
1526
- this._delegate.export(patchedSpans, resultCallback);
1550
+ const filter = this._beforeSendSpan;
1551
+ if (!filter) {
1552
+ this._delegate.export(patchedSpans, resultCallback);
1553
+ return;
1554
+ }
1555
+ const verdicts = patchedSpans.map((span) => {
1556
+ try {
1557
+ return Promise.resolve(filter(span));
1558
+ } catch (error) {
1559
+ logger.warn("beforeSendSpan threw; span will be kept", { error });
1560
+ return Promise.resolve(true);
1561
+ }
1562
+ });
1563
+ Promise.all(verdicts).then((keep) => {
1564
+ const filtered = patchedSpans.filter((_, i) => keep[i] !== false);
1565
+ if (filtered.length === 0) {
1566
+ resultCallback({ code: import_core.ExportResultCode.SUCCESS });
1567
+ return;
1568
+ }
1569
+ this._delegate.export(filtered, resultCallback);
1570
+ return;
1571
+ }).catch((error) => {
1572
+ logger.warn("beforeSendSpan rejected; all spans will be kept", { error });
1573
+ this._delegate.export(patchedSpans, resultCallback);
1574
+ });
1527
1575
  }
1528
1576
  async shutdown() {
1529
1577
  return this._delegate.shutdown();
@@ -1643,6 +1691,15 @@ var TracingModule = class _TracingModule {
1643
1691
  */
1644
1692
  setup(config) {
1645
1693
  logger.info("Setting up tracing module");
1694
+ if (config.disableSpanExporter) {
1695
+ logger.info(
1696
+ "Span exporter disabled via disableSpanExporter; skipping exporter and processor setup"
1697
+ );
1698
+ this.spanExporter = null;
1699
+ this.spanProcessor = null;
1700
+ _TracingModule.instance = this;
1701
+ return;
1702
+ }
1646
1703
  this.initSpanExporter(config);
1647
1704
  this.initSpanProcessor(config);
1648
1705
  _TracingModule.instance = this;
@@ -1981,6 +2038,7 @@ var _Brizz = class __Brizz {
1981
2038
  const registry = InstrumentationRegistry.getInstance();
1982
2039
  const manualInstrumentations = registry.getManualInstrumentations();
1983
2040
  const resourceAttributes = {
2041
+ ...resolvedConfig.resourceAttributes,
1984
2042
  "service.name": resolvedConfig.appName,
1985
2043
  [BRIZZ_SDK_VERSION]: getSDKVersion(),
1986
2044
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
@@ -1988,8 +2046,11 @@ var _Brizz = class __Brizz {
1988
2046
  if (resolvedConfig.environment) {
1989
2047
  resourceAttributes["deployment.environment"] = resolvedConfig.environment;
1990
2048
  }
2049
+ if (resolvedConfig.appVersion) {
2050
+ resourceAttributes["service.version"] = resolvedConfig.appVersion;
2051
+ }
1991
2052
  this._sdk = new import_sdk_node.NodeSDK({
1992
- spanProcessors: [getSpanProcessor()],
2053
+ spanProcessors: resolvedConfig.disableSpanExporter ? [] : [getSpanProcessor()],
1993
2054
  metricReader: getMetricsReader(),
1994
2055
  resource: (0, import_resources3.resourceFromAttributes)(resourceAttributes),
1995
2056
  instrumentations: manualInstrumentations