@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/README.md +1 -0
- package/dist/index.esm.js +49 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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);
|
|
@@ -15642,6 +15660,20 @@ function addWebSocketLogging(config) {
|
|
|
15642
15660
|
const originalSend = ws.send;
|
|
15643
15661
|
ws.send = function (data) {
|
|
15644
15662
|
if (config.logWebSocketMessages) {
|
|
15663
|
+
// Skip logging if data is just a number
|
|
15664
|
+
let shouldLog = true;
|
|
15665
|
+
if (typeof data === 'string') {
|
|
15666
|
+
// Check if string is just a number
|
|
15667
|
+
if (/^\d+$/.test(data.trim())) {
|
|
15668
|
+
shouldLog = false;
|
|
15669
|
+
}
|
|
15670
|
+
}
|
|
15671
|
+
else if (typeof data === 'number') {
|
|
15672
|
+
shouldLog = false;
|
|
15673
|
+
}
|
|
15674
|
+
if (!shouldLog) {
|
|
15675
|
+
return originalSend.call(ws, data);
|
|
15676
|
+
}
|
|
15645
15677
|
const messageSpan = tracer.startSpan('WebSocket Send');
|
|
15646
15678
|
const sendStartTime = performance.now();
|
|
15647
15679
|
messageSpan.setAttribute('websocket.url', wsUrl);
|
|
@@ -15698,6 +15730,23 @@ function addWebSocketLogging(config) {
|
|
|
15698
15730
|
const originalOnMessage = ws.onmessage;
|
|
15699
15731
|
ws.addEventListener('message', function (event) {
|
|
15700
15732
|
if (config.logWebSocketMessages) {
|
|
15733
|
+
// Skip logging if data is just a number
|
|
15734
|
+
let shouldLog = true;
|
|
15735
|
+
if (typeof event.data === 'string') {
|
|
15736
|
+
// Check if string is just a number
|
|
15737
|
+
if (/^\d+$/.test(event.data.trim())) {
|
|
15738
|
+
shouldLog = false;
|
|
15739
|
+
}
|
|
15740
|
+
}
|
|
15741
|
+
else if (typeof event.data === 'number') {
|
|
15742
|
+
shouldLog = false;
|
|
15743
|
+
}
|
|
15744
|
+
if (!shouldLog) {
|
|
15745
|
+
if (originalOnMessage) {
|
|
15746
|
+
originalOnMessage.call(ws, event);
|
|
15747
|
+
}
|
|
15748
|
+
return;
|
|
15749
|
+
}
|
|
15701
15750
|
const messageSpan = tracer.startSpan('WebSocket Receive');
|
|
15702
15751
|
messageSpan.setAttribute('websocket.url', wsUrl);
|
|
15703
15752
|
messageSpan.setAttribute('websocket.direction', 'receive');
|