@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.
Files changed (55) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +213 -2
  3. package/dist/callsite.d.ts +109 -0
  4. package/dist/callsite.js +565 -0
  5. package/dist/callsite.js.map +1 -0
  6. package/dist/config.d.ts +75 -0
  7. package/dist/config.js +182 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/drizzle.d.ts +21 -0
  10. package/dist/drizzle.js +124 -0
  11. package/dist/drizzle.js.map +1 -0
  12. package/dist/esm.mjs +41 -0
  13. package/dist/esmhook.d.ts +12 -0
  14. package/dist/esmhook.js +84 -0
  15. package/dist/esmhook.js.map +1 -0
  16. package/dist/index.d.ts +12 -0
  17. package/dist/index.js +50 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/intake.d.ts +40 -0
  20. package/dist/intake.js +164 -0
  21. package/dist/intake.js.map +1 -0
  22. package/dist/keys.d.ts +9 -0
  23. package/dist/keys.js +15 -0
  24. package/dist/keys.js.map +1 -0
  25. package/dist/notices.d.ts +2 -0
  26. package/dist/notices.js +21 -0
  27. package/dist/notices.js.map +1 -0
  28. package/dist/otlp.d.ts +75 -0
  29. package/dist/otlp.js +449 -0
  30. package/dist/otlp.js.map +1 -0
  31. package/dist/pg.d.ts +16 -0
  32. package/dist/pg.js +165 -0
  33. package/dist/pg.js.map +1 -0
  34. package/dist/pgpool.d.ts +13 -0
  35. package/dist/pgpool.js +85 -0
  36. package/dist/pgpool.js.map +1 -0
  37. package/dist/postgresjs.d.ts +33 -0
  38. package/dist/postgresjs.js +272 -0
  39. package/dist/postgresjs.js.map +1 -0
  40. package/dist/privacy.d.ts +38 -0
  41. package/dist/privacy.js +147 -0
  42. package/dist/privacy.js.map +1 -0
  43. package/dist/processor.d.ts +94 -0
  44. package/dist/processor.js +252 -0
  45. package/dist/processor.js.map +1 -0
  46. package/dist/register.d.ts +1 -0
  47. package/dist/register.js +12 -0
  48. package/dist/register.js.map +1 -0
  49. package/dist/sampler.d.ts +12 -0
  50. package/dist/sampler.js +52 -0
  51. package/dist/sampler.js.map +1 -0
  52. package/dist/sdk.d.ts +88 -0
  53. package/dist/sdk.js +305 -0
  54. package/dist/sdk.js.map +1 -0
  55. package/package.json +65 -4
