@echoteam/signoz-react 1.2.6 → 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/README.md CHANGED
@@ -194,6 +194,7 @@ Library ini secara otomatis melog semua HTTP request dan response yang dilakukan
194
194
  - `http.url`: URL endpoint
195
195
  - `http.method`: HTTP method
196
196
  - `http.status_code`: Status code response
197
+ - `http.response_content_length`: Ukuran response dalam bytes
197
198
  - `duration_ms`: Durasi request dalam milliseconds
198
199
  - `page.url`: URL halaman frontend yang melakukan request
199
200
  - `page.pathname`: Pathname halaman frontend
package/dist/index.esm.js CHANGED
@@ -15344,12 +15344,21 @@ function addFetchLogging(config) {
15344
15344
  span.setAttribute('duration_ms', Math.round(duration));
15345
15345
  // Log response data
15346
15346
  span.setAttribute('http.status_code', response.status);
15347
+ // Log response content length from headers
15348
+ const contentLength = response.headers.get('content-length');
15349
+ if (contentLength) {
15350
+ span.setAttribute('http.response_content_length', parseInt(contentLength));
15351
+ }
15347
15352
  if (config.logResponseBody && response.ok) {
15348
15353
  const clonedResponse = response.clone();
15349
15354
  try {
15350
15355
  const responseData = await clonedResponse.text();
15351
15356
  const truncatedData = truncateBody(responseData, config.maxBodyLogSize);
15352
15357
  span.setAttribute('response.data', truncatedData);
15358
+ // If content-length header is not available, calculate from response data
15359
+ if (!contentLength) {
15360
+ span.setAttribute('http.response_content_length', responseData.length);
15361
+ }
15353
15362
  // Try to parse JSON and extract message if exists
15354
15363
  try {
15355
15364
  const jsonData = JSON.parse(responseData);
@@ -15437,11 +15446,20 @@ function addXHRLogging(config) {
15437
15446
  const duration = performance.now() - startTime;
15438
15447
  span.setAttribute('duration_ms', Math.round(duration));
15439
15448
  span.setAttribute('http.status_code', xhr.status);
15449
+ // Log response content length from headers
15450
+ const contentLength = xhr.getResponseHeader('content-length');
15451
+ if (contentLength) {
15452
+ span.setAttribute('http.response_content_length', parseInt(contentLength));
15453
+ }
15440
15454
  // Log response body
15441
15455
  if (config.logResponseBody && xhr.status >= 200 && xhr.status < 300) {
15442
15456
  const responseData = xhr.responseText;
15443
15457
  const truncatedData = truncateBody(responseData, config.maxBodyLogSize);
15444
15458
  span.setAttribute('response.data', truncatedData);
15459
+ // If content-length header is not available, calculate from response data
15460
+ if (!contentLength) {
15461
+ span.setAttribute('http.response_content_length', responseData.length);
15462
+ }
15445
15463
  // Try to parse JSON and extract message if exists
15446
15464
  try {
15447
15465
  const jsonData = JSON.parse(responseData);