@echoteam/signoz-react 1.2.5 → 1.2.7

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
@@ -15364,12 +15364,21 @@ function addFetchLogging(config) {
15364
15364
  span.setAttribute('duration_ms', Math.round(duration));
15365
15365
  // Log response data
15366
15366
  span.setAttribute('http.status_code', response.status);
15367
+ // Log response content length from headers
15368
+ const contentLength = response.headers.get('content-length');
15369
+ if (contentLength) {
15370
+ span.setAttribute('http.response_content_length', parseInt(contentLength));
15371
+ }
15367
15372
  if (config.logResponseBody && response.ok) {
15368
15373
  const clonedResponse = response.clone();
15369
15374
  try {
15370
15375
  const responseData = await clonedResponse.text();
15371
15376
  const truncatedData = truncateBody(responseData, config.maxBodyLogSize);
15372
15377
  span.setAttribute('response.data', truncatedData);
15378
+ // If content-length header is not available, calculate from response data
15379
+ if (!contentLength) {
15380
+ span.setAttribute('http.response_content_length', responseData.length);
15381
+ }
15373
15382
  // Try to parse JSON and extract message if exists
15374
15383
  try {
15375
15384
  const jsonData = JSON.parse(responseData);
@@ -15457,11 +15466,20 @@ function addXHRLogging(config) {
15457
15466
  const duration = performance.now() - startTime;
15458
15467
  span.setAttribute('duration_ms', Math.round(duration));
15459
15468
  span.setAttribute('http.status_code', xhr.status);
15469
+ // Log response content length from headers
15470
+ const contentLength = xhr.getResponseHeader('content-length');
15471
+ if (contentLength) {
15472
+ span.setAttribute('http.response_content_length', parseInt(contentLength));
15473
+ }
15460
15474
  // Log response body
15461
15475
  if (config.logResponseBody && xhr.status >= 200 && xhr.status < 300) {
15462
15476
  const responseData = xhr.responseText;
15463
15477
  const truncatedData = truncateBody(responseData, config.maxBodyLogSize);
15464
15478
  span.setAttribute('response.data', truncatedData);
15479
+ // If content-length header is not available, calculate from response data
15480
+ if (!contentLength) {
15481
+ span.setAttribute('http.response_content_length', responseData.length);
15482
+ }
15465
15483
  // Try to parse JSON and extract message if exists
15466
15484
  try {
15467
15485
  const jsonData = JSON.parse(responseData);
@@ -15662,6 +15680,20 @@ function addWebSocketLogging(config) {
15662
15680
  const originalSend = ws.send;
15663
15681
  ws.send = function (data) {
15664
15682
  if (config.logWebSocketMessages) {
15683
+ // Skip logging if data is just a number
15684
+ let shouldLog = true;
15685
+ if (typeof data === 'string') {
15686
+ // Check if string is just a number
15687
+ if (/^\d+$/.test(data.trim())) {
15688
+ shouldLog = false;
15689
+ }
15690
+ }
15691
+ else if (typeof data === 'number') {
15692
+ shouldLog = false;
15693
+ }
15694
+ if (!shouldLog) {
15695
+ return originalSend.call(ws, data);
15696
+ }
15665
15697
  const messageSpan = tracer.startSpan('WebSocket Send');
15666
15698
  const sendStartTime = performance.now();
15667
15699
  messageSpan.setAttribute('websocket.url', wsUrl);
@@ -15718,6 +15750,23 @@ function addWebSocketLogging(config) {
15718
15750
  const originalOnMessage = ws.onmessage;
15719
15751
  ws.addEventListener('message', function (event) {
15720
15752
  if (config.logWebSocketMessages) {
15753
+ // Skip logging if data is just a number
15754
+ let shouldLog = true;
15755
+ if (typeof event.data === 'string') {
15756
+ // Check if string is just a number
15757
+ if (/^\d+$/.test(event.data.trim())) {
15758
+ shouldLog = false;
15759
+ }
15760
+ }
15761
+ else if (typeof event.data === 'number') {
15762
+ shouldLog = false;
15763
+ }
15764
+ if (!shouldLog) {
15765
+ if (originalOnMessage) {
15766
+ originalOnMessage.call(ws, event);
15767
+ }
15768
+ return;
15769
+ }
15721
15770
  const messageSpan = tracer.startSpan('WebSocket Receive');
15722
15771
  messageSpan.setAttribute('websocket.url', wsUrl);
15723
15772
  messageSpan.setAttribute('websocket.direction', 'receive');