package/dist/intake.js ADDED
@@ -0,0 +1,164 @@
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.procFiles = void 0;
37
+ exports.defaultGateway = defaultGateway;
38
+ exports.inContainer = inContainer;
39
+ exports.hostNetwork = hostNetwork;
40
+ exports.privateAddress = privateAddress;
41
+ exports.discoverIntake = discoverIntake;
42
+ // Intake discovery: where the host agent's OTLP listener is from where the
43
+ // process runs. Inside a container the agent listens on the IPv4 address
44
+ // of the container's bridge, which is the container's default gateway; on
45
+ // the host it listens on loopback. Both come from /proc, read once,
46
+ // bounded.
47
+ const fs = __importStar(require("node:fs"));
48
+ const config_js_1 = require("./config.js");
49
+ /** Bounds on the /proc reads. */
50
+ const maxRouteBytes = 64 * 1024;
51
+ const maxCgroupBytes = 16 * 1024;
52
+ /** procFiles reads the real /proc, /sys and root. */
53
+ exports.procFiles = {
54
+ exists(file) {
55
+ try {
56
+ return fs.existsSync(file);
57
+ }
58
+ catch {
59
+ return false;
60
+ }
61
+ },
62
+ list(dir) {
63
+ try {
64
+ return fs.readdirSync(dir).slice(0, 4096);
65
+ }
66
+ catch {
67
+ return [];
68
+ }
69
+ },
70
+ read(file, maxBytes) {
71
+ let fd;
72
+ try {
73
+ fd = fs.openSync(file, 'r');
74
+ const buffer = Buffer.alloc(maxBytes);
75
+ const n = fs.readSync(fd, buffer, 0, maxBytes, 0);
76
+ return buffer.toString('utf8', 0, n);
77
+ }
78
+ catch {
79
+ return undefined;
80
+ }
81
+ finally {
82
+ if (fd !== undefined) {
83
+ fs.closeSync(fd);
84
+ }
85
+ }
86
+ },
87
+ };
88
+ /**
89
+ * defaultGateway parses /proc/net/route and returns the IPv4 gateway of
90
+ * the default route (destination 0.0.0.0 with the gateway flag set), or
91
+ * undefined when there is none.
92
+ */
93
+ function defaultGateway(routeTable) {
94
+ const lines = routeTable.split('\n');
95
+ for (const line of lines.slice(1)) {
96
+ const fields = line.trim().split(/\s+/);
97
+ if (fields.length < 4) {
98
+ continue;
99
+ }
100
+ const [, destination, gateway, flags] = fields;
101
+ if (destination !== '00000000' || !/^[0-9a-fA-F]{8}$/.test(gateway)) {
102
+ continue;
103
+ }
104
+ const flagBits = Number.parseInt(flags, 16);
105
+ if (Number.isNaN(flagBits) || (flagBits & 0x2) === 0) {
106
+ continue; // RTF_GATEWAY not set
107
+ }
108
+ const value = Number.parseInt(gateway, 16);
109
+ if (value === 0) {
110
+ continue;
111
+ }
112
+ // The kernel writes the address in host byte order, little-endian on
113
+ // every platform Rootcat runs on.
114
+ const address = [value & 0xff, (value >>> 8) & 0xff, (value >>> 16) & 0xff, (value >>> 24) & 0xff].join('.');
115
+ return address;
116
+ }
117
+ return undefined;
118
+ }
119
+ /**
120
+ * inContainer reports whether the process runs in a container: Docker's
121
+ * /.dockerenv, podman's /run/.containerenv, or a cgroup path naming a
122
+ * container runtime.
123
+ */
124
+ function inContainer(files) {
125
+ if (files.exists('/.dockerenv') || files.exists('/run/.containerenv')) {
126
+ return true;
127
+ }
128
+ const cgroup = files.read('/proc/1/cgroup', maxCgroupBytes) ?? '';
129
+ return /\/(docker|containerd|kubepods|libpod|lxc|podman)[/-]/.test(cgroup) || /:\/docker\//.test(cgroup);
130
+ }
131
+ /**
132
+ * hostNetwork reports whether the process sees the host's own network:
133
+ * a Docker bridge (docker0, docker_gwbridge, br-*) among the interfaces
134
+ * in /sys/class/net, which in a container's own network namespace lists
135
+ * only that namespace's interfaces. A container started with
136
+ * network_mode: host has /.dockerenv and the host's routing table, whose
137
+ * default gateway is the LAN's or the provider's router.
138
+ */
139
+ function hostNetwork(files) {
140
+ return files.list('/sys/class/net').some((name) => name === 'docker0' || name === 'docker_gwbridge' || name.startsWith('br-'));
141
+ }
142
+ /** privateAddress reports whether an IPv4 address is in a private or shared range. */
143
+ function privateAddress(address) {
144
+ const [a, b] = address.split('.').map(Number);
145
+ return a === 10 || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168) || (a === 100 && b >= 64 && b <= 127);
146
+ }
147
+ /**
148
+ * discoverIntake returns the agent intake's origin: the default gateway
149
+ * inside a container on a bridge (the bridge address the agent listens
150
+ * on), else loopback. A container on the host's network, or a gateway
151
+ * outside the private ranges, gets loopback: spans are never sent off
152
+ * the host by discovery.
153
+ */
154
+ function discoverIntake(files = exports.procFiles) {
155
+ if (inContainer(files) && !hostNetwork(files)) {
156
+ const route = files.read('/proc/net/route', maxRouteBytes);
157
+ const gateway = route ? defaultGateway(route) : undefined;
158
+ if (gateway && privateAddress(gateway)) {
159
+ return `http://${gateway}:${config_js_1.otlpPort}`;
160
+ }
161
+ }
162
+ return `http://127.0.0.1:${config_js_1.otlpPort}`;
163
+ }
164
+ //# sourceMappingURL=intake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intake.js","sourceRoot":"","sources":["../src/intake.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,wCAyBC;AAOD,kCAMC;AAUD,kCAEC;AAGD,wCAGC;AASD,wCASC;AApID,2EAA2E;AAC3E,yEAAyE;AACzE,0EAA0E;AAC1E,oEAAoE;AACpE,WAAW;AACX,4CAA8B;AAC9B,2CAAuC;AAEvC,iCAAiC;AACjC,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,CAAC;AAChC,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC;AAUjC,qDAAqD;AACxC,QAAA,SAAS,GAAU;IAC9B,MAAM,CAAC,IAAI;QACT,IAAI,CAAC;YACH,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,IAAI,CAAC,GAAG;QACN,IAAI,CAAC;YACH,OAAO,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAC5C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IACD,IAAI,CAAC,IAAI,EAAE,QAAQ;QACjB,IAAI,EAAsB,CAAC;QAC3B,IAAI,CAAC;YACH,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAC5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AG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9C,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;AACzH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,QAAe,iBAAS;IACrD,IAAI,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1D,IAAI,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;YACvC,OAAO,UAAU,OAAO,IAAI,oBAAQ,EAAE,CAAC;QACzC,CAAC;IACH,CAAC;IACD,OAAO,oBAAoB,oBAAQ,EAAE,CAAC;AACxC,CAAC"}
package/dist/keys.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /** callSiteContextKey carries a call site through the active context. */
2
+ export declare const callSiteContextKey: symbol;
3
+ /**
4
+ * rootDecisionKey carries a trace decision an entry wrapper made for an
5
+ * operation outside any span, so the span the driver starts later is
6
+ * sampled as the wrapper decided (and the wrapper captured, or not, to
7
+ * match).
8
+ */
9
+ export declare const rootDecisionKey: symbol;
package/dist/keys.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rootDecisionKey = exports.callSiteContextKey = void 0;
4
+ // Context keys shared by the processor, the sampler and the entry wrappers.
5
+ const api_1 = require("@opentelemetry/api");
6
+ /** callSiteContextKey carries a call site through the active context. */
7
+ exports.callSiteContextKey = (0, api_1.createContextKey)('rootcat.callsite');
8
+ /**
9
+ * rootDecisionKey carries a trace decision an entry wrapper made for an
10
+ * operation outside any span, so the span the driver starts later is
11
+ * sampled as the wrapper decided (and the wrapper captured, or not, to
12
+ * match).
13
+ */
14
+ exports.rootDecisionKey = (0, api_1.createContextKey)('rootcat.root-decision');
15
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";;;AAAA,4EAA4E;AAC5E,4CAAsD;AAEtD,yEAAyE;AAC5D,QAAA,kBAAkB,GAAG,IAAA,sBAAgB,EAAC,kBAAkB,CAAC,CAAC;AAEvE;;;;;GAKG;AACU,QAAA,eAAe,GAAG,IAAA,sBAAgB,EAAC,uBAAuB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ /** sayOnce writes a line to stderr the first time key is seen. */
2
+ export declare function sayOnce(key: string, message: string): void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sayOnce = sayOnce;
4
+ // Notices the package prints on stderr, each at most once per process:
5
+ // the exporter's and the SDK's failures never reach the application, but
6
+ // an operator should learn once that spans are being lost, and why.
7
+ const said = new Set();
8
+ /** sayOnce writes a line to stderr the first time key is seen. */
9
+ function sayOnce(key, message) {
10
+ if (said.has(key)) {
11
+ return;
12
+ }
13
+ said.add(key);
14
+ try {
15
+ process.stderr.write(`rootcat: ${message}; this is said once\n`);
16
+ }
17
+ catch {
18
+ // stderr closed: nothing to do
19
+ }
20
+ }
21
+ //# sourceMappingURL=notices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notices.js","sourceRoot":"","sources":["../src/notices.ts"],"names":[],"mappings":";;AAMA,0BAUC;AAhBD,uEAAuE;AACvE,yEAAyE;AACzE,oEAAoE;AACpE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;AAE/B,kEAAkE;AAClE,SAAgB,OAAO,CAAC,GAAW,EAAE,OAAe;IAClD,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAClB,OAAO;IACT,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACd,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,OAAO,uBAAuB,CAAC,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACP,+BAA+B;IACjC,CAAC;AACH,CAAC"}
package/dist/otlp.d.ts ADDED
@@ -0,0 +1,75 @@
1
+ import type { HrTime } from '@opentelemetry/api';
2
+ import { type ExportResult } from '@opentelemetry/core';
3
+ import type { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base';
4
+ /** Writer appends protobuf fields to a growing buffer. */
5
+ export declare class Writer {
6
+ buf: Buffer;
7
+ pos: number;
8
+ constructor(size?: number);
9
+ private ensure;
10
+ varint(value: number): void;
11
+ tag(field: number, type: number): void;
12
+ /** begin opens a length-delimited field and returns where its length goes. */
13
+ begin(field: number): number;
14
+ /** end closes the field begin opened, widening its length when needed. */
15
+ end(at: number): void;
16
+ string(field: number, value: string): void;
17
+ bytesHex(field: number, hex: string): void;
18
+ fixed64Time(field: number, time: HrTime): void;
19
+ double(field: number, value: number): void;
20
+ int64(field: number, value: number): void;
21
+ /** finish returns the bytes written (a view of the buffer). */
22
+ finish(): Buffer;
23
+ }
24
+ /**
25
+ * encodeTraces writes one ExportTraceServiceRequest for spans that share a
26
+ * resource (the SDK's one resource), grouped by instrumentation scope.
27
+ */
28
+ export declare function encodeTraces(spans: readonly ReadableSpan[], w?: Writer): Buffer;
29
+ /**
30
+ * maxRequestBytes keeps every request under the agent's 1 MiB intake
31
+ * bound, with room for the transport's own framing.
32
+ */
33
+ export declare const maxRequestBytes: number;
34
+ /**
35
+ * encodeWithin encodes spans into requests of at most limit bytes,
36
+ * halving a batch until each part fits. A single span that does not fit
37
+ * on its own (which the span limits make all but impossible) is dropped,
38
+ * and counted in dropped.
39
+ */
40
+ export declare function encodeWithin(spans: readonly ReadableSpan[], limit?: number): {
41
+ bodies: Buffer[];
42
+ dropped: number;
43
+ };
44
+ /** ProtobufExporterOptions bounds the exporter. */
45
+ export interface ProtobufExporterOptions {
46
+ url: string;
47
+ timeoutMillis: number;
48
+ /** concurrency is how many exports may be in flight; past it a batch is dropped. */
49
+ concurrency: number;
50
+ /** maxRequestBytes bounds one request (tests lower it). */
51
+ maxRequestBytes?: number;
52
+ }
53
+ /**
54
+ * ProtobufExporter posts encoded batches to the intake, split into
55
+ * requests under maxRequestBytes and sent one after another. A batch that
56
+ * cannot be sent (the intake is down, slow past the timeout, answers an
57
+ * error, or two exports are already in flight) is dropped and reported as
58
+ * failed to the batch processor; nothing is retried. A request the intake
59
+ * refuses as too large (413) is said once on stderr.
60
+ */
61
+ export declare class ProtobufExporter implements SpanExporter {
62
+ private readonly url;
63
+ private readonly agent;
64
+ private readonly timeoutMillis;
65
+ private readonly concurrency;
66
+ private readonly maxRequestBytes;
67
+ private inFlight;
68
+ private stopped;
69
+ constructor(options: ProtobufExporterOptions);
70
+ export(spans: ReadableSpan[], done: (result: ExportResult) => void): void;
71
+ /** post sends one request and settles with its outcome. */
72
+ private post;
73
+ shutdown(): Promise<void>;
74
+ forceFlush(): Promise<void>;
75
+ }