@echoteam/signoz-react 1.2.8 → 1.2.10

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.
@@ -1,5 +1,81 @@
1
1
  # Troubleshooting Guide
2
2
 
3
+ ## Error: Timeout from BatchSpanProcessor
4
+
5
+ ### Masalah
6
+ Jika Anda mendapatkan error seperti ini di console:
7
+ ```
8
+ Unhandled Promise rejection: Timeout ; Zone: <root> ; Task: Promise.then ; Value: Error: Timeout
9
+ at BatchSpanProcessorBase.js:132:1
10
+ ```
11
+
12
+ ### Penyebab
13
+ Error ini terjadi ketika BatchSpanProcessor mencoba mengirim spans ke backend SignOz tetapi mengalami timeout. Ini biasanya terjadi karena:
14
+ 1. Backend SignOz tidak dapat dijangkau
15
+ 2. Network lambat atau tidak stabil
16
+ 3. CORS tidak dikonfigurasi dengan benar di backend
17
+ 4. Timeout terlalu pendek untuk koneksi Anda
18
+
19
+ ### Solusi
20
+
21
+ #### 1. Verifikasi Backend SignOz Dapat Dijangkau
22
+ Pastikan URL SignOz Anda benar dan dapat diakses dari browser:
23
+ ```javascript
24
+ // Test di browser console
25
+ fetch('http://your-signoz-url:4318/v1/traces', {
26
+ method: 'POST',
27
+ headers: { 'Content-Type': 'application/json' }
28
+ })
29
+ ```
30
+
31
+ #### 2. Periksa CORS Configuration
32
+ Pastikan backend SignOz Anda mengizinkan request dari domain frontend Anda. Lihat [BACKEND_CORS_SETUP.md](./BACKEND_CORS_SETUP.md) untuk panduan lengkap.
33
+
34
+ #### 3. Tingkatkan Timeout (Recommended)
35
+ Sejak versi 1.2.10, timeout default sudah ditingkatkan menjadi 60 detik. Jika masih timeout, Anda bisa meningkatkannya lebih lanjut:
36
+
37
+ ```javascript
38
+ import { initializeSignOzTracing } from '@echoteam/signoz-react';
39
+
40
+ initializeSignOzTracing({
41
+ serviceName: 'my-app',
42
+ serviceVersion: '1.0.0',
43
+ environment: 'production',
44
+ serviceNamespace: 'frontend',
45
+ url: 'http://your-signoz-url:4318/v1/traces',
46
+ batchSpanProcessorConfig: {
47
+ maxQueueSize: 100,
48
+ scheduledDelayMillis: 5000,
49
+ exportTimeoutMillis: 120000, // 120 seconds
50
+ maxExportBatchSize: 50
51
+ }
52
+ });
53
+ ```
54
+
55
+ #### 4. Suppress Timeout Errors (Jika Tidak Mengganggu)
56
+ Sejak versi 1.2.10, timeout errors dari BatchSpanProcessor secara otomatis di-suppress untuk menghindari noise di console. Error ini biasanya aman untuk diabaikan karena spans akan di-retry atau di-queue ulang.
57
+
58
+ Jika Anda ingin melihat warning untuk timeout ini, aktifkan console logging:
59
+ ```javascript
60
+ initializeSignOzTracing({
61
+ // ... config lainnya
62
+ enableConsoleLog: true
63
+ });
64
+ ```
65
+
66
+ #### 5. Gunakan Network yang Lebih Stabil
67
+ Jika Anda mengalami timeout secara konsisten, pertimbangkan:
68
+ - Menggunakan koneksi internet yang lebih stabil
69
+ - Mengurangi ukuran batch dengan `maxExportBatchSize`
70
+ - Meningkatkan `scheduledDelayMillis` untuk mengirim spans lebih jarang
71
+
72
+ ### Catatan Penting
73
+ - Timeout errors biasanya tidak mempengaruhi fungsionalitas aplikasi Anda
74
+ - Spans yang gagal dikirim akan di-queue ulang dan dicoba lagi
75
+ - Jika backend SignOz tidak dapat dijangkau sama sekali, spans akan di-drop setelah queue penuh
76
+
77
+ ---
78
+
3
79
  ## Error: Can't resolve 'perf_hooks'
4
80
 
5
81
  ### Masalah
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ interface SignOzConfig {
11
11
  maxQueueSize?: number;
12
12
  scheduledDelayMillis?: number;
13
13
  exportTimeoutMillis?: number;
14
+ maxExportBatchSize?: number;
14
15
  };
15
16
  allowedOrigins?: (string | RegExp)[];
16
17
  enableRequestLogging?: boolean;
package/dist/index.esm.js CHANGED
@@ -15584,6 +15584,15 @@ function addErrorTracking(enableConsoleLog = false) {
15584
15584
  }, true); // Use capture phase to catch errors early
15585
15585
  // Track unhandled promise rejections
15586
15586
  window.addEventListener('unhandledrejection', (event) => {
15587
+ // Suppress BatchSpanProcessor timeout errors to avoid noise
15588
+ const reason = String(event.reason);
15589
+ if (reason.includes('Timeout') && reason.includes('BatchSpanProcessor')) {
15590
+ if (enableConsoleLog) {
15591
+ console.warn('[SignOz] Span export timeout (this is usually safe to ignore):', event.reason);
15592
+ }
15593
+ event.preventDefault(); // Prevent the error from being logged
15594
+ return;
15595
+ }
15587
15596
  const tracer = trace.getTracer('error-tracker');
15588
15597
  const span = tracer.startSpan('Unhandled Promise Rejection');
15589
15598
  span.setAttribute('error.type', 'unhandled_rejection');
@@ -15984,7 +15993,8 @@ function initializeSignOzTracing(config) {
15984
15993
  batchSpanProcessorConfig: (config === null || config === void 0 ? void 0 : config.batchSpanProcessorConfig) || {
15985
15994
  maxQueueSize: 100,
15986
15995
  scheduledDelayMillis: 5000,
15987
- exportTimeoutMillis: 30000
15996
+ exportTimeoutMillis: 60000, // Increased to 60 seconds
15997
+ maxExportBatchSize: 50 // Smaller batches to avoid timeouts
15988
15998
  },
15989
15999
  allowedOrigins: (config === null || config === void 0 ? void 0 : config.allowedOrigins) || parseAllowedOrigins(getConfigValue('REACT_APP_SIGNOZ_ALLOWED_ORIGINS')),
15990
16000
  enableRequestLogging: (config === null || config === void 0 ? void 0 : config.enableRequestLogging) !== undefined ? config.enableRequestLogging : (getConfigValue('REACT_APP_SIGNOZ_ENABLE_REQUEST_LOGGING') === 'true' || true),
@@ -16015,7 +16025,8 @@ function initializeSignOzTracing(config) {
16015
16025
  // Set up the OTLP trace exporter
16016
16026
  const exporter = new OTLPTraceExporter({
16017
16027
  url: effectiveConfig.url,
16018
- headers: effectiveConfig.headers
16028
+ headers: effectiveConfig.headers,
16029
+ timeoutMillis: 60000 // Set exporter timeout to 60 seconds
16019
16030
  });
16020
16031
  // Set up the span processor with configuration
16021
16032
  const processor = new BatchSpanProcessor(exporter, {