@pingops/otel 0.1.0 → 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.
- package/dist/index.cjs +1018 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +342 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +342 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +981 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +23 -11
- package/dist/config.d.ts +0 -75
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -5
- package/dist/config.js.map +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +0 -1
- package/dist/instrumentations/body-extractor.d.ts +0 -48
- package/dist/instrumentations/body-extractor.d.ts.map +0 -1
- package/dist/instrumentations/body-extractor.js +0 -361
- package/dist/instrumentations/body-extractor.js.map +0 -1
- package/dist/instrumentations/http.d.ts +0 -12
- package/dist/instrumentations/http.d.ts.map +0 -1
- package/dist/instrumentations/http.js +0 -38
- package/dist/instrumentations/http.js.map +0 -1
- package/dist/instrumentations/index.d.ts +0 -17
- package/dist/instrumentations/index.d.ts.map +0 -1
- package/dist/instrumentations/index.js +0 -32
- package/dist/instrumentations/index.js.map +0 -1
- package/dist/instrumentations/undici.d.ts +0 -12
- package/dist/instrumentations/undici.d.ts.map +0 -1
- package/dist/instrumentations/undici.js +0 -38
- package/dist/instrumentations/undici.js.map +0 -1
- package/dist/processor.d.ts +0 -82
- package/dist/processor.d.ts.map +0 -1
- package/dist/processor.js +0 -264
- package/dist/processor.js.map +0 -1
- package/dist/span-processor.d.ts +0 -78
- package/dist/span-processor.d.ts.map +0 -1
- package/dist/span-processor.js +0 -272
- package/dist/span-processor.js.map +0 -1
- package/dist/span-wrapper.d.ts +0 -60
- package/dist/span-wrapper.d.ts.map +0 -1
- package/dist/span-wrapper.js +0 -118
- package/dist/span-wrapper.js.map +0 -1
- package/dist/tracer-provider.d.ts +0 -57
- package/dist/tracer-provider.d.ts.map +0 -1
- package/dist/tracer-provider.js +0 -182
- package/dist/tracer-provider.js.map +0 -1
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utilities for extracting HTTP request and response bodies
|
|
3
|
-
*
|
|
4
|
-
* Handles streaming bodies by buffering data from streams
|
|
5
|
-
*/
|
|
6
|
-
import { PassThrough } from 'stream';
|
|
7
|
-
// Maximum body size to capture (1MB)
|
|
8
|
-
const MAX_BODY_SIZE = 1024 * 1024;
|
|
9
|
-
// Content types to skip (binary data)
|
|
10
|
-
const BINARY_CONTENT_TYPES = [
|
|
11
|
-
'application/octet-stream',
|
|
12
|
-
'image/',
|
|
13
|
-
'video/',
|
|
14
|
-
'audio/',
|
|
15
|
-
'application/pdf',
|
|
16
|
-
'application/zip',
|
|
17
|
-
'application/gzip',
|
|
18
|
-
];
|
|
19
|
-
/**
|
|
20
|
-
* Checks if a content type should be skipped (binary data)
|
|
21
|
-
*/
|
|
22
|
-
function shouldSkipContentType(contentType) {
|
|
23
|
-
if (!contentType) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
const normalized = contentType.toLowerCase().split(';')[0].trim();
|
|
27
|
-
return BINARY_CONTENT_TYPES.some((skipType) => normalized.startsWith(skipType));
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Converts a body value to a string representation
|
|
31
|
-
*/
|
|
32
|
-
function bodyToString(body) {
|
|
33
|
-
if (body === null || body === undefined) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
// Already a string
|
|
37
|
-
if (typeof body === 'string') {
|
|
38
|
-
return body.length > MAX_BODY_SIZE ? body.substring(0, MAX_BODY_SIZE) : body;
|
|
39
|
-
}
|
|
40
|
-
// Buffer
|
|
41
|
-
if (Buffer.isBuffer(body)) {
|
|
42
|
-
if (body.length > MAX_BODY_SIZE) {
|
|
43
|
-
return body.subarray(0, MAX_BODY_SIZE).toString('utf8');
|
|
44
|
-
}
|
|
45
|
-
return body.toString('utf8');
|
|
46
|
-
}
|
|
47
|
-
// ArrayBuffer or ArrayBufferView
|
|
48
|
-
if (body instanceof ArrayBuffer) {
|
|
49
|
-
const buffer = Buffer.from(body);
|
|
50
|
-
if (buffer.length > MAX_BODY_SIZE) {
|
|
51
|
-
return buffer.subarray(0, MAX_BODY_SIZE).toString('utf8');
|
|
52
|
-
}
|
|
53
|
-
return buffer.toString('utf8');
|
|
54
|
-
}
|
|
55
|
-
// Uint8Array or similar
|
|
56
|
-
if (body instanceof Uint8Array) {
|
|
57
|
-
const buffer = Buffer.from(body);
|
|
58
|
-
if (buffer.length > MAX_BODY_SIZE) {
|
|
59
|
-
return buffer.subarray(0, MAX_BODY_SIZE).toString('utf8');
|
|
60
|
-
}
|
|
61
|
-
return buffer.toString('utf8');
|
|
62
|
-
}
|
|
63
|
-
// Try to convert to string via JSON or toString
|
|
64
|
-
try {
|
|
65
|
-
if (typeof body === 'object') {
|
|
66
|
-
const json = JSON.stringify(body);
|
|
67
|
-
return json.length > MAX_BODY_SIZE ? json.substring(0, MAX_BODY_SIZE) : json;
|
|
68
|
-
}
|
|
69
|
-
const str = String(body);
|
|
70
|
-
return str.length > MAX_BODY_SIZE ? str.substring(0, MAX_BODY_SIZE) : str;
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Captures HTTP request body using event handlers
|
|
78
|
-
*
|
|
79
|
-
* Uses a PassThrough stream to capture data via events, while still needing to
|
|
80
|
-
* intercept write()/end() to feed data into the stream
|
|
81
|
-
*/
|
|
82
|
-
export function captureHttpRequestBody(span, request) {
|
|
83
|
-
// Check content-type to see if we should skip
|
|
84
|
-
const contentType = request.getHeader('content-type');
|
|
85
|
-
console.log('captureHttpRequestBody contentType', contentType);
|
|
86
|
-
if (shouldSkipContentType(typeof contentType === 'string' ? contentType : null)) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const chunks = [];
|
|
90
|
-
let totalSize = 0;
|
|
91
|
-
// Create a PassThrough stream to capture data via events
|
|
92
|
-
const captureStream = new PassThrough();
|
|
93
|
-
// Listen to data events on the capture stream
|
|
94
|
-
captureStream.on('data', (chunk) => {
|
|
95
|
-
if (totalSize < MAX_BODY_SIZE) {
|
|
96
|
-
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
97
|
-
const remaining = MAX_BODY_SIZE - totalSize;
|
|
98
|
-
if (buffer.length <= remaining) {
|
|
99
|
-
chunks.push(buffer);
|
|
100
|
-
totalSize += buffer.length;
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
chunks.push(buffer.subarray(0, remaining));
|
|
104
|
-
totalSize = MAX_BODY_SIZE;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
// Listen to end event to set the body attribute
|
|
109
|
-
captureStream.once('end', () => {
|
|
110
|
-
console.log('captureStream.once end', chunks);
|
|
111
|
-
if (chunks.length > 0 && span.isRecording()) {
|
|
112
|
-
try {
|
|
113
|
-
const body = Buffer.concat(chunks).toString('utf8');
|
|
114
|
-
span.setAttribute('http.request.body', body);
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
// Silently fail if we can't convert to string
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
// Handle errors gracefully
|
|
122
|
-
captureStream.once('error', () => {
|
|
123
|
-
// Don't set body on error
|
|
124
|
-
});
|
|
125
|
-
// Store original methods
|
|
126
|
-
const originalWrite = request.write.bind(request);
|
|
127
|
-
const originalEnd = request.end.bind(request);
|
|
128
|
-
// Intercept write() to feed data into our event-based capture stream
|
|
129
|
-
request.write = function (chunk, encoding, callback) {
|
|
130
|
-
// Write to capture stream to trigger 'data' events
|
|
131
|
-
if (chunk) {
|
|
132
|
-
captureStream.write(chunk, encoding);
|
|
133
|
-
}
|
|
134
|
-
return originalWrite(chunk, encoding, callback);
|
|
135
|
-
};
|
|
136
|
-
// Intercept end() to finalize capture
|
|
137
|
-
request.end = function (chunk, encoding, callback) {
|
|
138
|
-
// Write final chunk to capture stream if present
|
|
139
|
-
if (chunk) {
|
|
140
|
-
captureStream.write(chunk, encoding);
|
|
141
|
-
}
|
|
142
|
-
// End the capture stream to trigger 'end' event
|
|
143
|
-
captureStream.end();
|
|
144
|
-
return originalEnd(chunk, encoding, callback);
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Extracts request body from HTTP ClientRequest (legacy function, kept for compatibility)
|
|
149
|
-
*/
|
|
150
|
-
export function extractHttpRequestBody(_request) {
|
|
151
|
-
// This function is kept for compatibility but captureHttpRequestBody should be used instead
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Captures HTTP response body by listening to stream events
|
|
156
|
-
*/
|
|
157
|
-
export function captureHttpResponseBody(span, response) {
|
|
158
|
-
// Check content-type to see if we should skip
|
|
159
|
-
const contentType = response.headers['content-type'];
|
|
160
|
-
console.log('captureHttpResponseBody contentType', contentType);
|
|
161
|
-
if (shouldSkipContentType(typeof contentType === 'string' ? contentType : Array.isArray(contentType) ? contentType[0] : null)) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
// Check if stream is already consumed or destroyed
|
|
165
|
-
if (response.readableEnded || response.destroyed) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const chunks = [];
|
|
169
|
-
let totalSize = 0;
|
|
170
|
-
// Listen to data events to capture chunks
|
|
171
|
-
response.on('data', (chunk) => {
|
|
172
|
-
if (totalSize < MAX_BODY_SIZE) {
|
|
173
|
-
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
174
|
-
const remaining = MAX_BODY_SIZE - totalSize;
|
|
175
|
-
if (buffer.length <= remaining) {
|
|
176
|
-
chunks.push(buffer);
|
|
177
|
-
totalSize += buffer.length;
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
chunks.push(buffer.subarray(0, remaining));
|
|
181
|
-
totalSize = MAX_BODY_SIZE;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
// When stream ends, set the body attribute
|
|
186
|
-
response.once('end', () => {
|
|
187
|
-
console.log('captureHttpResponseBody.once end', chunks);
|
|
188
|
-
if (chunks.length > 0 && span.isRecording()) {
|
|
189
|
-
try {
|
|
190
|
-
const body = Buffer.concat(chunks).toString('utf8');
|
|
191
|
-
span.setAttribute('http.response.body', body);
|
|
192
|
-
}
|
|
193
|
-
catch (error) {
|
|
194
|
-
// Silently fail if we can't convert to string
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
// Handle errors gracefully
|
|
199
|
-
response.once('error', () => {
|
|
200
|
-
// Don't set body on error
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Extracts response body from HTTP IncomingMessage (legacy function, kept for compatibility)
|
|
205
|
-
*/
|
|
206
|
-
export function extractHttpResponseBody(_response) {
|
|
207
|
-
// This function is kept for compatibility but captureHttpResponseBody should be used instead
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Extracts request body from Undici request
|
|
212
|
-
*/
|
|
213
|
-
export function extractUndiciRequestBody(request) {
|
|
214
|
-
const { body, contentType } = request;
|
|
215
|
-
// Skip if content type indicates binary data
|
|
216
|
-
if (shouldSkipContentType(contentType)) {
|
|
217
|
-
return null;
|
|
218
|
-
}
|
|
219
|
-
return bodyToString(body);
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Gets content-type from Undici response headers
|
|
223
|
-
*/
|
|
224
|
-
function getUndiciContentType(headers) {
|
|
225
|
-
if (!headers) {
|
|
226
|
-
return null;
|
|
227
|
-
}
|
|
228
|
-
if (Array.isArray(headers)) {
|
|
229
|
-
// Headers are in format [key1, value1, key2, value2, ...]
|
|
230
|
-
for (let i = 0; i < headers.length; i += 2) {
|
|
231
|
-
const key = headers[i]?.toString().toLowerCase();
|
|
232
|
-
if (key === 'content-type') {
|
|
233
|
-
return headers[i + 1]?.toString() || null;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
else if (typeof headers === 'object') {
|
|
238
|
-
const contentTypeHeader = headers['content-type'] || headers['Content-Type'];
|
|
239
|
-
if (typeof contentTypeHeader === 'string') {
|
|
240
|
-
return contentTypeHeader;
|
|
241
|
-
}
|
|
242
|
-
else if (Array.isArray(contentTypeHeader) && contentTypeHeader.length > 0) {
|
|
243
|
-
return contentTypeHeader[0];
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return null;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Captures Undici response body by reading from the body stream
|
|
250
|
-
*/
|
|
251
|
-
export function captureUndiciResponseBody(span, response) {
|
|
252
|
-
// Get content-type
|
|
253
|
-
const contentType = getUndiciContentType(response.headers);
|
|
254
|
-
if (shouldSkipContentType(contentType)) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
// Check if body is a stream or readable
|
|
258
|
-
const body = response.body;
|
|
259
|
-
if (!body) {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
// If body is directly available (not a stream), extract it
|
|
263
|
-
if (body && typeof body !== 'object' || !('on' in body) && !('pipe' in body)) {
|
|
264
|
-
const bodyStr = bodyToString(body);
|
|
265
|
-
if (bodyStr !== null && span.isRecording()) {
|
|
266
|
-
span.setAttribute('http.response.body', bodyStr);
|
|
267
|
-
}
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
// Handle stream-like body (Readable, Body, etc.)
|
|
271
|
-
if (body && typeof body === 'object' && ('on' in body || 'pipe' in body || 'read' in body)) {
|
|
272
|
-
const chunks = [];
|
|
273
|
-
let totalSize = 0;
|
|
274
|
-
let captured = false;
|
|
275
|
-
// Try to read from stream
|
|
276
|
-
const captureChunk = (chunk) => {
|
|
277
|
-
if (captured || totalSize >= MAX_BODY_SIZE) {
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
281
|
-
const remaining = MAX_BODY_SIZE - totalSize;
|
|
282
|
-
if (buffer.length <= remaining) {
|
|
283
|
-
chunks.push(buffer);
|
|
284
|
-
totalSize += buffer.length;
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
chunks.push(buffer.subarray(0, remaining));
|
|
288
|
-
totalSize = MAX_BODY_SIZE;
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
// Try different stream interfaces
|
|
292
|
-
if (typeof body.on === 'function') {
|
|
293
|
-
// Node.js stream interface
|
|
294
|
-
body.on('data', captureChunk);
|
|
295
|
-
body.once('end', () => {
|
|
296
|
-
if (!captured && chunks.length > 0 && span.isRecording()) {
|
|
297
|
-
captured = true;
|
|
298
|
-
try {
|
|
299
|
-
const bodyStr = Buffer.concat(chunks).toString('utf8');
|
|
300
|
-
span.setAttribute('http.response.body', bodyStr);
|
|
301
|
-
}
|
|
302
|
-
catch {
|
|
303
|
-
// Silently fail
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
body.once('error', () => {
|
|
308
|
-
// Don't capture on error
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
else if (typeof body.text === 'function') {
|
|
312
|
-
// Fetch Body interface
|
|
313
|
-
body.text().then((text) => {
|
|
314
|
-
if (!captured && span.isRecording()) {
|
|
315
|
-
captured = true;
|
|
316
|
-
const bodyStr = text.length > MAX_BODY_SIZE
|
|
317
|
-
? text.substring(0, MAX_BODY_SIZE)
|
|
318
|
-
: text;
|
|
319
|
-
span.setAttribute('http.response.body', bodyStr);
|
|
320
|
-
}
|
|
321
|
-
}).catch(() => {
|
|
322
|
-
// Silently fail
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
else if (typeof body.json === 'function') {
|
|
326
|
-
// Fetch Body interface with JSON
|
|
327
|
-
body.json().then((json) => {
|
|
328
|
-
if (!captured && span.isRecording()) {
|
|
329
|
-
captured = true;
|
|
330
|
-
try {
|
|
331
|
-
const jsonStr = JSON.stringify(json);
|
|
332
|
-
const bodyStr = jsonStr.length > MAX_BODY_SIZE
|
|
333
|
-
? jsonStr.substring(0, MAX_BODY_SIZE)
|
|
334
|
-
: jsonStr;
|
|
335
|
-
span.setAttribute('http.response.body', bodyStr);
|
|
336
|
-
}
|
|
337
|
-
catch {
|
|
338
|
-
// Silently fail
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}).catch(() => {
|
|
342
|
-
// Silently fail
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Extracts response body from Undici response (legacy function, kept for compatibility)
|
|
349
|
-
*/
|
|
350
|
-
export function extractUndiciResponseBody(response) {
|
|
351
|
-
// Check if body is directly available (not a stream)
|
|
352
|
-
if (response.body !== undefined) {
|
|
353
|
-
const contentType = getUndiciContentType(response.headers);
|
|
354
|
-
if (shouldSkipContentType(contentType)) {
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
357
|
-
return bodyToString(response.body);
|
|
358
|
-
}
|
|
359
|
-
return null;
|
|
360
|
-
}
|
|
361
|
-
//# sourceMappingURL=body-extractor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"body-extractor.js","sourceRoot":"","sources":["../../src/instrumentations/body-extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qCAAqC;AACrC,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC;AAElC,sCAAsC;AACtC,MAAM,oBAAoB,GAAG;IAC3B,0BAA0B;IAC1B,QAA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D,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP instrumentation for OpenTelemetry
|
|
3
|
-
*/
|
|
4
|
-
import { HttpInstrumentation } from "@opentelemetry/instrumentation-http";
|
|
5
|
-
/**
|
|
6
|
-
* Creates an HTTP instrumentation instance
|
|
7
|
-
*
|
|
8
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
9
|
-
* @returns HttpInstrumentation instance
|
|
10
|
-
*/
|
|
11
|
-
export declare function createHttpInstrumentation(isGlobalInstrumentationEnabled: () => boolean): HttpInstrumentation;
|
|
12
|
-
//# sourceMappingURL=http.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/instrumentations/http.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAM1E;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,8BAA8B,EAAE,MAAM,OAAO,GAC5C,mBAAmB,CA+BrB"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP instrumentation for OpenTelemetry
|
|
3
|
-
*/
|
|
4
|
-
import { HttpInstrumentation } from "@opentelemetry/instrumentation-http";
|
|
5
|
-
import { context } from "@opentelemetry/api";
|
|
6
|
-
import { PINGOPS_HTTP_ENABLED } from "@pingops/core";
|
|
7
|
-
/**
|
|
8
|
-
* Creates an HTTP instrumentation instance
|
|
9
|
-
*
|
|
10
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
11
|
-
* @returns HttpInstrumentation instance
|
|
12
|
-
*/
|
|
13
|
-
export function createHttpInstrumentation(isGlobalInstrumentationEnabled) {
|
|
14
|
-
return new HttpInstrumentation({
|
|
15
|
-
ignoreIncomingRequestHook: () => true, // Only instrument outgoing requests
|
|
16
|
-
ignoreOutgoingRequestHook: () => {
|
|
17
|
-
// If global instrumentation is enabled, instrument all outgoing requests
|
|
18
|
-
if (isGlobalInstrumentationEnabled()) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
// If global instrumentation is NOT enabled, only instrument when PINGOPS_HTTP_ENABLED is true
|
|
22
|
-
return context.active().getValue(PINGOPS_HTTP_ENABLED) !== true;
|
|
23
|
-
},
|
|
24
|
-
requestHook: (span, request) => {
|
|
25
|
-
const headers = request.headers;
|
|
26
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
27
|
-
span.setAttribute(`http.request.header.${key.toLowerCase()}`, Array.isArray(value) ? value.join(",") : String(value));
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
responseHook: (span, response) => {
|
|
31
|
-
const headers = response.headers;
|
|
32
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
33
|
-
span.setAttribute(`http.response.header.${key.toLowerCase()}`, Array.isArray(value) ? value.join(",") : String(value));
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=http.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/instrumentations/http.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAIrD;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,8BAA6C;IAE7C,OAAO,IAAI,mBAAmB,CAAC;QAC7B,yBAAyB,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,oCAAoC;QAC3E,yBAAyB,EAAE,GAAG,E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|
-
*/
|
|
4
|
-
import type { Instrumentation } from "@opentelemetry/instrumentation";
|
|
5
|
-
/**
|
|
6
|
-
* Registers instrumentations for Node.js environment.
|
|
7
|
-
* This function is idempotent and can be called multiple times safely.
|
|
8
|
-
*
|
|
9
|
-
* Instrumentation behavior:
|
|
10
|
-
* - If global instrumentation is enabled: all HTTP requests are instrumented
|
|
11
|
-
* - If global instrumentation is NOT enabled: only requests within wrapHttp blocks are instrumented
|
|
12
|
-
*
|
|
13
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
14
|
-
* @returns Array of Instrumentation instances
|
|
15
|
-
*/
|
|
16
|
-
export declare function getInstrumentations(isGlobalInstrumentationEnabled: () => boolean): Instrumentation[];
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/instrumentations/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAMtE;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,8BAA8B,EAAE,MAAM,OAAO,GAC5C,eAAe,EAAE,CAcnB"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Instrumentation setup for HTTP, fetch, undici, and GenAI
|
|
3
|
-
*/
|
|
4
|
-
import { registerInstrumentations } from "@opentelemetry/instrumentation";
|
|
5
|
-
import { createHttpInstrumentation } from "./http";
|
|
6
|
-
import { createUndiciInstrumentation } from "./undici";
|
|
7
|
-
let installed = false;
|
|
8
|
-
/**
|
|
9
|
-
* Registers instrumentations for Node.js environment.
|
|
10
|
-
* This function is idempotent and can be called multiple times safely.
|
|
11
|
-
*
|
|
12
|
-
* Instrumentation behavior:
|
|
13
|
-
* - If global instrumentation is enabled: all HTTP requests are instrumented
|
|
14
|
-
* - If global instrumentation is NOT enabled: only requests within wrapHttp blocks are instrumented
|
|
15
|
-
*
|
|
16
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
17
|
-
* @returns Array of Instrumentation instances
|
|
18
|
-
*/
|
|
19
|
-
export function getInstrumentations(isGlobalInstrumentationEnabled) {
|
|
20
|
-
if (installed) {
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
registerInstrumentations({
|
|
24
|
-
instrumentations: [
|
|
25
|
-
createHttpInstrumentation(isGlobalInstrumentationEnabled),
|
|
26
|
-
createUndiciInstrumentation(isGlobalInstrumentationEnabled),
|
|
27
|
-
],
|
|
28
|
-
});
|
|
29
|
-
installed = true;
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/instrumentations/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAEvD,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CACjC,8BAA6C;IAE7C,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,wBAAwB,CAAC;QACvB,gBAAgB,EAAE;YAChB,yBAAyB,CAAC,8BAA8B,CAAC;YACzD,2BAA2B,CAAC,8BAA8B,CAAC;SAC5D;KACF,CAAC,CAAC;IAEH,SAAS,GAAG,IAAI,CAAC;IACjB,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Undici instrumentation for OpenTelemetry
|
|
3
|
-
*/
|
|
4
|
-
import { UndiciInstrumentation } from "@opentelemetry/instrumentation-undici";
|
|
5
|
-
/**
|
|
6
|
-
* Creates an Undici instrumentation instance
|
|
7
|
-
*
|
|
8
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
9
|
-
* @returns UndiciInstrumentation instance
|
|
10
|
-
*/
|
|
11
|
-
export declare function createUndiciInstrumentation(isGlobalInstrumentationEnabled: () => boolean): UndiciInstrumentation;
|
|
12
|
-
//# sourceMappingURL=undici.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"undici.d.ts","sourceRoot":"","sources":["../../src/instrumentations/undici.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAK9E;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,8BAA8B,EAAE,MAAM,OAAO,GAC5C,qBAAqB,CA+BvB"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Undici instrumentation for OpenTelemetry
|
|
3
|
-
*/
|
|
4
|
-
import { UndiciInstrumentation } from "@opentelemetry/instrumentation-undici";
|
|
5
|
-
import { context } from "@opentelemetry/api";
|
|
6
|
-
import { PINGOPS_HTTP_ENABLED } from "@pingops/core";
|
|
7
|
-
/**
|
|
8
|
-
* Creates an Undici instrumentation instance
|
|
9
|
-
*
|
|
10
|
-
* @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
|
|
11
|
-
* @returns UndiciInstrumentation instance
|
|
12
|
-
*/
|
|
13
|
-
export function createUndiciInstrumentation(isGlobalInstrumentationEnabled) {
|
|
14
|
-
return new UndiciInstrumentation({
|
|
15
|
-
enabled: true,
|
|
16
|
-
ignoreRequestHook: () => {
|
|
17
|
-
// If global instrumentation is enabled, instrument all requests
|
|
18
|
-
if (isGlobalInstrumentationEnabled()) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
// If global instrumentation is NOT enabled, only instrument when PINGOPS_HTTP_ENABLED is true
|
|
22
|
-
return context.active().getValue(PINGOPS_HTTP_ENABLED) !== true;
|
|
23
|
-
},
|
|
24
|
-
requestHook: (span, request) => {
|
|
25
|
-
const headers = request.headers;
|
|
26
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
27
|
-
span.setAttribute(`http.request.header.${key.toLowerCase()}`, Array.isArray(value) ? value.join(",") : String(value));
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
responseHook: (span, { response }) => {
|
|
31
|
-
const headers = response.headers;
|
|
32
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
33
|
-
span.setAttribute(`http.response.header.${key.toLowerCase()}`, Array.isArray(value) ? value.join(",") : String(value));
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=undici.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"undici.js","sourceRoot":"","sources":["../../src/instrumentations/undici.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGrD;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,8BAA6C;IAE7C,OAAO,IAAI,qBAAqB,CAAC;QAC/B,OAAO,EAAE,IAAI;QACb,iBAAiB,EAAE,GAAG,EAAE;YACtB,gEAAgE;YAChE,IAAI,8BAA8B,EAAE,EAAE,CAAC;gBACrC,OAAO,KAAK,CAAC;YACf,CAAC;YACD,8FAA8F;YAC9F,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;QAClE,CAAC;QACD,WAAW,EAAE,CAAC,IAAU,EAAE,OAAO,EAAE,EAAE;YACnC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;YAEhC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnD,IAAI,CAAC,YAAY,CACf,uBAAuB,GAAG,CAAC,WAAW,EAAE,EAAE,EAC1C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CAAC;YACJ,CAAC;QACH,CAAC;QACD,YAAY,EAAE,CAAC,IAAU,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YACzC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;YACjC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnD,IAAI,CAAC,YAAY,CACf,wBAAwB,GAAG,CAAC,WAAW,EAAE,EAAE,EAC3C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/processor.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PingopsSpanProcessor - OpenTelemetry SpanProcessor implementation
|
|
3
|
-
* Observes finished spans and sends eligible ones to PingOps backend
|
|
4
|
-
*
|
|
5
|
-
* This processor provides:
|
|
6
|
-
* - Automatic filtering of spans (CLIENT spans with HTTP/GenAI attributes only)
|
|
7
|
-
* - Domain and header filtering based on configuration
|
|
8
|
-
* - Batched or immediate export modes using OTLP exporters
|
|
9
|
-
* - Fire-and-forget transport (never blocks application)
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
14
|
-
* import { PingopsSpanProcessor } from '@pingops/otel';
|
|
15
|
-
*
|
|
16
|
-
* const sdk = new NodeSDK({
|
|
17
|
-
* spanProcessors: [
|
|
18
|
-
* new PingopsSpanProcessor({
|
|
19
|
-
* apiKey: 'your-api-key',
|
|
20
|
-
* baseUrl: 'https://api.pingops.com',
|
|
21
|
-
* serviceName: 'my-service',
|
|
22
|
-
* exportMode: 'batched', // or 'immediate'
|
|
23
|
-
* domainAllowList: [
|
|
24
|
-
* { domain: 'api.example.com' }
|
|
25
|
-
* ]
|
|
26
|
-
* })
|
|
27
|
-
* ]
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* sdk.start();
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
import type { SpanProcessor, ReadableSpan, Span } from '@opentelemetry/sdk-trace-base';
|
|
34
|
-
import type { Context } from '@opentelemetry/api';
|
|
35
|
-
import type { PingopsProcessorConfig } from './config';
|
|
36
|
-
/**
|
|
37
|
-
* OpenTelemetry span processor for sending spans to PingOps backend.
|
|
38
|
-
*
|
|
39
|
-
* This processor wraps OpenTelemetry's built-in processors (BatchSpanProcessor or SimpleSpanProcessor)
|
|
40
|
-
* and applies filtering before passing spans to the OTLP exporter.
|
|
41
|
-
*/
|
|
42
|
-
export declare class PingopsSpanProcessor implements SpanProcessor {
|
|
43
|
-
private processor;
|
|
44
|
-
private config;
|
|
45
|
-
/**
|
|
46
|
-
* Creates a new PingopsSpanProcessor instance.
|
|
47
|
-
*
|
|
48
|
-
* @param config - Configuration parameters for the processor
|
|
49
|
-
*/
|
|
50
|
-
constructor(config: PingopsProcessorConfig);
|
|
51
|
-
/**
|
|
52
|
-
* Called when a span starts - extracts parent attributes from context and adds them to the span
|
|
53
|
-
*/
|
|
54
|
-
onStart(span: Span, parentContext: Context): void;
|
|
55
|
-
/**
|
|
56
|
-
* Extracts custom attributes (non-HTTP, non-GenAI) from attributes.
|
|
57
|
-
* These are attributes that were added manually via updateActiveSpan.
|
|
58
|
-
*/
|
|
59
|
-
private extractCustomAttributes;
|
|
60
|
-
/**
|
|
61
|
-
* Called when a span ends. Filters the span and passes it to the underlying processor if eligible.
|
|
62
|
-
*
|
|
63
|
-
* This method:
|
|
64
|
-
* 1. Checks if the span is eligible (CLIENT + HTTP/GenAI attributes)
|
|
65
|
-
* 2. Applies domain filtering
|
|
66
|
-
* 3. If eligible, passes span to underlying OTLP processor for export
|
|
67
|
-
*/
|
|
68
|
-
onEnd(span: ReadableSpan): void;
|
|
69
|
-
/**
|
|
70
|
-
* Forces an immediate flush of all pending spans.
|
|
71
|
-
*
|
|
72
|
-
* @returns Promise that resolves when all pending operations are complete
|
|
73
|
-
*/
|
|
74
|
-
forceFlush(): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Gracefully shuts down the processor, ensuring all pending operations are completed.
|
|
77
|
-
*
|
|
78
|
-
* @returns Promise that resolves when shutdown is complete
|
|
79
|
-
*/
|
|
80
|
-
shutdown(): Promise<void>;
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=processor.d.ts.map
|
package/dist/processor.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processor.d.ts","sourceRoot":"","sources":["../src/processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAGvF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAOlD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAKvD;;;;;GAKG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACxD,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,MAAM,CAMZ;IAEF;;;;OAIG;gBACS,MAAM,EAAE,sBAAsB;IA8C1C;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI;IA0CjD;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAqB/B;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IA4E/B;;;;OAIG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAaxC;;;;OAIG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAYvC"}
|