@pingops/otel 0.1.1 → 0.1.2

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.
Files changed (53) hide show
  1. package/dist/index.cjs +1018 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +342 -0
  4. package/dist/index.d.cts.map +1 -0
  5. package/dist/index.d.mts +342 -0
  6. package/dist/index.d.mts.map +1 -0
  7. package/dist/index.mjs +981 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +18 -6
  10. package/dist/config-store.d.ts +0 -26
  11. package/dist/config-store.d.ts.map +0 -1
  12. package/dist/config-store.js +0 -26
  13. package/dist/config-store.js.map +0 -1
  14. package/dist/config.d.ts +0 -83
  15. package/dist/config.d.ts.map +0 -1
  16. package/dist/config.js +0 -5
  17. package/dist/config.js.map +0 -1
  18. package/dist/index.d.ts +0 -11
  19. package/dist/index.d.ts.map +0 -1
  20. package/dist/index.js +0 -10
  21. package/dist/index.js.map +0 -1
  22. package/dist/instrumentations/http/http.d.ts +0 -13
  23. package/dist/instrumentations/http/http.d.ts.map +0 -1
  24. package/dist/instrumentations/http/http.js +0 -28
  25. package/dist/instrumentations/http/http.js.map +0 -1
  26. package/dist/instrumentations/http/pingops-http.d.ts +0 -52
  27. package/dist/instrumentations/http/pingops-http.d.ts.map +0 -1
  28. package/dist/instrumentations/http/pingops-http.js +0 -381
  29. package/dist/instrumentations/http/pingops-http.js.map +0 -1
  30. package/dist/instrumentations/index.d.ts +0 -17
  31. package/dist/instrumentations/index.d.ts.map +0 -1
  32. package/dist/instrumentations/index.js +0 -28
  33. package/dist/instrumentations/index.js.map +0 -1
  34. package/dist/instrumentations/undici/pingops-undici.d.ts +0 -25
  35. package/dist/instrumentations/undici/pingops-undici.d.ts.map +0 -1
  36. package/dist/instrumentations/undici/pingops-undici.js +0 -568
  37. package/dist/instrumentations/undici/pingops-undici.js.map +0 -1
  38. package/dist/instrumentations/undici/types.d.ts +0 -106
  39. package/dist/instrumentations/undici/types.d.ts.map +0 -1
  40. package/dist/instrumentations/undici/types.js +0 -2
  41. package/dist/instrumentations/undici/types.js.map +0 -1
  42. package/dist/instrumentations/undici/undici.d.ts +0 -12
  43. package/dist/instrumentations/undici/undici.d.ts.map +0 -1
  44. package/dist/instrumentations/undici/undici.js +0 -26
  45. package/dist/instrumentations/undici/undici.js.map +0 -1
  46. package/dist/span-processor.d.ts +0 -78
  47. package/dist/span-processor.d.ts.map +0 -1
  48. package/dist/span-processor.js +0 -282
  49. package/dist/span-processor.js.map +0 -1
  50. package/dist/tracer-provider.d.ts +0 -57
  51. package/dist/tracer-provider.d.ts.map +0 -1
  52. package/dist/tracer-provider.js +0 -184
  53. package/dist/tracer-provider.js.map +0 -1
