@brizz/sdk 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -280,7 +280,7 @@ function autoInitializeInstrumentations() {
280
280
  autoInitializeInstrumentations();
281
281
 
282
282
  // src/internal/sdk.ts
283
- var import_resources2 = require("@opentelemetry/resources");
283
+ var import_resources3 = require("@opentelemetry/resources");
284
284
  var import_sdk_node = require("@opentelemetry/sdk-node");
285
285
 
286
286
  // src/internal/config.ts
@@ -346,7 +346,7 @@ function resolveConfig(options) {
346
346
  });
347
347
  } catch (error) {
348
348
  logger.error("Failed to parse BRIZZ_HEADERS environment variable", { error });
349
- throw new Error("Invalid JSON in BRIZZ_HEADERS environment variable");
349
+ throw new Error("Invalid JSON in BRIZZ_HEADERS environment variable", { cause: error });
350
350
  }
351
351
  }
352
352
  logger.debug("Configuration resolved with environment variables", {
@@ -482,7 +482,7 @@ var import_sdk_logs2 = require("@opentelemetry/sdk-logs");
482
482
 
483
483
  // src/internal/version.ts
484
484
  function getSDKVersion() {
485
- return "0.1.10";
485
+ return "0.1.11";
486
486
  }
487
487
 
488
488
  // src/internal/log/processors/log-processor.ts
@@ -928,7 +928,9 @@ function getGroupedPattern(patternEntry) {
928
928
  try {
929
929
  new RegExp(patternEntry.pattern);
930
930
  } catch (error) {
931
- throw new Error(`Invalid regex pattern '${patternEntry.pattern}': ${String(error)}`);
931
+ throw new Error(`Invalid regex pattern '${patternEntry.pattern}': ${String(error)}`, {
932
+ cause: error
933
+ });
932
934
  }
933
935
  return `(?<${name}>${patternEntry.pattern})`;
934
936
  }
@@ -1480,6 +1482,39 @@ function getMetricsReader() {
1480
1482
  // src/internal/trace/tracing.ts
1481
1483
  var import_exporter_trace_otlp_proto = require("@opentelemetry/exporter-trace-otlp-proto");
1482
1484
 
1485
+ // src/internal/trace/exporters/span-exporter.ts
1486
+ var import_resources2 = require("@opentelemetry/resources");
1487
+ var BrizzSpanExporter = class {
1488
+ _delegate;
1489
+ _brizzResource;
1490
+ constructor(delegate, config) {
1491
+ this._delegate = delegate;
1492
+ const resourceAttrs = {
1493
+ "service.name": config.appName,
1494
+ [BRIZZ_SDK_VERSION]: getSDKVersion(),
1495
+ [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
1496
+ };
1497
+ if (config.environment) {
1498
+ resourceAttrs["deployment.environment"] = config.environment;
1499
+ }
1500
+ this._brizzResource = (0, import_resources2.resourceFromAttributes)(resourceAttrs);
1501
+ }
1502
+ export(spans, resultCallback) {
1503
+ const patchedSpans = spans.map((span) => ({
1504
+ ...span,
1505
+ resource: span.resource.merge(this._brizzResource),
1506
+ spanContext: span.spanContext.bind(span)
1507
+ }));
1508
+ this._delegate.export(patchedSpans, resultCallback);
1509
+ }
1510
+ async shutdown() {
1511
+ return this._delegate.shutdown();
1512
+ }
1513
+ async forceFlush() {
1514
+ return this._delegate.forceFlush?.();
1515
+ }
1516
+ };
1517
+
1483
1518
  // src/internal/trace/processors/span-processor.ts
1484
1519
  var import_api4 = require("@opentelemetry/api");
1485
1520
  var import_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
@@ -1605,16 +1640,17 @@ var TracingModule = class _TracingModule {
1605
1640
  }
1606
1641
  if (config.customSpanExporter) {
1607
1642
  logger.debug("Using custom span exporter");
1608
- this.spanExporter = config.customSpanExporter;
1643
+ this.spanExporter = new BrizzSpanExporter(config.customSpanExporter, config);
1609
1644
  logger.debug("Custom span exporter initialized successfully");
1610
1645
  return;
1611
1646
  }
1612
1647
  const tracesUrl = config.baseUrl.replace(/\/$/, "") + "/v1/traces";
1613
1648
  logger.debug("Initializing default OTLP span exporter", { url: tracesUrl });
1614
- this.spanExporter = new import_exporter_trace_otlp_proto.OTLPTraceExporter({
1649
+ const otlpExporter = new import_exporter_trace_otlp_proto.OTLPTraceExporter({
1615
1650
  url: tracesUrl,
1616
1651
  headers: config.headers
1617
1652
  });
1653
+ this.spanExporter = new BrizzSpanExporter(otlpExporter, config);
1618
1654
  logger.debug("OTLP span exporter initialized successfully");
1619
1655
  }
1620
1656
  /**
@@ -1831,7 +1867,7 @@ var _Brizz = class __Brizz {
1831
1867
  });
1832
1868
  } catch (error) {
1833
1869
  logger.error("Failed to initialize Brizz SDK", { error });
1834
- throw new Error(`Failed to initialize SDK: ${String(error)}`);
1870
+ throw new Error(`Failed to initialize SDK: ${String(error)}`, { cause: error });
1835
1871
  }
1836
1872
  }
1837
1873
  /**
@@ -1867,7 +1903,7 @@ var _Brizz = class __Brizz {
1867
1903
  this._sdk = new import_sdk_node.NodeSDK({
1868
1904
  spanProcessors: [getSpanProcessor()],
1869
1905
  metricReader: getMetricsReader(),
1870
- resource: (0, import_resources2.resourceFromAttributes)(resourceAttributes),
1906
+ resource: (0, import_resources3.resourceFromAttributes)(resourceAttributes),
1871
1907
  instrumentations: manualInstrumentations
1872
1908
  });
1873
1909
  this._sdk.start();