@echoteam/signoz-react 1.2.10 → 1.2.13

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.js CHANGED
@@ -15571,7 +15571,22 @@ function addXHRLogging(config) {
15571
15571
  function addErrorTracking(enableConsoleLog = false) {
15572
15572
  // Track unhandled errors
15573
15573
  window.addEventListener('error', (event) => {
15574
- var _a;
15574
+ var _a, _b;
15575
+ // Skip SignOz internal timeout errors
15576
+ const errorMessage = event.message || '';
15577
+ const errorStack = ((_a = event.error) === null || _a === void 0 ? void 0 : _a.stack) || '';
15578
+ const isSignOzTimeout = (errorMessage.includes('Timeout') &&
15579
+ (errorMessage.includes('BatchSpanProcessor') ||
15580
+ errorStack.includes('BatchSpanProcessor') ||
15581
+ errorStack.includes('zone.js') ||
15582
+ errorStack.includes('SignOz')));
15583
+ if (isSignOzTimeout) {
15584
+ if (enableConsoleLog) {
15585
+ console.warn('[SignOz] Span export timeout detected (safe to ignore - not tracking this error)');
15586
+ }
15587
+ event.preventDefault(); // Prevent the error from propagating
15588
+ return;
15589
+ }
15575
15590
  const tracer = trace.getTracer('error-tracker');
15576
15591
  const span = tracer.startSpan('Unhandled Error');
15577
15592
  span.setAttribute('error.type', 'unhandled');
@@ -15596,7 +15611,7 @@ function addErrorTracking(enableConsoleLog = false) {
15596
15611
  filename: event.filename,
15597
15612
  lineno: event.lineno,
15598
15613
  colno: event.colno,
15599
- stack: (_a = event.error) === null || _a === void 0 ? void 0 : _a.stack,
15614
+ stack: (_b = event.error) === null || _b === void 0 ? void 0 : _b.stack,
15600
15615
  page: window.location.pathname
15601
15616
  });
15602
15617
  }
@@ -15606,9 +15621,15 @@ function addErrorTracking(enableConsoleLog = false) {
15606
15621
  window.addEventListener('unhandledrejection', (event) => {
15607
15622
  // Suppress BatchSpanProcessor timeout errors to avoid noise
15608
15623
  const reason = String(event.reason);
15609
- if (reason.includes('Timeout') && reason.includes('BatchSpanProcessor')) {
15624
+ const stack = event.reason instanceof Error ? (event.reason.stack || '') : '';
15625
+ // Check if this is a SignOz internal timeout error
15626
+ const isSignOzTimeout = (reason.includes('Timeout') &&
15627
+ (reason.includes('BatchSpanProcessor') ||
15628
+ stack.includes('BatchSpanProcessor') ||
15629
+ stack.includes('zone.js')));
15630
+ if (isSignOzTimeout) {
15610
15631
  if (enableConsoleLog) {
15611
- console.warn('[SignOz] Span export timeout (this is usually safe to ignore):', event.reason);
15632
+ console.warn('[SignOz] Span export timeout (this is usually safe to ignore - check if SignOz endpoint is reachable)');
15612
15633
  }
15613
15634
  event.preventDefault(); // Prevent the error from being logged
15614
15635
  return;
@@ -15640,6 +15661,17 @@ function addErrorTracking(enableConsoleLog = false) {
15640
15661
  const originalHandleError = currentZone.handleError;
15641
15662
  if (originalHandleError) {
15642
15663
  currentZone.handleError = function (error) {
15664
+ // Skip SignOz internal timeout errors
15665
+ const errorMessage = error.message || String(error);
15666
+ const errorStack = error.stack || '';
15667
+ const isSignOzTimeout = (errorMessage.includes('Timeout') &&
15668
+ (errorStack.includes('BatchSpanProcessor') || errorStack.includes('zone.js')));
15669
+ if (isSignOzTimeout) {
15670
+ if (enableConsoleLog) {
15671
+ console.warn('[SignOz] Zone.js caught span export timeout (safe to ignore)');
15672
+ }
15673
+ return; // Don't track this error
15674
+ }
15643
15675
  const tracer = trace.getTracer('error-tracker');
15644
15676
  const span = tracer.startSpan('Zone.js Error');
15645
15677
  span.setAttribute('error.type', 'zone_error');
@@ -15669,6 +15701,15 @@ function addErrorTracking(enableConsoleLog = false) {
15669
15701
  console.error = function (...args) {
15670
15702
  // Check if this is a React error
15671
15703
  const errorMessage = args.map(arg => String(arg)).join(' ');
15704
+ // Skip SignOz internal errors
15705
+ const isSignOzError = (errorMessage.includes('Timeout') &&
15706
+ (errorMessage.includes('BatchSpanProcessor') ||
15707
+ errorMessage.includes('zone.js') ||
15708
+ errorMessage.includes('SignOz')));
15709
+ if (isSignOzError) {
15710
+ // Just call original console.error without tracking
15711
+ return originalConsoleError.apply(console, args);
15712
+ }
15672
15713
  if (errorMessage.includes('React') || errorMessage.includes('TypeError') || errorMessage.includes('Uncaught')) {
15673
15714
  const tracer = trace.getTracer('error-tracker');
15674
15715
  const span = tracer.startSpan('Console Error');
@@ -16013,7 +16054,7 @@ function initializeSignOzTracing(config) {
16013
16054
  batchSpanProcessorConfig: (config === null || config === void 0 ? void 0 : config.batchSpanProcessorConfig) || {
16014
16055
  maxQueueSize: 100,
16015
16056
  scheduledDelayMillis: 5000,
16016
- exportTimeoutMillis: 60000, // Increased to 60 seconds
16057
+ exportTimeoutMillis: 30000, // Reduced to 30 seconds to fail faster
16017
16058
  maxExportBatchSize: 50 // Smaller batches to avoid timeouts
16018
16059
  },
16019
16060
  allowedOrigins: (config === null || config === void 0 ? void 0 : config.allowedOrigins) || parseAllowedOrigins(getConfigValue('REACT_APP_SIGNOZ_ALLOWED_ORIGINS')),
@@ -16042,12 +16083,31 @@ function initializeSignOzTracing(config) {
16042
16083
  'deployment.environment': effectiveConfig.environment,
16043
16084
  'service.namespace': effectiveConfig.serviceNamespace,
16044
16085
  });
16045
- // Set up the OTLP trace exporter
16086
+ // Set up the OTLP trace exporter with error handling
16046
16087
  const exporter = new OTLPTraceExporter({
16047
16088
  url: effectiveConfig.url,
16048
16089
  headers: effectiveConfig.headers,
16049
- timeoutMillis: 60000 // Set exporter timeout to 60 seconds
16090
+ timeoutMillis: 30000 // Reduced to 30 seconds to fail faster
16050
16091
  });
16092
+ // Wrap exporter to suppress timeout errors
16093
+ const originalExport = exporter.export.bind(exporter);
16094
+ exporter.export = function (spans, resultCallback) {
16095
+ originalExport(spans, (result) => {
16096
+ // Suppress timeout errors to prevent console noise
16097
+ if (result.error) {
16098
+ const errorMessage = String(result.error);
16099
+ if (errorMessage.includes('Timeout') || errorMessage.includes('timeout')) {
16100
+ if (effectiveConfig.enableConsoleLog) {
16101
+ console.warn('[SignOz] Span export timeout - check if SignOz endpoint is reachable:', effectiveConfig.url);
16102
+ }
16103
+ // Call callback with success to prevent error propagation
16104
+ resultCallback({ code: 0 });
16105
+ return;
16106
+ }
16107
+ }
16108
+ resultCallback(result);
16109
+ });
16110
+ };
16051
16111
  // Set up the span processor with configuration
16052
16112
  const processor = new BatchSpanProcessor(exporter, {
16053
16113
  maxQueueSize: effectiveConfig.batchSpanProcessorConfig.maxQueueSize,