@@ -1,568 +0,0 @@
1
- import * as diagch from "diagnostics_channel";
2
- import { URL } from "url";
3
- import { InstrumentationBase, safeExecuteInTheMiddle, } from "@opentelemetry/instrumentation";
4
- import { context, INVALID_SPAN_CONTEXT, propagation, SpanKind, SpanStatusCode, trace, ValueType, } from "@opentelemetry/api";
5
- import { hrTime, hrTimeDuration, hrTimeToMilliseconds, } from "@opentelemetry/core";
6
- import { ATTR_ERROR_TYPE, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_REQUEST_METHOD_ORIGINAL, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_NETWORK_PEER_ADDRESS, ATTR_NETWORK_PEER_PORT, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, ATTR_URL_PATH, ATTR_URL_QUERY, ATTR_URL_SCHEME, ATTR_USER_AGENT_ORIGINAL, METRIC_HTTP_CLIENT_REQUEST_DURATION, } from "@opentelemetry/semantic-conventions";
7
- import { PINGOPS_CAPTURE_REQUEST_BODY, PINGOPS_CAPTURE_RESPONSE_BODY, } from "@pingops/core";
8
- import { getGlobalConfig } from "../../config-store";
9
- // Constants
10
- const DEFAULT_MAX_REQUEST_BODY_SIZE = 4 * 1024; // 4 KB
11
- const DEFAULT_MAX_RESPONSE_BODY_SIZE = 4 * 1024; // 4 KB
12
- // Semantic attributes
13
- const HTTP_REQUEST_BODY = "http.request.body";
14
- const HTTP_RESPONSE_BODY = "http.response.body";
15
- /**
16
- * Extracts domain from URL
17
- */
18
- function extractDomainFromUrl(url) {
19
- try {
20
- const urlObj = new URL(url);
21
- return urlObj.hostname;
22
- }
23
- catch {
24
- const match = url.match(/^(?:https?:\/\/)?([^/]+)/);
25
- return match ? match[1] : "";
26
- }
27
- }
28
- /**
29
- * Gets domain rule configuration for a given URL
30
- */
31
- function getDomainRule(url, domainAllowList) {
32
- if (!domainAllowList) {
33
- return undefined;
34
- }
35
- const domain = extractDomainFromUrl(url);
36
- for (const rule of domainAllowList) {
37
- if (domain === rule.domain ||
38
- domain.endsWith(`.${rule.domain}`) ||
39
- domain === rule.domain.slice(1)) {
40
- return rule;
41
- }
42
- }
43
- return undefined;
44
- }
45
- /**
46
- * Determines if request body should be captured based on priority:
47
- * context > domain rule > global config > default (false)
48
- */
49
- function shouldCaptureRequestBody(url) {
50
- const activeContext = context.active();
51
- // Check context value first (from wrapHttp)
52
- const contextValue = activeContext.getValue(PINGOPS_CAPTURE_REQUEST_BODY);
53
- if (contextValue !== undefined) {
54
- return contextValue;
55
- }
56
- // Check domain-specific rule
57
- if (url) {
58
- const globalConfig = getGlobalConfig();
59
- const domainRule = getDomainRule(url, globalConfig?.domainAllowList);
60
- if (domainRule?.captureRequestBody !== undefined) {
61
- return domainRule.captureRequestBody;
62
- }
63
- }
64
- // Fall back to global config
65
- const globalConfig = getGlobalConfig();
66
- if (globalConfig?.captureRequestBody !== undefined) {
67
- return globalConfig.captureRequestBody;
68
- }
69
- // Default to false
70
- return false;
71
- }
72
- /**
73
- * Determines if response body should be captured based on priority:
74
- * context > domain rule > global config > default (false)
75
- */
76
- function shouldCaptureResponseBody(url) {
77
- const activeContext = context.active();
78
- // Check context value first (from wrapHttp)
79
- const contextValue = activeContext.getValue(PINGOPS_CAPTURE_RESPONSE_BODY);
80
- if (contextValue !== undefined) {
81
- return contextValue;
82
- }
83
- // Check domain-specific rule
84
- if (url) {
85
- const globalConfig = getGlobalConfig();
86
- const domainRule = getDomainRule(url, globalConfig?.domainAllowList);
87
- if (domainRule?.captureResponseBody !== undefined) {
88
- return domainRule.captureResponseBody;
89
- }
90
- }
91
- // Fall back to global config
92
- const globalConfig = getGlobalConfig();
93
- if (globalConfig?.captureResponseBody !== undefined) {
94
- return globalConfig.captureResponseBody;
95
- }
96
- // Default to false
97
- return false;
98
- }
99
- export class UndiciInstrumentation extends InstrumentationBase {
100
- _recordFromReq = new WeakMap();
101
- constructor(config = {}) {
102
- super("pingops-undici", "0.1.0", config);
103
- }
104
- // No need to instrument files/modules
105
- init() {
106
- return undefined;
107
- }
108
- disable() {
109
- super.disable();
110
- this._channelSubs.forEach((sub) => sub.unsubscribe());
111
- this._channelSubs.length = 0;
112
- }
113
- enable() {
114
- // "enabled" handling is currently a bit messy with InstrumentationBase.
115
- // If constructed with `{enabled: false}`, this `.enable()` is still called,
116
- // and `this.getConfig().enabled !== this.isEnabled()`, creating confusion.
117
- //
118
- // For now, this class will setup for instrumenting if `.enable()` is
119
- // called, but use `this.getConfig().enabled` to determine if
120
- // instrumentation should be generated. This covers the more likely common
121
- // case of config being given a construction time, rather than later via
122
- // `instance.enable()`, `.disable()`, or `.setConfig()` calls.
123
- super.enable();
124
- // This method is called by the super-class constructor before ours is
125
- // called. So we need to ensure the property is initalized.
126
- this._channelSubs = this._channelSubs || [];
127
- // Avoid to duplicate subscriptions
128
- if (this._channelSubs.length > 0) {
129
- return;
130
- }
131
- this.subscribeToChannel("undici:request:create", this.onRequestCreated.bind(this));
132
- this.subscribeToChannel("undici:client:sendHeaders", this.onRequestHeaders.bind(this));
133
- this.subscribeToChannel("undici:request:headers", this.onResponseHeaders.bind(this));
134
- this.subscribeToChannel("undici:request:trailers", this.onDone.bind(this));
135
- this.subscribeToChannel("undici:request:error", this.onError.bind(this));
136
- this.subscribeToChannel("undici:request:bodyChunkSent", this.onBodyChunkSent.bind(this));
137
- this.subscribeToChannel("undici:request:bodySent", this.onBodySent.bind(this));
138
- this.subscribeToChannel("undici:request:bodyChunkReceived", this.onBodyChunkReceived.bind(this));
139
- }
140
- _updateMetricInstruments() {
141
- this._httpClientDurationHistogram = this.meter.createHistogram(METRIC_HTTP_CLIENT_REQUEST_DURATION, {
142
- description: "Measures the duration of outbound HTTP requests.",
143
- unit: "s",
144
- valueType: ValueType.DOUBLE,
145
- advice: {
146
- explicitBucketBoundaries: [
147
- 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5,
148
- 7.5, 10,
149
- ],
150
- },
151
- });
152
- }
153
- subscribeToChannel(diagnosticChannel, onMessage) {
154
- // `diagnostics_channel` had a ref counting bug until v18.19.0.
155
- // https://github.com/nodejs/node/pull/47520
156
- const [major, minor] = process.version
157
- .replace("v", "")
158
- .split(".")
159
- .map((n) => Number(n));
160
- const useNewSubscribe = major > 18 || (major === 18 && minor >= 19);
161
- let unsubscribe;
162
- if (useNewSubscribe) {
163
- diagch.subscribe?.(diagnosticChannel, onMessage);
164
- unsubscribe = () => diagch.unsubscribe?.(diagnosticChannel, onMessage);
165
- }
166
- else {
167
- const channel = diagch.channel(diagnosticChannel);
168
- channel.subscribe(onMessage);
169
- unsubscribe = () => channel.unsubscribe(onMessage);
170
- }
171
- this._channelSubs.push({
172
- name: diagnosticChannel,
173
- unsubscribe,
174
- });
175
- }
176
- parseRequestHeaders(request) {
177
- const result = new Map();
178
- if (Array.isArray(request.headers)) {
179
- // headers are an array [k1, v2, k2, v2] (undici v6+)
180
- // values could be string or a string[] for multiple values
181
- for (let i = 0; i < request.headers.length; i += 2) {
182
- const key = request.headers[i];
183
- const value = request.headers[i + 1];
184
- // Key should always be a string, but the types don't know that, and let's be safe
185
- if (typeof key === "string") {
186
- result.set(key.toLowerCase(), value);
187
- }
188
- }
189
- }
190
- else if (typeof request.headers === "string") {
191
- // headers are a raw string (undici v5)
192
- // headers could be repeated in several lines for multiple values
193
- const headers = request.headers.split("\r\n");
194
- for (const line of headers) {
195
- if (!line) {
196
- continue;
197
- }
198
- const colonIndex = line.indexOf(":");
199
- if (colonIndex === -1) {
200
- // Invalid header? Probably this can't happen, but again let's be safe.
201
- continue;
202
- }
203
- const key = line.substring(0, colonIndex).toLowerCase();
204
- const value = line.substring(colonIndex + 1).trim();
205
- const allValues = result.get(key);
206
- if (allValues && Array.isArray(allValues)) {
207
- allValues.push(value);
208
- }
209
- else if (allValues) {
210
- result.set(key, [allValues, value]);
211
- }
212
- else {
213
- result.set(key, value);
214
- }
215
- }
216
- }
217
- return result;
218
- }
219
- // This is the 1st message we receive for each request (fired after request creation). Here we will
220
- // create the span and populate some atttributes, then link the span to the request for further
221
- // span processing
222
- onRequestCreated({ request }) {
223
- // Ignore if:
224
- // - instrumentation is disabled
225
- // - ignored by config
226
- // - method is 'CONNECT'
227
- const config = this.getConfig();
228
- const enabled = config.enabled !== false;
229
- const shouldIgnoreReq = safeExecuteInTheMiddle(() => !enabled ||
230
- request.method === "CONNECT" ||
231
- config.ignoreRequestHook?.(request), (e) => e && this._diag.error("caught ignoreRequestHook error: ", e), true);
232
- if (shouldIgnoreReq) {
233
- return;
234
- }
235
- const startTime = hrTime();
236
- let requestUrl;
237
- try {
238
- requestUrl = new URL(request.path, request.origin);
239
- }
240
- catch (err) {
241
- this._diag.warn("could not determine url.full:", err);
242
- // Skip instrumenting this request.
243
- return;
244
- }
245
- const urlScheme = requestUrl.protocol.replace(":", "");
246
- const requestMethod = this.getRequestMethod(request.method);
247
- const attributes = {
248
- [ATTR_HTTP_REQUEST_METHOD]: requestMethod,
249
- [ATTR_HTTP_REQUEST_METHOD_ORIGINAL]: request.method,
250
- [ATTR_URL_FULL]: requestUrl.toString(),
251
- [ATTR_URL_PATH]: requestUrl.pathname,
252
- [ATTR_URL_QUERY]: requestUrl.search,
253
- [ATTR_URL_SCHEME]: urlScheme,
254
- };
255
- const schemePorts = { https: "443", http: "80" };
256
- const serverAddress = requestUrl.hostname;
257
- const serverPort = requestUrl.port || schemePorts[urlScheme];
258
- attributes[ATTR_SERVER_ADDRESS] = serverAddress;
259
- if (serverPort && !isNaN(Number(serverPort))) {
260
- attributes[ATTR_SERVER_PORT] = Number(serverPort);
261
- }
262
- // Get user agent from headers
263
- const headersMap = this.parseRequestHeaders(request);
264
- const userAgentValues = headersMap.get("user-agent");
265
- if (userAgentValues) {
266
- // NOTE: having multiple user agents is not expected so
267
- // we're going to take last one like `curl` does
268
- // ref: https://curl.se/docs/manpage.html#-A
269
- const userAgent = Array.isArray(userAgentValues)
270
- ? userAgentValues[userAgentValues.length - 1]
271
- : userAgentValues;
272
- attributes[ATTR_USER_AGENT_ORIGINAL] = userAgent;
273
- }
274
- // Get attributes from the hook if present
275
- const hookAttributes = safeExecuteInTheMiddle(() => config.startSpanHook?.(request), (e) => e && this._diag.error("caught startSpanHook error: ", e), true);
276
- if (hookAttributes) {
277
- Object.entries(hookAttributes).forEach(([key, val]) => {
278
- attributes[key] = val;
279
- });
280
- }
281
- // Check if parent span is required via config and:
282
- // - if a parent is required but not present, we use a `NoopSpan` to still
283
- // propagate context without recording it.
284
- // - create a span otherwise
285
- const activeCtx = context.active();
286
- const currentSpan = trace.getSpan(activeCtx);
287
- let span;
288
- if (config.requireParentforSpans &&
289
- (!currentSpan || !trace.isSpanContextValid(currentSpan.spanContext()))) {
290
- span = trace.wrapSpanContext(INVALID_SPAN_CONTEXT);
291
- }
292
- else {
293
- span = this.tracer.startSpan(requestMethod === "_OTHER" ? "HTTP" : requestMethod, {
294
- kind: SpanKind.CLIENT,
295
- attributes: attributes,
296
- }, activeCtx);
297
- }
298
- // Execute the request hook if defined
299
- safeExecuteInTheMiddle(() => config.requestHook?.(span, request), (e) => e && this._diag.error("caught requestHook error: ", e), true);
300
- // Context propagation goes last so no hook can tamper
301
- // the propagation headers
302
- const requestContext = trace.setSpan(context.active(), span);
303
- const addedHeaders = {};
304
- propagation.inject(requestContext, addedHeaders);
305
- const headerEntries = Object.entries(addedHeaders);
306
- for (let i = 0; i < headerEntries.length; i++) {
307
- const [k, v] = headerEntries[i];
308
- if (typeof request.addHeader === "function") {
309
- request.addHeader(k, v);
310
- }
311
- else if (typeof request.headers === "string") {
312
- request.headers += `${k}: ${v}\r\n`;
313
- }
314
- else if (Array.isArray(request.headers)) {
315
- // undici@6.11.0 accidentally, briefly removed `request.addHeader()`.
316
- request.headers.push(k, v);
317
- }
318
- }
319
- this._recordFromReq.set(request, {
320
- span,
321
- attributes,
322
- startTime,
323
- requestBodyChunks: [],
324
- responseBodyChunks: [],
325
- requestBodySize: 0,
326
- responseBodySize: 0,
327
- url: requestUrl.toString(),
328
- });
329
- }
330
- // This is the 2nd message we receive for each request. It is fired when connection with
331
- // the remote is established and about to send the first byte. Here we do have info about the
332
- // remote address and port so we can populate some `network.*` attributes into the span
333
- onRequestHeaders({ request, socket }) {
334
- const record = this._recordFromReq.get(request);
335
- if (!record) {
336
- return;
337
- }
338
- const { span } = record;
339
- const { remoteAddress, remotePort } = socket;
340
- const spanAttributes = {
341
- [ATTR_NETWORK_PEER_ADDRESS]: remoteAddress,
342
- [ATTR_NETWORK_PEER_PORT]: remotePort,
343
- };
344
- const headersMap = this.parseRequestHeaders(request);
345
- for (const [name, value] of headersMap.entries()) {
346
- const attrValue = Array.isArray(value) ? value.join(", ") : value;
347
- spanAttributes[`http.request.header.${name}`] = attrValue;
348
- }
349
- span.setAttributes(spanAttributes);
350
- }
351
- // This is the 3rd message we get for each request and it's fired when the server
352
- // headers are received, body may not be accessible yet.
353
- // From the response headers we can set the status and content length
354
- onResponseHeaders({ request, response, }) {
355
- const record = this._recordFromReq.get(request);
356
- if (!record) {
357
- return;
358
- }
359
- const { span, attributes } = record;
360
- const spanAttributes = {
361
- [ATTR_HTTP_RESPONSE_STATUS_CODE]: response.statusCode,
362
- };
363
- const config = this.getConfig();
364
- // Execute the response hook if defined
365
- safeExecuteInTheMiddle(() => config.responseHook?.(span, { request, response }), (e) => e && this._diag.error("caught responseHook error: ", e), true);
366
- for (let idx = 0; idx < response.headers.length; idx = idx + 2) {
367
- const name = response.headers[idx].toString().toLowerCase();
368
- const value = response.headers[idx + 1];
369
- spanAttributes[`http.response.header.${name}`] = value.toString();
370
- if (name === "content-length") {
371
- const contentLength = Number(value.toString());
372
- if (!isNaN(contentLength)) {
373
- spanAttributes["http.response.header.content-length"] = contentLength;
374
- }
375
- }
376
- }
377
- span.setAttributes(spanAttributes);
378
- span.setStatus({
379
- code: response.statusCode >= 400
380
- ? SpanStatusCode.ERROR
381
- : SpanStatusCode.UNSET,
382
- });
383
- record.attributes = Object.assign(attributes, spanAttributes);
384
- }
385
- // This is the last event we receive if the request went without any errors
386
- onDone({ request }) {
387
- const record = this._recordFromReq.get(request);
388
- if (!record) {
389
- return;
390
- }
391
- const { span, attributes, startTime } = record;
392
- // Check if body capture is enabled before setting response body attribute
393
- if (shouldCaptureResponseBody(record.url)) {
394
- // Set response body attribute if we have chunks and haven't exceeded max size
395
- if (record.responseBodyChunks.length > 0 &&
396
- record.responseBodySize !== Infinity) {
397
- try {
398
- const responseBody = Buffer.concat(record.responseBodyChunks).toString("utf-8");
399
- if (responseBody) {
400
- span.setAttribute(HTTP_RESPONSE_BODY, responseBody);
401
- }
402
- }
403
- catch (e) {
404
- this._diag.error("Error occurred while capturing response body:", e);
405
- }
406
- }
407
- }
408
- // End the span
409
- span.end();
410
- this._recordFromReq.delete(request);
411
- // Record metrics
412
- this.recordRequestDuration(attributes, startTime);
413
- }
414
- // This is the event we get when something is wrong in the request like
415
- // - invalid options when calling `fetch` global API or any undici method for request
416
- // - connectivity errors such as unreachable host
417
- // - requests aborted through an `AbortController.signal`
418
- // NOTE: server errors are considered valid responses and it's the lib consumer
419
- // who should deal with that.
420
- onError({ request, error }) {
421
- const record = this._recordFromReq.get(request);
422
- if (!record) {
423
- return;
424
- }
425
- const { span, attributes, startTime } = record;
426
- // Check if body capture is enabled before setting request body attribute
427
- // (in case body was sent before error occurred)
428
- if (shouldCaptureRequestBody(record.url)) {
429
- // Set request body attribute if we have chunks and haven't exceeded max size
430
- if (record.requestBodyChunks.length > 0 &&
431
- record.requestBodySize !== Infinity) {
432
- try {
433
- const requestBody = Buffer.concat(record.requestBodyChunks).toString("utf-8");
434
- if (requestBody) {
435
- span.setAttribute(HTTP_REQUEST_BODY, requestBody);
436
- }
437
- }
438
- catch (e) {
439
- this._diag.error("Error occurred while capturing request body:", e);
440
- }
441
- }
442
- }
443
- // NOTE: in `undici@6.3.0` when request aborted the error type changes from
444
- // a custom error (`RequestAbortedError`) to a built-in `DOMException` carrying
445
- // some differences:
446
- // - `code` is from DOMEXception (ABORT_ERR: 20)
447
- // - `message` changes
448
- // - stacktrace is smaller and contains node internal frames
449
- span.recordException(error);
450
- span.setStatus({
451
- code: SpanStatusCode.ERROR,
452
- message: error.message,
453
- });
454
- span.end();
455
- this._recordFromReq.delete(request);
456
- // Record metrics (with the error)
457
- attributes[ATTR_ERROR_TYPE] = error.message;
458
- this.recordRequestDuration(attributes, startTime);
459
- }
460
- onBodyChunkSent({ request, chunk, }) {
461
- const record = this._recordFromReq.get(request);
462
- if (!record) {
463
- return;
464
- }
465
- // Check if body capture is enabled
466
- if (!shouldCaptureRequestBody(record.url)) {
467
- return;
468
- }
469
- const config = this.getConfig();
470
- const maxRequestBodySize = config.maxRequestBodySize ?? DEFAULT_MAX_REQUEST_BODY_SIZE;
471
- // Only accumulate chunks if we haven't exceeded the max size
472
- if (record.requestBodySize + chunk.length <= maxRequestBodySize) {
473
- record.requestBodyChunks.push(chunk);
474
- record.requestBodySize += chunk.length;
475
- }
476
- else if (record.requestBodyChunks.length === 0) {
477
- // If first chunk exceeds max size, don't track at all
478
- record.requestBodySize = Infinity; // Mark as exceeded
479
- }
480
- }
481
- onBodySent({ request }) {
482
- const record = this._recordFromReq.get(request);
483
- if (!record) {
484
- return;
485
- }
486
- // Check if body capture is enabled
487
- if (!shouldCaptureRequestBody(record.url)) {
488
- // Clear request body chunks to free memory
489
- record.requestBodyChunks = [];
490
- return;
491
- }
492
- // Set request body attribute if we have chunks and haven't exceeded max size
493
- if (record.requestBodyChunks.length > 0 &&
494
- record.requestBodySize !== Infinity) {
495
- try {
496
- const requestBody = Buffer.concat(record.requestBodyChunks).toString("utf-8");
497
- if (requestBody) {
498
- record.span.setAttribute(HTTP_REQUEST_BODY, requestBody);
499
- }
500
- }
501
- catch (e) {
502
- this._diag.error("Error occurred while capturing request body:", e);
503
- }
504
- }
505
- // Clear request body chunks to free memory
506
- record.requestBodyChunks = [];
507
- }
508
- onBodyChunkReceived({ request, chunk, }) {
509
- const record = this._recordFromReq.get(request);
510
- if (!record) {
511
- return;
512
- }
513
- // Check if body capture is enabled
514
- if (!shouldCaptureResponseBody(record.url)) {
515
- return;
516
- }
517
- const config = this.getConfig();
518
- const maxResponseBodySize = config.maxResponseBodySize ?? DEFAULT_MAX_RESPONSE_BODY_SIZE;
519
- // Only accumulate chunks if we haven't exceeded the max size
520
- if (record.responseBodySize + chunk.length <= maxResponseBodySize) {
521
- record.responseBodyChunks.push(chunk);
522
- record.responseBodySize += chunk.length;
523
- }
524
- else if (record.responseBodyChunks.length === 0) {
525
- // If first chunk exceeds max size, don't track at all
526
- record.responseBodySize = Infinity; // Mark as exceeded
527
- }
528
- }
529
- recordRequestDuration(attributes, startTime) {
530
- // Time to record metrics
531
- const metricsAttributes = {};
532
- // Get the attribs already in span attributes
533
- const keysToCopy = [
534
- ATTR_HTTP_RESPONSE_STATUS_CODE,
535
- ATTR_HTTP_REQUEST_METHOD,
536
- ATTR_SERVER_ADDRESS,
537
- ATTR_SERVER_PORT,
538
- ATTR_URL_SCHEME,
539
- ATTR_ERROR_TYPE,
540
- ];
541
- keysToCopy.forEach((key) => {
542
- if (key in attributes) {
543
- metricsAttributes[key] = attributes[key];
544
- }
545
- });
546
- // Take the duration and record it
547
- const durationSeconds = hrTimeToMilliseconds(hrTimeDuration(startTime, hrTime())) / 1000;
548
- this._httpClientDurationHistogram.record(durationSeconds, metricsAttributes);
549
- }
550
- getRequestMethod(original) {
551
- const knownMethods = {
552
- CONNECT: true,
553
- OPTIONS: true,
554
- HEAD: true,
555
- GET: true,
556
- POST: true,
557
- PUT: true,
558
- PATCH: true,
559
- DELETE: true,
560
- TRACE: true,
561
- };
562
- if (original.toUpperCase() in knownMethods) {
563
- return original.toUpperCase();
564
- }
565
- return "_OTHER";
566
- }
567
- }
568
- //# sourceMappingURL=pingops-undici.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pingops-undici.js","sourceRoot":"","sources":["../../../src/instrumentations/undici/pingops-undici.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,OAAO,EAGP,oBAAoB,EACpB,WAAW,EAEX,QAAQ,EACR,cAAc,EACd,KAAK,EACL,SAAS,GACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,MAAM,EACN,cAAc,EACd,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,iCAAiC,EACjC,8BAA8B,EAC9B,yBAAyB,EACzB,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,wBAAwB,EACxB,mCAAmC,GACpC,MAAM,qCAAqC,CAAC;AAc7C,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,GAE9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,YAAY;AACZ,MAAM,6BAA6B,GAAW,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO;AAC/D,MAAM,8BAA8B,GAAW,CAAC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