@pingops/otel 0.1.3 → 0.2.0
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.cjs +57 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -12
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +28 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +58 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -55,6 +55,26 @@ interface PingopsProcessorConfig {
|
|
|
55
55
|
* Capture response body.
|
|
56
56
|
*/
|
|
57
57
|
captureResponseBody?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Maximum size of request body to capture (bytes).
|
|
60
|
+
* Applies to both `http` and `undici` instrumentations.
|
|
61
|
+
*
|
|
62
|
+
* Note: this is the number of raw bytes observed at the instrumentation layer.
|
|
63
|
+
* For compressed bodies, this is the compressed size.
|
|
64
|
+
*
|
|
65
|
+
* @defaultValue 4096 (4 KB)
|
|
66
|
+
*/
|
|
67
|
+
maxRequestBodySize?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Maximum size of response body to capture (bytes).
|
|
70
|
+
* Applies to both `http` and `undici` instrumentations.
|
|
71
|
+
*
|
|
72
|
+
* Note: this is the number of raw bytes observed at the instrumentation layer.
|
|
73
|
+
* For compressed bodies, this is the compressed size.
|
|
74
|
+
*
|
|
75
|
+
* @defaultValue 4096 (4 KB)
|
|
76
|
+
*/
|
|
77
|
+
maxResponseBodySize?: number;
|
|
58
78
|
/**
|
|
59
79
|
* Domain allow list rules.
|
|
60
80
|
*/
|
|
@@ -167,15 +187,11 @@ declare function shutdownTracerProvider(): Promise<void>;
|
|
|
167
187
|
/**
|
|
168
188
|
* Registers instrumentations for Node.js environment.
|
|
169
189
|
* This function is idempotent and can be called multiple times safely.
|
|
190
|
+
* When the SDK is initialized, all HTTP requests are instrumented.
|
|
170
191
|
*
|
|
171
|
-
* Instrumentation behavior:
|
|
172
|
-
* - If global instrumentation is enabled: all HTTP requests are instrumented
|
|
173
|
-
* - If global instrumentation is NOT enabled: only requests within wrapHttp blocks are instrumented
|
|
174
|
-
*
|
|
175
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
176
192
|
* @returns Array of Instrumentation instances
|
|
177
193
|
*/
|
|
178
|
-
declare function getInstrumentations(
|
|
194
|
+
declare function getInstrumentations(): Instrumentation[];
|
|
179
195
|
//#endregion
|
|
180
196
|
//#region src/instrumentations/http/pingops-http.d.ts
|
|
181
197
|
declare const PingopsSemanticAttributes: {
|
|
@@ -208,13 +224,13 @@ declare class PingopsHttpInstrumentation extends HttpInstrumentation {
|
|
|
208
224
|
//#endregion
|
|
209
225
|
//#region src/instrumentations/http/http.d.ts
|
|
210
226
|
/**
|
|
211
|
-
* Creates an HTTP instrumentation instance
|
|
227
|
+
* Creates an HTTP instrumentation instance.
|
|
228
|
+
* All outgoing HTTP requests are instrumented when the SDK is initialized.
|
|
212
229
|
*
|
|
213
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
214
230
|
* @param config - Optional configuration for the instrumentation
|
|
215
231
|
* @returns PingopsHttpInstrumentation instance
|
|
216
232
|
*/
|
|
217
|
-
declare function createHttpInstrumentation(
|
|
233
|
+
declare function createHttpInstrumentation(config?: Partial<PingopsHttpInstrumentationConfig>): PingopsHttpInstrumentation;
|
|
218
234
|
//#endregion
|
|
219
235
|
//#region src/instrumentations/undici/types.d.ts
|
|
220
236
|
interface UndiciRequest {
|
|
@@ -313,12 +329,12 @@ declare class UndiciInstrumentation extends InstrumentationBase<UndiciInstrument
|
|
|
313
329
|
//#endregion
|
|
314
330
|
//#region src/instrumentations/undici/undici.d.ts
|
|
315
331
|
/**
|
|
316
|
-
* Creates an Undici instrumentation instance
|
|
332
|
+
* Creates an Undici instrumentation instance.
|
|
333
|
+
* All requests are instrumented when the SDK is initialized.
|
|
317
334
|
*
|
|
318
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
319
335
|
* @returns UndiciInstrumentation instance
|
|
320
336
|
*/
|
|
321
|
-
declare function createUndiciInstrumentation(
|
|
337
|
+
declare function createUndiciInstrumentation(): UndiciInstrumentation;
|
|
322
338
|
//#endregion
|
|
323
339
|
export { PingopsHttpInstrumentation, type PingopsHttpInstrumentationConfig, PingopsHttpSemanticAttributes, type PingopsInstrumentationConfig, type PingopsProcessorConfig, PingopsSemanticAttributes, PingopsSpanProcessor, createHttpInstrumentation, createUndiciInstrumentation, getInstrumentations, getPingopsTracerProvider, setPingopsTracerProvider, shutdownTracerProvider };
|
|
324
340
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/config.ts","../src/span-processor.ts","../src/tracer-provider.ts","../src/instrumentations/index.ts","../src/instrumentations/http/pingops-http.ts","../src/instrumentations/http/http.ts","../src/instrumentations/undici/types.ts","../src/instrumentations/undici/pingops-undici.ts","../src/instrumentations/undici/undici.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAgBA;AAKA;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/config.ts","../src/span-processor.ts","../src/tracer-provider.ts","../src/instrumentations/index.ts","../src/instrumentations/http/pingops-http.ts","../src/instrumentations/http/http.ts","../src/instrumentations/undici/types.ts","../src/instrumentations/undici/pingops-undici.ts","../src/instrumentations/undici/undici.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAgBA;AAKA;;;;;AAsGgC,KA3GpB,iBAAA,GA2GoB,WAAA,GAAA,SAAA;;;;ACAnB,UDtGI,sBAAA,CCsGiB;EAkBZ;;;EAoGR,MAAA,CAAA,EAAA,MAAA;EAiGe;;;EAvN6B,OAAA,EAAA,MAAA;;;;ACxB1D;EA6BgB,KAAA,CAAA,EA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AAA,EErWG,UFqWH;AAEb;AAGa,UErWI,2BFsWM,CAAA,cErWP,aFqWO,EAAA,eEpWN,cFmWkD,CAAA,SElWzD,qBFkWyD,CAAA;;sBEhW7C,sBAAsB;;EDzC5B,WAAA,CAAA,EC2CA,mBD3CyB,CC2CL,WD3CK,CAAA;EACtB;EAAR,YAAA,CAAA,EC4CM,oBD5CN,CC4C2B,WD5C3B,EC4CwC,YD5CxC,CAAA;EACR;EAA0B,aAAA,CAAA,EC6CX,qBD7CW,CC6CW,WD7CX,CAAA;;;;EChBZ,uBAAa,CAAA,EAAA;IAuBb,cAAc,CAAA,EAAA,MAAA,EACpB;IAKM,eAAA,CAAA,EAAA,MAAqB,EAAA;EAIrB,CAAA;EAAwB;;;;EAIxB,kBAAA,CAAA,EAAA,MAAoB;EACrB;;;;EAGuC,mBAAA,CAAA,EAAA,MAAA;;;;cCgJ1C,qBAAA,SAA8B,oBAAoB;;;;uBAMzC;;EPlLV,OAAA,CAAA,CAAA,EAAA,IAAA;EAKK,MAAA,CAAA,CAAA,EAAA,IAAA;EAmEG,UAAA,wBAAA,CAAA,CAAA,EAAA,IAAA;EAKD,QAAA,kBAAA;EAMC,QAAA,mBAAA;EAwBL,QAAA,gBAAA;EAAiB,QAAA,gBAAA;;;;ECAnB,QAAA,eAAqB;EAkBZ,QAAA,UAAA;EAiEN,QAAA,mBAAA;EAAqB,QAAA,qBAAA;EAmCvB,QAAA,gBAAA;;;;;;;;ADjOd;AAKA;AAmEoB,iBQ3EJ,2BAAA,CAAA,CR2EI,EQ3E2B,qBR2E3B"}
|
package/dist/index.d.mts
CHANGED
|
@@ -55,6 +55,26 @@ interface PingopsProcessorConfig {
|
|
|
55
55
|
* Capture response body.
|
|
56
56
|
*/
|
|
57
57
|
captureResponseBody?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Maximum size of request body to capture (bytes).
|
|
60
|
+
* Applies to both `http` and `undici` instrumentations.
|
|
61
|
+
*
|
|
62
|
+
* Note: this is the number of raw bytes observed at the instrumentation layer.
|
|
63
|
+
* For compressed bodies, this is the compressed size.
|
|
64
|
+
*
|
|
65
|
+
* @defaultValue 4096 (4 KB)
|
|
66
|
+
*/
|
|
67
|
+
maxRequestBodySize?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Maximum size of response body to capture (bytes).
|
|
70
|
+
* Applies to both `http` and `undici` instrumentations.
|
|
71
|
+
*
|
|
72
|
+
* Note: this is the number of raw bytes observed at the instrumentation layer.
|
|
73
|
+
* For compressed bodies, this is the compressed size.
|
|
74
|
+
*
|
|
75
|
+
* @defaultValue 4096 (4 KB)
|
|
76
|
+
*/
|
|
77
|
+
maxResponseBodySize?: number;
|
|
58
78
|
/**
|
|
59
79
|
* Domain allow list rules.
|
|
60
80
|
*/
|
|
@@ -167,15 +187,11 @@ declare function shutdownTracerProvider(): Promise<void>;
|
|
|
167
187
|
/**
|
|
168
188
|
* Registers instrumentations for Node.js environment.
|
|
169
189
|
* This function is idempotent and can be called multiple times safely.
|
|
190
|
+
* When the SDK is initialized, all HTTP requests are instrumented.
|
|
170
191
|
*
|
|
171
|
-
* Instrumentation behavior:
|
|
172
|
-
* - If global instrumentation is enabled: all HTTP requests are instrumented
|
|
173
|
-
* - If global instrumentation is NOT enabled: only requests within wrapHttp blocks are instrumented
|
|
174
|
-
*
|
|
175
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
176
192
|
* @returns Array of Instrumentation instances
|
|
177
193
|
*/
|
|
178
|
-
declare function getInstrumentations(
|
|
194
|
+
declare function getInstrumentations(): Instrumentation[];
|
|
179
195
|
//#endregion
|
|
180
196
|
//#region src/instrumentations/http/pingops-http.d.ts
|
|
181
197
|
declare const PingopsSemanticAttributes: {
|
|
@@ -208,13 +224,13 @@ declare class PingopsHttpInstrumentation extends HttpInstrumentation {
|
|
|
208
224
|
//#endregion
|
|
209
225
|
//#region src/instrumentations/http/http.d.ts
|
|
210
226
|
/**
|
|
211
|
-
* Creates an HTTP instrumentation instance
|
|
227
|
+
* Creates an HTTP instrumentation instance.
|
|
228
|
+
* All outgoing HTTP requests are instrumented when the SDK is initialized.
|
|
212
229
|
*
|
|
213
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
214
230
|
* @param config - Optional configuration for the instrumentation
|
|
215
231
|
* @returns PingopsHttpInstrumentation instance
|
|
216
232
|
*/
|
|
217
|
-
declare function createHttpInstrumentation(
|
|
233
|
+
declare function createHttpInstrumentation(config?: Partial<PingopsHttpInstrumentationConfig>): PingopsHttpInstrumentation;
|
|
218
234
|
//#endregion
|
|
219
235
|
//#region src/instrumentations/undici/types.d.ts
|
|
220
236
|
interface UndiciRequest {
|
|
@@ -313,12 +329,12 @@ declare class UndiciInstrumentation extends InstrumentationBase<UndiciInstrument
|
|
|
313
329
|
//#endregion
|
|
314
330
|
//#region src/instrumentations/undici/undici.d.ts
|
|
315
331
|
/**
|
|
316
|
-
* Creates an Undici instrumentation instance
|
|
332
|
+
* Creates an Undici instrumentation instance.
|
|
333
|
+
* All requests are instrumented when the SDK is initialized.
|
|
317
334
|
*
|
|
318
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
319
335
|
* @returns UndiciInstrumentation instance
|
|
320
336
|
*/
|
|
321
|
-
declare function createUndiciInstrumentation(
|
|
337
|
+
declare function createUndiciInstrumentation(): UndiciInstrumentation;
|
|
322
338
|
//#endregion
|
|
323
339
|
export { PingopsHttpInstrumentation, type PingopsHttpInstrumentationConfig, PingopsHttpSemanticAttributes, type PingopsInstrumentationConfig, type PingopsProcessorConfig, PingopsSemanticAttributes, PingopsSpanProcessor, createHttpInstrumentation, createUndiciInstrumentation, getInstrumentations, getPingopsTracerProvider, setPingopsTracerProvider, shutdownTracerProvider };
|
|
324
340
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/span-processor.ts","../src/tracer-provider.ts","../src/instrumentations/index.ts","../src/instrumentations/http/pingops-http.ts","../src/instrumentations/http/http.ts","../src/instrumentations/undici/types.ts","../src/instrumentations/undici/pingops-undici.ts","../src/instrumentations/undici/undici.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAgBA;AAKA;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/span-processor.ts","../src/tracer-provider.ts","../src/instrumentations/index.ts","../src/instrumentations/http/pingops-http.ts","../src/instrumentations/http/http.ts","../src/instrumentations/undici/types.ts","../src/instrumentations/undici/pingops-undici.ts","../src/instrumentations/undici/undici.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAgBA;AAKA;;;;;AAsGgC,KA3GpB,iBAAA,GA2GoB,WAAA,GAAA,SAAA;;;;ACAnB,UDtGI,sBAAA,CCsGiB;EAkBZ;;;EAoGR,MAAA,CAAA,EAAA,MAAA;EAiGe;;;EAvN6B,OAAA,EAAA,MAAA;;;;ACxB1D;EA6BgB,KAAA,CAAA,EAAA,OAAA;EA2EM;;;;EC1LN;;;;ECWH;AAKb;AAoXA;EAEiB,eAAA,CAAA,EAAA,MAAA,EAAA;EAGJ;;;;ECzYG;;;EAEb,mBAAA,CAAA,EAAA,OAAA;EAA0B;;;;AChB7B;AAuBA;AAMA;AAIA;;EACS,kBAAA,CAAA,EAAA,MAAA;EAAe;;AAGxB;;;;;;;EAOiB,mBAAA,CAAA,EAAA,MAAqB;EAAK;;;EACjB,eAAA,CAAA,ENwCN,UMxCM,EAAA;EAKT;;;EAK2B,cAAA,CAAA,ENmCzB,UMnCyB,EAAA;EAAtB;;;;EAI6B,eAAA,CAAA,ENqC/B,qBMrC+B;EAAlC;;;;EANc,SAAA,CAAA,EAAA,MAAA;;;;ACoI/B;EAA+D,YAAA,CAAA,EAAA,MAAA;EAMzC;;;;;;ACrLtB;;;;eR8Ge;;;;;;AG1Gf;;;;ACWA;AAKiB,c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SAA8B,oBAAoB;;;;uBAMzC;;EPlLV,OAAA,CAAA,CAAA,EAAA,IAAA;EAKK,MAAA,CAAA,CAAA,EAAA,IAAA;EAmEG,UAAA,wBAAA,CAAA,CAAA,EAAA,IAAA;EAKD,QAAA,kBAAA;EAMC,QAAA,mBAAA;EAwBL,QAAA,gBAAA;EAAiB,QAAA,gBAAA;;;;ECAnB,QAAA,eAAqB;EAkBZ,QAAA,UAAA;EAiEN,QAAA,mBAAA;EAAqB,QAAA,qBAAA;EAmCvB,QAAA,gBAAA;;;;;;;;ADjOd;AAKA;AAmEoB,iBQ3EJ,2BAAA,CAAA,CR2EI,EQ3E2B,qBR2E3B"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BatchSpanProcessor, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
2
2
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
3
|
-
import { PINGOPS_CAPTURE_REQUEST_BODY, PINGOPS_CAPTURE_RESPONSE_BODY,
|
|
3
|
+
import { HTTP_RESPONSE_CONTENT_ENCODING, PINGOPS_CAPTURE_REQUEST_BODY, PINGOPS_CAPTURE_RESPONSE_BODY, bufferToBodyString, createLogger, extractSpanPayload, getPropagatedAttributesFromContext, isCompressedContentEncoding, isSpanEligible, shouldCaptureSpan } from "@pingops/core";
|
|
4
4
|
import { INVALID_SPAN_CONTEXT, SpanKind, SpanStatusCode, ValueType, context, propagation, trace } from "@opentelemetry/api";
|
|
5
5
|
import "@opentelemetry/sdk-trace-node";
|
|
6
6
|
import "@opentelemetry/resources";
|
|
@@ -100,7 +100,9 @@ var PingopsSpanProcessor = class {
|
|
|
100
100
|
setGlobalConfig({
|
|
101
101
|
captureRequestBody: config.captureRequestBody,
|
|
102
102
|
captureResponseBody: config.captureResponseBody,
|
|
103
|
-
domainAllowList: config.domainAllowList
|
|
103
|
+
domainAllowList: config.domainAllowList,
|
|
104
|
+
maxRequestBodySize: config.maxRequestBodySize,
|
|
105
|
+
maxResponseBodySize: config.maxResponseBodySize
|
|
104
106
|
});
|
|
105
107
|
logger$1.info("Initialized PingopsSpanProcessor", {
|
|
106
108
|
baseUrl: config.baseUrl,
|
|
@@ -429,11 +431,19 @@ function captureRequestBody(span, data, maxSize, semanticAttr, url) {
|
|
|
429
431
|
/**
|
|
430
432
|
* Captures response body from chunks
|
|
431
433
|
*/
|
|
432
|
-
function captureResponseBody(span, chunks, semanticAttr, url) {
|
|
434
|
+
function captureResponseBody(span, chunks, semanticAttr, responseHeaders, url) {
|
|
433
435
|
if (!shouldCaptureResponseBody$1(url)) return;
|
|
434
436
|
if (chunks && chunks.length) try {
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
+
const concatedChunks = Buffer.concat(chunks);
|
|
438
|
+
const contentEncoding = responseHeaders?.["content-encoding"];
|
|
439
|
+
if (isCompressedContentEncoding(contentEncoding)) {
|
|
440
|
+
setAttributeValue(span, semanticAttr, concatedChunks.toString("base64"));
|
|
441
|
+
const encStr = typeof contentEncoding === "string" ? contentEncoding : Array.isArray(contentEncoding) ? contentEncoding.map(String).join(", ") : void 0;
|
|
442
|
+
if (encStr) setAttributeValue(span, HTTP_RESPONSE_CONTENT_ENCODING, encStr);
|
|
443
|
+
} else {
|
|
444
|
+
const bodyStr = bufferToBodyString(concatedChunks);
|
|
445
|
+
if (bodyStr != null) setAttributeValue(span, semanticAttr, bodyStr);
|
|
446
|
+
}
|
|
437
447
|
} catch (e) {
|
|
438
448
|
console.error("Error occurred while capturing response body:", e);
|
|
439
449
|
}
|
|
@@ -535,7 +545,7 @@ var PingopsHttpInstrumentation = class extends HttpInstrumentation {
|
|
|
535
545
|
}
|
|
536
546
|
});
|
|
537
547
|
response.prependOnceListener("end", () => {
|
|
538
|
-
captureResponseBody(span, chunks, PingopsSemanticAttributes.HTTP_RESPONSE_BODY, url);
|
|
548
|
+
captureResponseBody(span, chunks, PingopsSemanticAttributes.HTTP_RESPONSE_BODY, headers, url);
|
|
539
549
|
});
|
|
540
550
|
}
|
|
541
551
|
if (originalResponseHook) originalResponseHook(span, response);
|
|
@@ -549,19 +559,19 @@ var PingopsHttpInstrumentation = class extends HttpInstrumentation {
|
|
|
549
559
|
* HTTP instrumentation for OpenTelemetry
|
|
550
560
|
*/
|
|
551
561
|
/**
|
|
552
|
-
* Creates an HTTP instrumentation instance
|
|
562
|
+
* Creates an HTTP instrumentation instance.
|
|
563
|
+
* All outgoing HTTP requests are instrumented when the SDK is initialized.
|
|
553
564
|
*
|
|
554
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
555
565
|
* @param config - Optional configuration for the instrumentation
|
|
556
566
|
* @returns PingopsHttpInstrumentation instance
|
|
557
567
|
*/
|
|
558
|
-
function createHttpInstrumentation(
|
|
568
|
+
function createHttpInstrumentation(config) {
|
|
569
|
+
const globalConfig$1 = getGlobalConfig();
|
|
559
570
|
return new PingopsHttpInstrumentation({
|
|
560
571
|
ignoreIncomingRequestHook: () => true,
|
|
561
|
-
ignoreOutgoingRequestHook: () =>
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
},
|
|
572
|
+
ignoreOutgoingRequestHook: () => false,
|
|
573
|
+
maxRequestBodySize: globalConfig$1?.maxRequestBodySize,
|
|
574
|
+
maxResponseBodySize: globalConfig$1?.maxResponseBodySize,
|
|
565
575
|
...config
|
|
566
576
|
});
|
|
567
577
|
}
|
|
@@ -818,9 +828,19 @@ var UndiciInstrumentation = class extends InstrumentationBase {
|
|
|
818
828
|
if (!record) return;
|
|
819
829
|
const { span, attributes, startTime } = record;
|
|
820
830
|
if (shouldCaptureResponseBody(record.url)) {
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
831
|
+
const maxResponseBodySize = this.getConfig().maxResponseBodySize ?? DEFAULT_MAX_RESPONSE_BODY_SIZE;
|
|
832
|
+
const contentEncoding = record.attributes?.["http.response.header.content-encoding"] ?? void 0;
|
|
833
|
+
const contentType = record.attributes?.["http.response.header.content-type"] ?? void 0;
|
|
834
|
+
if (record.responseBodySize === Infinity) span.setAttribute(HTTP_RESPONSE_BODY, `[truncated response body; exceeded maxResponseBodySize=${maxResponseBodySize}; content-type=${contentType ?? "unknown"}; content-encoding=${contentEncoding ?? "identity"}]`);
|
|
835
|
+
else if (record.responseBodyChunks.length > 0) try {
|
|
836
|
+
const responseBodyBuffer = Buffer.concat(record.responseBodyChunks);
|
|
837
|
+
if (isCompressedContentEncoding(contentEncoding)) {
|
|
838
|
+
span.setAttribute(HTTP_RESPONSE_BODY, responseBodyBuffer.toString("base64"));
|
|
839
|
+
if (contentEncoding) span.setAttribute(HTTP_RESPONSE_CONTENT_ENCODING, contentEncoding);
|
|
840
|
+
} else {
|
|
841
|
+
const bodyStr = bufferToBodyString(responseBodyBuffer);
|
|
842
|
+
if (bodyStr != null) span.setAttribute(HTTP_RESPONSE_BODY, bodyStr);
|
|
843
|
+
}
|
|
824
844
|
} catch (e) {
|
|
825
845
|
this._diag.error("Error occurred while capturing response body:", e);
|
|
826
846
|
}
|
|
@@ -859,7 +879,10 @@ var UndiciInstrumentation = class extends InstrumentationBase {
|
|
|
859
879
|
if (record.requestBodySize + chunk.length <= maxRequestBodySize) {
|
|
860
880
|
record.requestBodyChunks.push(chunk);
|
|
861
881
|
record.requestBodySize += chunk.length;
|
|
862
|
-
} else
|
|
882
|
+
} else {
|
|
883
|
+
record.requestBodySize = Infinity;
|
|
884
|
+
record.requestBodyChunks = [];
|
|
885
|
+
}
|
|
863
886
|
}
|
|
864
887
|
onBodySent({ request }) {
|
|
865
888
|
const record = this._recordFromReq.get(request);
|
|
@@ -868,7 +891,10 @@ var UndiciInstrumentation = class extends InstrumentationBase {
|
|
|
868
891
|
record.requestBodyChunks = [];
|
|
869
892
|
return;
|
|
870
893
|
}
|
|
871
|
-
if (record.
|
|
894
|
+
if (record.requestBodySize === Infinity) {
|
|
895
|
+
const maxRequestBodySize = this.getConfig().maxRequestBodySize ?? DEFAULT_MAX_REQUEST_BODY_SIZE;
|
|
896
|
+
record.span.setAttribute(HTTP_REQUEST_BODY, `[truncated request body; exceeded maxRequestBodySize=${maxRequestBodySize}]`);
|
|
897
|
+
} else if (record.requestBodyChunks.length > 0) try {
|
|
872
898
|
const requestBody = Buffer.concat(record.requestBodyChunks).toString("utf-8");
|
|
873
899
|
if (requestBody) record.span.setAttribute(HTTP_REQUEST_BODY, requestBody);
|
|
874
900
|
} catch (e) {
|
|
@@ -884,7 +910,10 @@ var UndiciInstrumentation = class extends InstrumentationBase {
|
|
|
884
910
|
if (record.responseBodySize + chunk.length <= maxResponseBodySize) {
|
|
885
911
|
record.responseBodyChunks.push(chunk);
|
|
886
912
|
record.responseBodySize += chunk.length;
|
|
887
|
-
} else
|
|
913
|
+
} else {
|
|
914
|
+
record.responseBodySize = Infinity;
|
|
915
|
+
record.responseBodyChunks = [];
|
|
916
|
+
}
|
|
888
917
|
}
|
|
889
918
|
recordRequestDuration(attributes, startTime) {
|
|
890
919
|
const metricsAttributes = {};
|
|
@@ -923,18 +952,18 @@ var UndiciInstrumentation = class extends InstrumentationBase {
|
|
|
923
952
|
* Undici instrumentation for OpenTelemetry
|
|
924
953
|
*/
|
|
925
954
|
/**
|
|
926
|
-
* Creates an Undici instrumentation instance
|
|
955
|
+
* Creates an Undici instrumentation instance.
|
|
956
|
+
* All requests are instrumented when the SDK is initialized.
|
|
927
957
|
*
|
|
928
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
929
958
|
* @returns UndiciInstrumentation instance
|
|
930
959
|
*/
|
|
931
|
-
function createUndiciInstrumentation(
|
|
960
|
+
function createUndiciInstrumentation() {
|
|
961
|
+
const globalConfig$1 = getGlobalConfig();
|
|
932
962
|
return new UndiciInstrumentation({
|
|
933
963
|
enabled: true,
|
|
934
|
-
ignoreRequestHook: () =>
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
}
|
|
964
|
+
ignoreRequestHook: () => false,
|
|
965
|
+
maxRequestBodySize: globalConfig$1?.maxRequestBodySize,
|
|
966
|
+
maxResponseBodySize: globalConfig$1?.maxResponseBodySize
|
|
938
967
|
});
|
|
939
968
|
}
|
|
940
969
|
|
|
@@ -944,18 +973,14 @@ let installed = false;
|
|
|
944
973
|
/**
|
|
945
974
|
* Registers instrumentations for Node.js environment.
|
|
946
975
|
* This function is idempotent and can be called multiple times safely.
|
|
976
|
+
* When the SDK is initialized, all HTTP requests are instrumented.
|
|
947
977
|
*
|
|
948
|
-
* Instrumentation behavior:
|
|
949
|
-
* - If global instrumentation is enabled: all HTTP requests are instrumented
|
|
950
|
-
* - If global instrumentation is NOT enabled: only requests within wrapHttp blocks are instrumented
|
|
951
|
-
*
|
|
952
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
953
978
|
* @returns Array of Instrumentation instances
|
|
954
979
|
*/
|
|
955
|
-
function getInstrumentations(
|
|
980
|
+
function getInstrumentations() {
|
|
956
981
|
if (installed) return [];
|
|
957
982
|
installed = true;
|
|
958
|
-
return [createHttpInstrumentation(
|
|
983
|
+
return [createHttpInstrumentation(), createUndiciInstrumentation()];
|
|
959
984
|
}
|
|
960
985
|
|
|
961
986
|
//#endregion
|