@rootcat/node 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +213 -2
- package/dist/callsite.d.ts +109 -0
- package/dist/callsite.js +565 -0
- package/dist/callsite.js.map +1 -0
- package/dist/config.d.ts +75 -0
- package/dist/config.js +182 -0
- package/dist/config.js.map +1 -0
- package/dist/drizzle.d.ts +21 -0
- package/dist/drizzle.js +124 -0
- package/dist/drizzle.js.map +1 -0
- package/dist/esm.mjs +41 -0
- package/dist/esmhook.d.ts +12 -0
- package/dist/esmhook.js +84 -0
- package/dist/esmhook.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/intake.d.ts +40 -0
- package/dist/intake.js +164 -0
- package/dist/intake.js.map +1 -0
- package/dist/keys.d.ts +9 -0
- package/dist/keys.js +15 -0
- package/dist/keys.js.map +1 -0
- package/dist/notices.d.ts +2 -0
- package/dist/notices.js +21 -0
- package/dist/notices.js.map +1 -0
- package/dist/otlp.d.ts +75 -0
- package/dist/otlp.js +449 -0
- package/dist/otlp.js.map +1 -0
- package/dist/pg.d.ts +16 -0
- package/dist/pg.js +165 -0
- package/dist/pg.js.map +1 -0
- package/dist/pgpool.d.ts +13 -0
- package/dist/pgpool.js +85 -0
- package/dist/pgpool.js.map +1 -0
- package/dist/postgresjs.d.ts +33 -0
- package/dist/postgresjs.js +272 -0
- package/dist/postgresjs.js.map +1 -0
- package/dist/privacy.d.ts +38 -0
- package/dist/privacy.js +147 -0
- package/dist/privacy.js.map +1 -0
- package/dist/processor.d.ts +94 -0
- package/dist/processor.js +252 -0
- package/dist/processor.js.map +1 -0
- package/dist/register.d.ts +1 -0
- package/dist/register.js +12 -0
- package/dist/register.js.map +1 -0
- package/dist/sampler.d.ts +12 -0
- package/dist/sampler.js +52 -0
- package/dist/sampler.js.map +1 -0
- package/dist/sdk.d.ts +88 -0
- package/dist/sdk.js +305 -0
- package/dist/sdk.js.map +1 -0
- package/package.json +65 -4
package/dist/otlp.js
ADDED
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ProtobufExporter = exports.maxRequestBytes = exports.Writer = void 0;
|
|
37
|
+
exports.encodeTraces = encodeTraces;
|
|
38
|
+
exports.encodeWithin = encodeWithin;
|
|
39
|
+
// The exporter: OTLP/HTTP protobuf to the host agent, encoded here. The
|
|
40
|
+
// upstream exporter builds an intermediate object tree per span and then
|
|
41
|
+
// encodes it with a general protobuf library (about 13 µs per span on the
|
|
42
|
+
// benchmark machine); this writes the same ExportTraceServiceRequest
|
|
43
|
+
// straight from the SDK's ended spans into one buffer. Only the fields the
|
|
44
|
+
// agent reads and the SDK fills are written: resource and scope identity,
|
|
45
|
+
// ids, name, kind, times, attributes, events and status; links are not
|
|
46
|
+
// sent. Nested messages are written with a one-byte length placeholder
|
|
47
|
+
// that is widened in place when the message turns out longer.
|
|
48
|
+
//
|
|
49
|
+
// Field numbers are those of opentelemetry/proto/trace/v1/trace.proto,
|
|
50
|
+
// common/v1/common.proto and collector/trace/v1/trace_service.proto.
|
|
51
|
+
const http = __importStar(require("node:http"));
|
|
52
|
+
const https = __importStar(require("node:https"));
|
|
53
|
+
const core_1 = require("@opentelemetry/core");
|
|
54
|
+
const notices_js_1 = require("./notices.js");
|
|
55
|
+
const varintType = 0;
|
|
56
|
+
const fixed64Type = 1;
|
|
57
|
+
const lengthType = 2;
|
|
58
|
+
/** Writer appends protobuf fields to a growing buffer. */
|
|
59
|
+
class Writer {
|
|
60
|
+
buf;
|
|
61
|
+
pos = 0;
|
|
62
|
+
constructor(size = 64 * 1024) {
|
|
63
|
+
this.buf = Buffer.allocUnsafe(size);
|
|
64
|
+
}
|
|
65
|
+
ensure(n) {
|
|
66
|
+
if (this.pos + n <= this.buf.length) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
let size = this.buf.length * 2;
|
|
70
|
+
while (size < this.pos + n) {
|
|
71
|
+
size *= 2;
|
|
72
|
+
}
|
|
73
|
+
const next = Buffer.allocUnsafe(size);
|
|
74
|
+
this.buf.copy(next, 0, 0, this.pos);
|
|
75
|
+
this.buf = next;
|
|
76
|
+
}
|
|
77
|
+
varint(value) {
|
|
78
|
+
this.ensure(10);
|
|
79
|
+
let v = value;
|
|
80
|
+
while (v > 0x7f) {
|
|
81
|
+
this.buf[this.pos++] = (v % 128) | 0x80;
|
|
82
|
+
v = Math.floor(v / 128);
|
|
83
|
+
}
|
|
84
|
+
this.buf[this.pos++] = v;
|
|
85
|
+
}
|
|
86
|
+
tag(field, type) {
|
|
87
|
+
this.varint(field * 8 + type);
|
|
88
|
+
}
|
|
89
|
+
/** begin opens a length-delimited field and returns where its length goes. */
|
|
90
|
+
begin(field) {
|
|
91
|
+
this.tag(field, lengthType);
|
|
92
|
+
this.ensure(1);
|
|
93
|
+
const at = this.pos;
|
|
94
|
+
this.pos += 1;
|
|
95
|
+
return at;
|
|
96
|
+
}
|
|
97
|
+
/** end closes the field begin opened, widening its length when needed. */
|
|
98
|
+
end(at) {
|
|
99
|
+
const length = this.pos - at - 1;
|
|
100
|
+
const width = varintWidth(length);
|
|
101
|
+
if (width > 1) {
|
|
102
|
+
this.ensure(width - 1);
|
|
103
|
+
this.buf.copyWithin(at + width, at + 1, this.pos);
|
|
104
|
+
this.pos += width - 1;
|
|
105
|
+
}
|
|
106
|
+
let v = length;
|
|
107
|
+
let p = at;
|
|
108
|
+
while (v > 0x7f) {
|
|
109
|
+
this.buf[p++] = (v % 128) | 0x80;
|
|
110
|
+
v = Math.floor(v / 128);
|
|
111
|
+
}
|
|
112
|
+
this.buf[p] = v;
|
|
113
|
+
}
|
|
114
|
+
string(field, value) {
|
|
115
|
+
const at = this.begin(field);
|
|
116
|
+
this.ensure(value.length * 3);
|
|
117
|
+
this.pos += this.buf.write(value, this.pos, 'utf8');
|
|
118
|
+
this.end(at);
|
|
119
|
+
}
|
|
120
|
+
bytesHex(field, hex) {
|
|
121
|
+
this.tag(field, lengthType);
|
|
122
|
+
const n = hex.length >>> 1;
|
|
123
|
+
this.varint(n);
|
|
124
|
+
this.ensure(n);
|
|
125
|
+
this.pos += this.buf.write(hex, this.pos, 'hex');
|
|
126
|
+
}
|
|
127
|
+
fixed64Time(field, time) {
|
|
128
|
+
this.tag(field, fixed64Type);
|
|
129
|
+
this.ensure(8);
|
|
130
|
+
// nanoseconds since the epoch exceed 2^53: computed exactly
|
|
131
|
+
this.buf.writeBigUInt64LE(BigInt(time[0]) * 1000000000n + BigInt(time[1]), this.pos);
|
|
132
|
+
this.pos += 8;
|
|
133
|
+
}
|
|
134
|
+
double(field, value) {
|
|
135
|
+
this.tag(field, fixed64Type);
|
|
136
|
+
this.ensure(8);
|
|
137
|
+
this.buf.writeDoubleLE(value, this.pos);
|
|
138
|
+
this.pos += 8;
|
|
139
|
+
}
|
|
140
|
+
int64(field, value) {
|
|
141
|
+
this.tag(field, varintType);
|
|
142
|
+
if (value >= 0) {
|
|
143
|
+
this.varint(value);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
// A negative int64 is its two's complement, ten bytes.
|
|
147
|
+
this.ensure(10);
|
|
148
|
+
let v = BigInt.asUintN(64, BigInt(value));
|
|
149
|
+
while (v > 0x7fn) {
|
|
150
|
+
this.buf[this.pos++] = Number(v & 0x7fn) | 0x80;
|
|
151
|
+
v >>= 7n;
|
|
152
|
+
}
|
|
153
|
+
this.buf[this.pos++] = Number(v);
|
|
154
|
+
}
|
|
155
|
+
/** finish returns the bytes written (a view of the buffer). */
|
|
156
|
+
finish() {
|
|
157
|
+
return this.buf.subarray(0, this.pos);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.Writer = Writer;
|
|
161
|
+
function varintWidth(value) {
|
|
162
|
+
let width = 1;
|
|
163
|
+
let v = value;
|
|
164
|
+
while (v > 0x7f) {
|
|
165
|
+
v = Math.floor(v / 128);
|
|
166
|
+
width++;
|
|
167
|
+
}
|
|
168
|
+
return width;
|
|
169
|
+
}
|
|
170
|
+
/** writeAnyValue writes an AnyValue for an attribute value. */
|
|
171
|
+
function writeAnyValue(w, field, value) {
|
|
172
|
+
const at = w.begin(field);
|
|
173
|
+
if (typeof value === 'string') {
|
|
174
|
+
w.string(1, value);
|
|
175
|
+
}
|
|
176
|
+
else if (typeof value === 'boolean') {
|
|
177
|
+
w.tag(2, varintType);
|
|
178
|
+
w.varint(value ? 1 : 0);
|
|
179
|
+
}
|
|
180
|
+
else if (typeof value === 'number') {
|
|
181
|
+
if (Number.isSafeInteger(value)) {
|
|
182
|
+
w.int64(3, value);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
w.double(4, value);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else if (Array.isArray(value)) {
|
|
189
|
+
const array = w.begin(5);
|
|
190
|
+
for (const item of value) {
|
|
191
|
+
if (item !== null && item !== undefined) {
|
|
192
|
+
writeAnyValue(w, 1, item);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
w.end(array);
|
|
196
|
+
}
|
|
197
|
+
w.end(at);
|
|
198
|
+
}
|
|
199
|
+
function writeAttributes(w, field, attributes) {
|
|
200
|
+
for (const key in attributes) {
|
|
201
|
+
const value = attributes[key];
|
|
202
|
+
if (value === undefined || value === null) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const at = w.begin(field);
|
|
206
|
+
w.string(1, key);
|
|
207
|
+
writeAnyValue(w, 2, value);
|
|
208
|
+
w.end(at);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function writeSpan(w, span) {
|
|
212
|
+
const at = w.begin(2); // ScopeSpans.spans
|
|
213
|
+
const context = span.spanContext();
|
|
214
|
+
w.bytesHex(1, context.traceId);
|
|
215
|
+
w.bytesHex(2, context.spanId);
|
|
216
|
+
const traceState = context.traceState?.serialize();
|
|
217
|
+
if (traceState) {
|
|
218
|
+
w.string(3, traceState);
|
|
219
|
+
}
|
|
220
|
+
const parent = span.parentSpanContext;
|
|
221
|
+
if (parent && parent.spanId) {
|
|
222
|
+
w.bytesHex(4, parent.spanId);
|
|
223
|
+
}
|
|
224
|
+
w.string(5, span.name);
|
|
225
|
+
w.tag(6, varintType);
|
|
226
|
+
w.varint(span.kind + 1); // the API counts from INTERNAL = 0, OTLP from 1
|
|
227
|
+
w.fixed64Time(7, span.startTime);
|
|
228
|
+
w.fixed64Time(8, span.endTime);
|
|
229
|
+
writeAttributes(w, 9, span.attributes);
|
|
230
|
+
if (span.droppedAttributesCount > 0) {
|
|
231
|
+
w.tag(10, varintType);
|
|
232
|
+
w.varint(span.droppedAttributesCount);
|
|
233
|
+
}
|
|
234
|
+
for (const event of span.events) {
|
|
235
|
+
const e = w.begin(11);
|
|
236
|
+
w.fixed64Time(1, event.time);
|
|
237
|
+
w.string(2, event.name);
|
|
238
|
+
if (event.attributes) {
|
|
239
|
+
writeAttributes(w, 3, event.attributes);
|
|
240
|
+
}
|
|
241
|
+
w.end(e);
|
|
242
|
+
}
|
|
243
|
+
if (span.droppedEventsCount > 0) {
|
|
244
|
+
w.tag(12, varintType);
|
|
245
|
+
w.varint(span.droppedEventsCount);
|
|
246
|
+
}
|
|
247
|
+
if (span.status.code !== 0 || span.status.message) {
|
|
248
|
+
const s = w.begin(15);
|
|
249
|
+
if (span.status.message) {
|
|
250
|
+
w.string(2, span.status.message);
|
|
251
|
+
}
|
|
252
|
+
if (span.status.code !== 0) {
|
|
253
|
+
w.tag(3, varintType);
|
|
254
|
+
w.varint(span.status.code);
|
|
255
|
+
}
|
|
256
|
+
w.end(s);
|
|
257
|
+
}
|
|
258
|
+
w.end(at);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* encodeTraces writes one ExportTraceServiceRequest for spans that share a
|
|
262
|
+
* resource (the SDK's one resource), grouped by instrumentation scope.
|
|
263
|
+
*/
|
|
264
|
+
function encodeTraces(spans, w = new Writer()) {
|
|
265
|
+
if (spans.length === 0) {
|
|
266
|
+
return Buffer.alloc(0);
|
|
267
|
+
}
|
|
268
|
+
const byScope = new Map();
|
|
269
|
+
for (const span of spans) {
|
|
270
|
+
const scope = span.instrumentationScope;
|
|
271
|
+
const key = scope.name + '\0' + (scope.version ?? '');
|
|
272
|
+
let group = byScope.get(key);
|
|
273
|
+
if (!group) {
|
|
274
|
+
group = { name: scope.name, version: scope.version, spans: [] };
|
|
275
|
+
byScope.set(key, group);
|
|
276
|
+
}
|
|
277
|
+
group.spans.push(span);
|
|
278
|
+
}
|
|
279
|
+
const resourceSpans = w.begin(1);
|
|
280
|
+
const resource = w.begin(1);
|
|
281
|
+
writeAttributes(w, 1, spans[0].resource.attributes);
|
|
282
|
+
w.end(resource);
|
|
283
|
+
for (const group of byScope.values()) {
|
|
284
|
+
const scopeSpans = w.begin(2);
|
|
285
|
+
const scope = w.begin(1);
|
|
286
|
+
w.string(1, group.name);
|
|
287
|
+
if (group.version) {
|
|
288
|
+
w.string(2, group.version);
|
|
289
|
+
}
|
|
290
|
+
w.end(scope);
|
|
291
|
+
for (const span of group.spans) {
|
|
292
|
+
writeSpan(w, span);
|
|
293
|
+
}
|
|
294
|
+
w.end(scopeSpans);
|
|
295
|
+
}
|
|
296
|
+
w.end(resourceSpans);
|
|
297
|
+
return w.finish();
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* maxRequestBytes keeps every request under the agent's 1 MiB intake
|
|
301
|
+
* bound, with room for the transport's own framing.
|
|
302
|
+
*/
|
|
303
|
+
exports.maxRequestBytes = 900 * 1024;
|
|
304
|
+
/**
|
|
305
|
+
* encodeWithin encodes spans into requests of at most limit bytes,
|
|
306
|
+
* halving a batch until each part fits. A single span that does not fit
|
|
307
|
+
* on its own (which the span limits make all but impossible) is dropped,
|
|
308
|
+
* and counted in dropped.
|
|
309
|
+
*/
|
|
310
|
+
function encodeWithin(spans, limit = exports.maxRequestBytes) {
|
|
311
|
+
const bodies = [];
|
|
312
|
+
let dropped = 0;
|
|
313
|
+
const pending = [spans];
|
|
314
|
+
while (pending.length > 0) {
|
|
315
|
+
const part = pending.shift();
|
|
316
|
+
if (part.length === 0) {
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
const body = encodeTraces(part);
|
|
320
|
+
if (body.length <= limit) {
|
|
321
|
+
bodies.push(body);
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (part.length === 1) {
|
|
325
|
+
dropped++;
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
const half = Math.ceil(part.length / 2);
|
|
329
|
+
pending.unshift(part.slice(0, half), part.slice(half));
|
|
330
|
+
}
|
|
331
|
+
return { bodies, dropped };
|
|
332
|
+
}
|
|
333
|
+
/** maxResponseBytes bounds what is read of the intake's answer. */
|
|
334
|
+
const maxResponseBytes = 64 * 1024;
|
|
335
|
+
/**
|
|
336
|
+
* ProtobufExporter posts encoded batches to the intake, split into
|
|
337
|
+
* requests under maxRequestBytes and sent one after another. A batch that
|
|
338
|
+
* cannot be sent (the intake is down, slow past the timeout, answers an
|
|
339
|
+
* error, or two exports are already in flight) is dropped and reported as
|
|
340
|
+
* failed to the batch processor; nothing is retried. A request the intake
|
|
341
|
+
* refuses as too large (413) is said once on stderr.
|
|
342
|
+
*/
|
|
343
|
+
class ProtobufExporter {
|
|
344
|
+
url;
|
|
345
|
+
agent;
|
|
346
|
+
timeoutMillis;
|
|
347
|
+
concurrency;
|
|
348
|
+
maxRequestBytes;
|
|
349
|
+
inFlight = 0;
|
|
350
|
+
stopped = false;
|
|
351
|
+
constructor(options) {
|
|
352
|
+
this.url = new URL(options.url);
|
|
353
|
+
this.timeoutMillis = options.timeoutMillis;
|
|
354
|
+
this.concurrency = options.concurrency;
|
|
355
|
+
this.maxRequestBytes = options.maxRequestBytes ?? exports.maxRequestBytes;
|
|
356
|
+
const Agent = this.url.protocol === 'https:' ? https.Agent : http.Agent;
|
|
357
|
+
this.agent = new Agent({ keepAlive: true, maxSockets: options.concurrency });
|
|
358
|
+
}
|
|
359
|
+
export(spans, done) {
|
|
360
|
+
if (this.stopped || spans.length === 0) {
|
|
361
|
+
done({ code: this.stopped ? core_1.ExportResultCode.FAILED : core_1.ExportResultCode.SUCCESS });
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
if (this.inFlight >= this.concurrency) {
|
|
365
|
+
done({ code: core_1.ExportResultCode.FAILED, error: new Error('too many exports in flight') });
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
let bodies;
|
|
369
|
+
try {
|
|
370
|
+
const encoded = encodeWithin(spans, this.maxRequestBytes);
|
|
371
|
+
bodies = encoded.bodies;
|
|
372
|
+
if (encoded.dropped > 0) {
|
|
373
|
+
(0, notices_js_1.sayOnce)('span-too-large', 'a span larger than the intake accepts was dropped');
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
done({ code: core_1.ExportResultCode.FAILED, error: error });
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
this.inFlight++;
|
|
381
|
+
const sendAll = async () => {
|
|
382
|
+
for (const body of bodies) {
|
|
383
|
+
await this.post(body);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
sendAll().then(() => {
|
|
387
|
+
this.inFlight--;
|
|
388
|
+
done({ code: core_1.ExportResultCode.SUCCESS });
|
|
389
|
+
}, (error) => {
|
|
390
|
+
this.inFlight--;
|
|
391
|
+
done({ code: core_1.ExportResultCode.FAILED, error });
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
/** post sends one request and settles with its outcome. */
|
|
395
|
+
post(body) {
|
|
396
|
+
return new Promise((resolve, reject) => {
|
|
397
|
+
const send = this.url.protocol === 'https:' ? https.request : http.request;
|
|
398
|
+
let settled = false;
|
|
399
|
+
const finish = (error) => {
|
|
400
|
+
if (settled) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
settled = true;
|
|
404
|
+
if (error) {
|
|
405
|
+
reject(error);
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
resolve();
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
const request = send(this.url, { method: 'POST', agent: this.agent, timeout: this.timeoutMillis, headers: { 'content-type': 'application/x-protobuf', 'content-length': body.length } }, (response) => {
|
|
412
|
+
let read = 0;
|
|
413
|
+
response.on('data', (chunk) => {
|
|
414
|
+
read += chunk.length;
|
|
415
|
+
if (read > maxResponseBytes) {
|
|
416
|
+
response.destroy();
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
response.on('end', () => {
|
|
420
|
+
const status = response.statusCode ?? 0;
|
|
421
|
+
if (status === 413) {
|
|
422
|
+
(0, notices_js_1.sayOnce)('intake-413', `the intake refused a request of ${body.length} bytes as too large (HTTP 413); its spans were dropped`);
|
|
423
|
+
}
|
|
424
|
+
finish(status >= 200 && status < 300 ? undefined : new Error(`intake answered ${status}`));
|
|
425
|
+
});
|
|
426
|
+
response.on('error', (error) => finish(error));
|
|
427
|
+
});
|
|
428
|
+
const timer = setTimeout(() => request.destroy(new Error('export timed out')), this.timeoutMillis);
|
|
429
|
+
timer.unref();
|
|
430
|
+
request.on('timeout', () => request.destroy(new Error('export timed out')));
|
|
431
|
+
request.on('error', (error) => finish(error));
|
|
432
|
+
request.on('close', () => {
|
|
433
|
+
clearTimeout(timer);
|
|
434
|
+
finish(new Error('connection closed'));
|
|
435
|
+
});
|
|
436
|
+
request.end(body);
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
shutdown() {
|
|
440
|
+
this.stopped = true;
|
|
441
|
+
this.agent.destroy();
|
|
442
|
+
return Promise.resolve();
|
|
443
|
+
}
|
|
444
|
+
forceFlush() {
|
|
445
|
+
return Promise.resolve();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
exports.ProtobufExporter = ProtobufExporter;
|
|
449
|
+
//# sourceMappingURL=otlp.js.map
|
package/dist/otlp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp.js","sourceRoot":"","sources":["../src/otlp.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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C;QACpB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,UAAU;QACR,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AAlHD,4CAkHC"}
|
package/dist/pg.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InstrumentationBase, type InstrumentationConfig, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { type CallSiteSampling } from './processor.js';
|
|
3
|
+
/** PgOptions configures the instrumentation. */
|
|
4
|
+
export interface PgOptions extends InstrumentationConfig {
|
|
5
|
+
/** sampling gates the call-site capture made where the app calls client.query. */
|
|
6
|
+
sampling: CallSiteSampling;
|
|
7
|
+
depth: number;
|
|
8
|
+
isApp?: (file: string) => boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class PgInstrumentation extends InstrumentationBase<PgOptions> {
|
|
11
|
+
constructor(options: PgOptions);
|
|
12
|
+
protected init(): InstrumentationNodeModuleDefinition;
|
|
13
|
+
private readonly wrapQuery;
|
|
14
|
+
private startQuerySpan;
|
|
15
|
+
private endQuerySpan;
|
|
16
|
+
}
|
package/dist/pg.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PgInstrumentation = void 0;
|
|
4
|
+
// pg (node-postgres): one span per query, nothing else. The upstream
|
|
5
|
+
// instrumentation starts a span for every pool acquire beside the query,
|
|
6
|
+
// another per connection, records metrics and a dozen attributes, and
|
|
7
|
+
// costs about three times what the query span itself does (see the
|
|
8
|
+
// benchmark); the agent counts operations and keeps error events, so
|
|
9
|
+
// one client span with the statement, the database and the server is
|
|
10
|
+
// what it needs. Client.prototype.query is patched (pool.query goes
|
|
11
|
+
// through it); a submittable (a cursor or a stream) passes through
|
|
12
|
+
// untraced; parameter values are never read.
|
|
13
|
+
const api_1 = require("@opentelemetry/api");
|
|
14
|
+
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
15
|
+
const callsite_js_1 = require("./callsite.js");
|
|
16
|
+
const privacy_js_1 = require("./privacy.js");
|
|
17
|
+
const processor_js_1 = require("./processor.js");
|
|
18
|
+
const maxStatementBytes = 4096;
|
|
19
|
+
const supportedVersions = ['>=8.0.0 <9'];
|
|
20
|
+
class PgInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
21
|
+
constructor(options) {
|
|
22
|
+
super('@rootcat/node/pg', '0.1.0', options);
|
|
23
|
+
}
|
|
24
|
+
init() {
|
|
25
|
+
return new instrumentation_1.InstrumentationNodeModuleDefinition('pg', supportedVersions, (moduleExports) => {
|
|
26
|
+
const proto = clientPrototype(moduleExports);
|
|
27
|
+
if (proto) {
|
|
28
|
+
if ((0, instrumentation_1.isWrapped)(proto.query)) {
|
|
29
|
+
this._unwrap(proto, 'query');
|
|
30
|
+
}
|
|
31
|
+
this._wrap(proto, 'query', this.wrapQuery);
|
|
32
|
+
}
|
|
33
|
+
return moduleExports;
|
|
34
|
+
}, (moduleExports) => {
|
|
35
|
+
const proto = clientPrototype(moduleExports);
|
|
36
|
+
if (proto && (0, instrumentation_1.isWrapped)(proto.query)) {
|
|
37
|
+
this._unwrap(proto, 'query');
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
wrapQuery = (original) => {
|
|
42
|
+
const instrumentation = this;
|
|
43
|
+
return function query(...args) {
|
|
44
|
+
const [config, values, callback] = args;
|
|
45
|
+
if (config && typeof config.submit === 'function') {
|
|
46
|
+
return original.apply(this, args); // a cursor or a stream: not a query with an end
|
|
47
|
+
}
|
|
48
|
+
const outer = api_1.context.active();
|
|
49
|
+
let span;
|
|
50
|
+
let parent = outer;
|
|
51
|
+
try {
|
|
52
|
+
const options = instrumentation.getConfig();
|
|
53
|
+
parent = options.sampling.carry(() => (0, callsite_js_1.captureCallSite)(options.depth, options.isApp, query)) ?? outer;
|
|
54
|
+
if ((0, processor_js_1.unsampled)(parent)) {
|
|
55
|
+
return original.apply(this, args); // not recorded: nothing to start or carry
|
|
56
|
+
}
|
|
57
|
+
span = instrumentation.startQuerySpan(this, config, parent);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
span = undefined;
|
|
61
|
+
}
|
|
62
|
+
if (!span) {
|
|
63
|
+
return original.apply(this, args);
|
|
64
|
+
}
|
|
65
|
+
const end = instrumentation.endQuerySpan.bind(instrumentation, span);
|
|
66
|
+
// The callback may be the second or third argument, or on the config.
|
|
67
|
+
// It continues in the caller's context, not the query's.
|
|
68
|
+
let callArgs = args;
|
|
69
|
+
const userCallback = typeof values === 'function' ? values : typeof callback === 'function' ? callback : config?.callback;
|
|
70
|
+
if (typeof userCallback === 'function') {
|
|
71
|
+
const wrapped = api_1.context.bind(outer, function (error, result) {
|
|
72
|
+
end(error);
|
|
73
|
+
return userCallback.call(this, error, result);
|
|
74
|
+
});
|
|
75
|
+
if (typeof values === 'function') {
|
|
76
|
+
callArgs = [config, wrapped];
|
|
77
|
+
}
|
|
78
|
+
else if (typeof callback === 'function') {
|
|
79
|
+
callArgs = [config, values, wrapped];
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// A config may be a class instance whose text or values are
|
|
83
|
+
// getters on its prototype: the callback goes on an object that
|
|
84
|
+
// inherits from it, not on a copy of its own fields.
|
|
85
|
+
const withCallback = Object.create(config);
|
|
86
|
+
withCallback.callback = wrapped;
|
|
87
|
+
callArgs = [withCallback, values, callback];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const active = api_1.trace.setSpan(parent, span);
|
|
91
|
+
let result;
|
|
92
|
+
try {
|
|
93
|
+
result = api_1.context.with(active, () => original.apply(this, callArgs));
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
end(error);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
if (typeof userCallback !== 'function') {
|
|
100
|
+
if (result && typeof result.then === 'function') {
|
|
101
|
+
result.then(() => end(undefined), (error) => end(error ?? new Error('query failed')));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
end(undefined);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
startQuerySpan(client, config, parent) {
|
|
111
|
+
const text = typeof config === 'string' ? config : typeof config?.text === 'string' ? config.text : '';
|
|
112
|
+
const keyword = (0, privacy_js_1.statementKeyword)(text);
|
|
113
|
+
const attributes = { 'db.system.name': 'postgresql' };
|
|
114
|
+
if (keyword !== '') {
|
|
115
|
+
attributes['db.operation.name'] = keyword;
|
|
116
|
+
}
|
|
117
|
+
if (text !== '') {
|
|
118
|
+
// Literals are masked (or the text reduced to its keyword) by the
|
|
119
|
+
// processor's statement rule as the span starts.
|
|
120
|
+
attributes['db.query.text'] = text.slice(0, maxStatementBytes);
|
|
121
|
+
}
|
|
122
|
+
if (typeof client.database === 'string') {
|
|
123
|
+
attributes['db.namespace'] = client.database;
|
|
124
|
+
}
|
|
125
|
+
if (typeof client.host === 'string') {
|
|
126
|
+
attributes['server.address'] = client.host;
|
|
127
|
+
}
|
|
128
|
+
if (typeof client.port === 'number') {
|
|
129
|
+
attributes['server.port'] = client.port;
|
|
130
|
+
}
|
|
131
|
+
return this.tracer.startSpan(keyword === '' ? 'pg.query' : `pg.query:${keyword}`, { kind: api_1.SpanKind.CLIENT, attributes }, parent);
|
|
132
|
+
}
|
|
133
|
+
endQuerySpan(span, error) {
|
|
134
|
+
try {
|
|
135
|
+
if (error !== undefined && error !== null) {
|
|
136
|
+
// The server's message can quote the input that failed; only the
|
|
137
|
+
// error's class and SQLSTATE travel.
|
|
138
|
+
const e = error;
|
|
139
|
+
const generic = typeof e.name !== 'string' || e.name === '' || e.name === 'Error' || e.name === 'error';
|
|
140
|
+
const name = (generic ? e.constructor?.name : e.name) || 'Error';
|
|
141
|
+
const code = typeof e.code === 'string' ? e.code.slice(0, 16) : '';
|
|
142
|
+
const message = code === '' ? `${name} from pg` : `${name} from pg (code: ${code})`;
|
|
143
|
+
span.setStatus({ code: api_1.SpanStatusCode.ERROR, message });
|
|
144
|
+
span.addEvent('exception', { 'exception.type': name.slice(0, 64), 'exception.message': message });
|
|
145
|
+
span.setAttribute('error.type', name.slice(0, 64));
|
|
146
|
+
if (code !== '') {
|
|
147
|
+
span.setAttribute('db.response.status_code', code);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// the span still ends
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
span.end();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.PgInstrumentation = PgInstrumentation;
|
|
160
|
+
function clientPrototype(moduleExports) {
|
|
161
|
+
const mod = moduleExports;
|
|
162
|
+
const proto = mod?.Client?.prototype;
|
|
163
|
+
return proto && typeof proto.query === 'function' ? proto : undefined;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=pg.js.map
|
package/dist/pg.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pg.js","sourceRoot":"","sources":["../src/pg.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,yEAAyE;AACzE,sEAAsE;AACtE,mEAAmE;AACnE,qEAAqE;AACrE,qEAAqE;AACrE,oEAAoE;AACpE,mEAAmE;AACnE,6CAA6C;AAC7C,4CAAwH;AACxH,oEAAiJ;AACjJ,+CAAgD;AAChD,6CAAgD;AAChD,iDAAkE;AAUlE,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,iBAAiB,GAAG,CAAC,YAAY,CAAC,CAAC;AAiBzC,MAAa,iBAAkB,SAAQ,qCAA8B;IACnE,YAAY,OAAkB;QAC5B,KAAK,CAAC,kBAAkB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9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