@obzerver/node 0.0.0-stage → 0.3.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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -2
  3. package/dist/agent-types.d.ts +28 -0
  4. package/dist/agent-types.js +6 -0
  5. package/dist/agent-types.js.map +1 -0
  6. package/dist/agent.d.ts +90 -0
  7. package/dist/agent.js +578 -0
  8. package/dist/agent.js.map +1 -0
  9. package/dist/context.d.ts +86 -0
  10. package/dist/context.js +136 -0
  11. package/dist/context.js.map +1 -0
  12. package/dist/errors.d.ts +18 -0
  13. package/dist/errors.js +108 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/index.d.ts +76 -0
  16. package/dist/index.js +110 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/instrument/console.d.ts +11 -0
  19. package/dist/instrument/console.js +68 -0
  20. package/dist/instrument/console.js.map +1 -0
  21. package/dist/instrument/db.d.ts +7 -0
  22. package/dist/instrument/db.js +155 -0
  23. package/dist/instrument/db.js.map +1 -0
  24. package/dist/instrument/express.d.ts +3 -0
  25. package/dist/instrument/express.js +133 -0
  26. package/dist/instrument/express.js.map +1 -0
  27. package/dist/instrument/fastify.d.ts +35 -0
  28. package/dist/instrument/fastify.js +88 -0
  29. package/dist/instrument/fastify.js.map +1 -0
  30. package/dist/instrument/http.d.ts +10 -0
  31. package/dist/instrument/http.js +149 -0
  32. package/dist/instrument/http.js.map +1 -0
  33. package/dist/instrument/jobs.d.ts +15 -0
  34. package/dist/instrument/jobs.js +90 -0
  35. package/dist/instrument/jobs.js.map +1 -0
  36. package/dist/options.d.ts +89 -0
  37. package/dist/options.js +3 -0
  38. package/dist/options.js.map +1 -0
  39. package/dist/protocol.d.ts +146 -0
  40. package/dist/protocol.js +4 -0
  41. package/dist/protocol.js.map +1 -0
  42. package/dist/redact.d.ts +12 -0
  43. package/dist/redact.js +54 -0
  44. package/dist/redact.js.map +1 -0
  45. package/dist/register.d.ts +1 -0
  46. package/dist/register.js +9 -0
  47. package/dist/register.js.map +1 -0
  48. package/dist/runtime.d.ts +37 -0
  49. package/dist/runtime.js +142 -0
  50. package/dist/runtime.js.map +1 -0
  51. package/dist/transport.d.ts +32 -0
  52. package/dist/transport.js +122 -0
  53. package/dist/transport.js.map +1 -0
  54. package/package.json +51 -4
@@ -0,0 +1,15 @@
1
+ import type { JobMeta } from '../agent';
2
+ /** What the job instrumentations need from the agent. */
3
+ export interface JobRunner {
4
+ /** Run one invocation of fn as its own job trace. */
5
+ runJob<R>(name: string, fn: () => R, meta: JobMeta, auto: boolean): R;
6
+ }
7
+ /**
8
+ * BullMQ: every processor run becomes a job, inline or sandboxed processors alike.
9
+ * Hooks Worker.prototype.callProcessJob (BullMQ 3–5), which wraps the user's processor.
10
+ */
11
+ export declare function patchBullmq(bullmq: unknown, runner: JobRunner): boolean;
12
+ /** node-cron (v3/v4): every scheduled tick of a function task becomes a job. */
13
+ export declare function patchNodeCron(nodeCron: unknown, runner: JobRunner): boolean;
14
+ /** cron (kelektiv, v2–v4): every onTick callback run becomes a job. */
15
+ export declare function patchCron(cron: unknown, runner: JobRunner): boolean;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchBullmq = patchBullmq;
4
+ exports.patchNodeCron = patchNodeCron;
5
+ exports.patchCron = patchCron;
6
+ const kPatched = Symbol.for('obzerver.jobs.patched');
7
+ /**
8
+ * BullMQ: every processor run becomes a job, inline or sandboxed processors alike.
9
+ * Hooks Worker.prototype.callProcessJob (BullMQ 3–5), which wraps the user's processor.
10
+ */
11
+ function patchBullmq(bullmq, runner) {
12
+ const Worker = bullmq.Worker;
13
+ const proto = Worker?.prototype;
14
+ if (!proto || typeof proto.callProcessJob !== 'function' || proto.callProcessJob[kPatched])
15
+ return false;
16
+ const orig = proto.callProcessJob;
17
+ const wrapped = function (job, ...rest) {
18
+ const queue = this.name || job?.queueName || 'bullmq';
19
+ return runner.runJob(job?.name || queue, () => orig.call(this, job, ...rest), {
20
+ queue,
21
+ attempt: (job?.attemptsMade || 0) + 1,
22
+ queueWait: job?.timestamp ? Math.max(0, (job.processedOn || Date.now()) - job.timestamp) : null,
23
+ }, true);
24
+ };
25
+ wrapped[kPatched] = true;
26
+ proto.callProcessJob = wrapped;
27
+ return true;
28
+ }
29
+ /** node-cron (v3/v4): every scheduled tick of a function task becomes a job. */
30
+ function patchNodeCron(nodeCron, runner) {
31
+ const mod = nodeCron;
32
+ if (typeof mod.schedule !== 'function' || mod.schedule[kPatched])
33
+ return false;
34
+ const wrapTask = (expression, func, options) => {
35
+ if (typeof func !== 'function')
36
+ return func; // v4 background tasks take a file path; those run in a child process
37
+ const user = func;
38
+ const name = options?.name || user.name || `cron ${String(expression)}`;
39
+ const w = function (...args) {
40
+ return runner.runJob(name, () => user.apply(this, args), { queue: 'cron', attempt: 1, queueWait: null }, true);
41
+ };
42
+ Object.defineProperty(w, 'name', { value: user.name });
43
+ return w;
44
+ };
45
+ const patchFn = (holder, key) => {
46
+ const orig = holder[key];
47
+ if (typeof orig !== 'function' || orig[kPatched])
48
+ return;
49
+ const w = function (expression, func, options, ...rest) {
50
+ return orig.call(this, expression, wrapTask(expression, func, options), options, ...rest);
51
+ };
52
+ w[kPatched] = true;
53
+ holder[key] = w;
54
+ };
55
+ const holders = [mod];
56
+ // v4 also exposes the same functions on a default/nodeCron object.
57
+ for (const k of ['default', 'nodeCron']) {
58
+ const o = mod[k];
59
+ if (o && typeof o === 'object' && o !== mod)
60
+ holders.push(o);
61
+ }
62
+ for (const h of holders) {
63
+ patchFn(h, 'schedule');
64
+ patchFn(h, 'createTask');
65
+ }
66
+ return true;
67
+ }
68
+ /** cron (kelektiv, v2–v4): every onTick callback run becomes a job. */
69
+ function patchCron(cron, runner) {
70
+ const CronJob = cron.CronJob;
71
+ const proto = CronJob?.prototype;
72
+ if (!proto || typeof proto.addCallback !== 'function' || proto.addCallback[kPatched])
73
+ return false;
74
+ const orig = proto.addCallback;
75
+ const wrapped = function (callback, ...rest) {
76
+ if (typeof callback !== 'function')
77
+ return orig.call(this, callback, ...rest);
78
+ const cronJob = this;
79
+ const user = callback;
80
+ const cb = function (...args) {
81
+ const name = cronJob.name || (user.name && user.name !== 'bound ' ? user.name.replace(/^bound /, '') : '') || `cron ${String(cronJob.cronTime?.source ?? '')}`;
82
+ return runner.runJob(name, () => user.apply(this, args), { queue: 'cron', attempt: 1, queueWait: null }, true);
83
+ };
84
+ return orig.call(this, cb, ...rest);
85
+ };
86
+ wrapped[kPatched] = true;
87
+ proto.addCallback = wrapped;
88
+ return true;
89
+ }
90
+ //# sourceMappingURL=jobs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../src/instrument/jobs.ts"],"names":[],"mappings":";;AAmBA,kCAgBC;AAGD,sCA8BC;AAKD,8BAkBC;AAzFD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAarD;;;GAGG;AACH,SAAgB,WAAW,CAAC,MAAe,EAAE,MAAiB;IAC5D,MAAM,MAAM,GAAI,MAA4D,CAAC,MAAM,CAAC;IACpF,MAAM,KAAK,GAAG,MAAM,EAAE,SAAS,CAAC;IAChC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,cAAc,KAAK,UAAU,IAAI,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IACzG,MAAM,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC;IAClC,MAAM,OAAO,GAAU,UAA4B,GAAY,EAAE,GAAG,IAAe;QACjF,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,IAAI,GAAG,EAAE,SAAS,IAAI,QAAQ,CAAC;QACtD,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,IAAI,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,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IAAI,CAAC,CAAC;QACjH,CAAC,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC,CAAC;IACF,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,89 @@
1
+ import type { IncomingMessage } from 'node:http';
2
+ import type { RedactionOptions } from './redact';
3
+ import type { SourceContextOptions } from './errors';
4
+ export type IgnoreRule = string | RegExp | {
5
+ method?: string;
6
+ path: string | RegExp;
7
+ } | ((req: IncomingMessage) => boolean);
8
+ export interface CaptureOptions {
9
+ /** Extra request headers to record on failed or slow requests (an allow-list is always recorded). */
10
+ headers?: string[];
11
+ /** Record the parsed request body (redacted). Off by default. */
12
+ body?: boolean | {
13
+ maxBytes?: number;
14
+ };
15
+ /** Also capture requests slower than this. Default 2000 */
16
+ slowerThanMs?: number;
17
+ }
18
+ export interface HttpOptions {
19
+ ignore?: IgnoreRule[];
20
+ /** Return an opaque user id for the Users view. Receives the Express req or Fastify request. */
21
+ getUserId?: ((req: any) => string | number | null | undefined) | null;
22
+ capture?: false | CaptureOptions;
23
+ }
24
+ export type InstrumentationName = 'http' | 'fetch' | 'express' | 'fastify' | 'pg' | 'mysql2' | 'ioredis' | 'console' | 'bullmq' | 'nodeCron' | 'cron';
25
+ export interface ObzerverOptions {
26
+ /** Ingest key from the dashboard. Default: OBZERVER_KEY */
27
+ appKey?: string;
28
+ /** Collector URL. Default: OBZERVER_ENDPOINT or http://localhost:4319 */
29
+ endpoint?: string;
30
+ /** Identifies the application. Default: OBZERVER_SERVICE or package.json name */
31
+ serviceId?: string;
32
+ /** Release identifier; enables the Releases view. Default: OBZERVER_VERSION, GIT_SHA or package.json version */
33
+ serviceVersion?: string | null;
34
+ environment?: string;
35
+ instanceId?: string;
36
+ /** false records and sends nothing. Default: OBZERVER_ENABLED !== 'false' */
37
+ enabled?: boolean;
38
+ debug?: boolean;
39
+ /** Fraction of executions that keep their full waterfall (failed and slow ones always do). Default 1 */
40
+ tracesSampleRate?: number;
41
+ /** ms between sends. Default 5000 */
42
+ flushInterval?: number;
43
+ maxTracesPerBatch?: number;
44
+ /** ms between runtime samples. Default 15000 */
45
+ runtimeMetricsInterval?: number;
46
+ /** Forward console output correlated to the active trace. Default true */
47
+ forwardLogs?: boolean;
48
+ /** Collapse repeated sibling spans. Default { threshold: 20, keepSlowest: 3 } */
49
+ spanCollapse?: false | {
50
+ threshold?: number;
51
+ keepSlowest?: number;
52
+ };
53
+ /** Source lines attached to in-app stack frames. */
54
+ sourceContext?: false | SourceContextOptions;
55
+ redaction?: false | RedactionOptions;
56
+ http?: HttpOptions;
57
+ instrument?: Partial<Record<InstrumentationName, boolean>>;
58
+ /** Directory used to resolve the app's package.json and modules. Default process.cwd() */
59
+ cwd?: string;
60
+ }
61
+ /** Options after defaults are applied. */
62
+ export interface ResolvedOptions {
63
+ enabled: boolean;
64
+ appKey: string;
65
+ endpoint: string;
66
+ serviceId: string;
67
+ serviceVersion: string | null;
68
+ environment: string;
69
+ instanceId: string;
70
+ debug: boolean;
71
+ tracesSampleRate: number;
72
+ flushInterval: number;
73
+ maxTracesPerBatch: number;
74
+ runtimeMetricsInterval: number;
75
+ forwardLogs: boolean;
76
+ spanCollapse: false | {
77
+ threshold: number;
78
+ keepSlowest: number;
79
+ };
80
+ sourceContext: false | SourceContextOptions;
81
+ http: {
82
+ ignore: IgnoreRule[];
83
+ getUserId: HttpOptions['getUserId'];
84
+ capture: false | Required<Pick<CaptureOptions, 'headers' | 'slowerThanMs'>> & {
85
+ body: CaptureOptions['body'];
86
+ };
87
+ };
88
+ instrument: Record<InstrumentationName, boolean>;
89
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,146 @@
1
+ export interface StackFrame {
2
+ fn: string;
3
+ file: string;
4
+ rel: string;
5
+ line: number;
6
+ col: number;
7
+ inApp: boolean;
8
+ context?: {
9
+ start: number;
10
+ lines: string[];
11
+ };
12
+ }
13
+ export interface WireSpan {
14
+ id: string;
15
+ parentId: string | null;
16
+ name: string;
17
+ kind: SpanKind;
18
+ /** ms offset from the trace start */
19
+ start: number;
20
+ duration: number;
21
+ /** duration minus the union of child intervals */
22
+ self: number;
23
+ /** >1 when repeated sibling spans were collapsed into one */
24
+ count?: number;
25
+ attrs?: Record<string, unknown>;
26
+ error?: string;
27
+ }
28
+ export type SpanKind = 'request' | 'job' | 'middleware' | 'handler' | 'function' | 'custom' | 'db' | 'http';
29
+ export interface CaptureData {
30
+ reason: 'failed' | 'error' | 'slow';
31
+ headers?: Record<string, unknown>;
32
+ query?: string;
33
+ body?: string;
34
+ }
35
+ export interface WireTrace {
36
+ traceId: string;
37
+ spanId: string;
38
+ parentSpanId: string | null;
39
+ kind: 'http' | 'job';
40
+ name: string;
41
+ method: string | null;
42
+ route: string | null;
43
+ path: string | null;
44
+ status: number | null;
45
+ ts: number;
46
+ duration: number;
47
+ userId: string | null;
48
+ failed: boolean;
49
+ errorClass: string | null;
50
+ fingerprint: string | null;
51
+ errorMessage: string | null;
52
+ tags?: Record<string, unknown>;
53
+ capture?: CaptureData;
54
+ queue: string | null;
55
+ queueWait: number | null;
56
+ attempt: number | null;
57
+ sampled: boolean;
58
+ spans?: WireSpan[];
59
+ }
60
+ export interface WireError {
61
+ ts: number;
62
+ class: string;
63
+ message: string;
64
+ stack: string;
65
+ frames: StackFrame[];
66
+ fingerprint: string;
67
+ status: number | null;
68
+ handled: boolean;
69
+ code: string | null;
70
+ httpStatus?: number | null;
71
+ traceId?: string | null;
72
+ operation?: string | null;
73
+ kind?: string;
74
+ userId?: string | null;
75
+ version?: string | null;
76
+ }
77
+ export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
78
+ export interface WireLog {
79
+ ts: number;
80
+ level: LogLevel | string;
81
+ message: string;
82
+ logger: string | null;
83
+ traceId: string | null;
84
+ spanId: string | null;
85
+ attrs?: Record<string, unknown>;
86
+ }
87
+ export interface WireRuntime {
88
+ ts: number;
89
+ cpu: number;
90
+ rss: number;
91
+ heapUsed: number;
92
+ heapTotal: number;
93
+ external: number;
94
+ elDelayP50: number;
95
+ elDelayP99: number;
96
+ elDelayMax: number;
97
+ elu: number;
98
+ gcCount: number;
99
+ gcMs: number;
100
+ handles: number | null;
101
+ inflight: number;
102
+ }
103
+ export type MetricType = 'counter' | 'gauge' | 'summary';
104
+ export interface WireMetric {
105
+ ts: number;
106
+ name: string;
107
+ type: MetricType;
108
+ labels: Record<string, string>;
109
+ value: number;
110
+ count: number;
111
+ sum?: number;
112
+ min?: number | null;
113
+ max?: number | null;
114
+ }
115
+ export interface ServiceInfo {
116
+ id: string;
117
+ version: string | null;
118
+ instance: string;
119
+ environment?: string;
120
+ node?: string;
121
+ host?: string;
122
+ pid?: number;
123
+ frameworks?: string[];
124
+ }
125
+ export interface IngestPayload {
126
+ sdk?: {
127
+ name: string;
128
+ version: string;
129
+ };
130
+ service: ServiceInfo;
131
+ sentAt?: number;
132
+ dropped?: number;
133
+ traces?: WireTrace[];
134
+ errors?: WireError[];
135
+ logs?: WireLog[];
136
+ runtime?: WireRuntime[];
137
+ metrics?: WireMetric[];
138
+ }
139
+ export type QueueKind = 'traces' | 'errors' | 'logs' | 'runtime' | 'metrics';
140
+ export interface QueueItems {
141
+ traces: WireTrace;
142
+ errors: WireError;
143
+ logs: WireLog;
144
+ runtime: WireRuntime;
145
+ metrics: WireMetric;
146
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Wire format between @obzerver/node and @obzerver/server (POST /v1/ingest, gzip JSON).
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":";AAAA,wFAAwF"}
@@ -0,0 +1,12 @@
1
+ export interface RedactionOptions {
2
+ enabled?: boolean;
3
+ useDefaultPatterns?: boolean;
4
+ keys?: string[];
5
+ patterns?: RegExp[];
6
+ replacement?: string;
7
+ }
8
+ export interface Redactor {
9
+ string(s: string): string;
10
+ value<T>(v: T): T;
11
+ }
12
+ export declare function createRedactor(opts?: RedactionOptions | false): Redactor;
package/dist/redact.js ADDED
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRedactor = createRedactor;
4
+ const DEFAULT_KEYS = [
5
+ 'authorization', 'cookie', 'set-cookie', 'password', 'passwd', 'pwd', 'secret', 'token',
6
+ 'access_token', 'refresh_token', 'id_token', 'api_key', 'apikey', 'x-api-key', 'client_secret',
7
+ 'private_key', 'credit_card', 'card_number', 'cvv', 'ssn', 'x-obzerver-key',
8
+ ];
9
+ const DEFAULT_PATTERNS = [
10
+ /\bBearer\s+[A-Za-z0-9\-._~+/]+=*/g,
11
+ /\beyJ[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\b/g, // JWT
12
+ /\b(AKIA|ASIA)[0-9A-Z]{16}\b/g, // AWS key id
13
+ /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,
14
+ /\b(password|passwd|secret|token|api[_-]?key)=([^&\s"']+)/gi,
15
+ /\b(?:\d[ -]?){13,19}\b/g, // card numbers
16
+ ];
17
+ function createRedactor(opts = {}) {
18
+ if (opts === false || opts.enabled === false) {
19
+ return { string: (s) => s, value: (v) => v };
20
+ }
21
+ const replacement = opts.replacement || '[REDACTED]';
22
+ const defaults = opts.useDefaultPatterns !== false;
23
+ const keys = new Set([...(defaults ? DEFAULT_KEYS : []), ...(opts.keys || [])].map((k) => k.toLowerCase()));
24
+ const patterns = [...(defaults ? DEFAULT_PATTERNS : []), ...(opts.patterns || [])];
25
+ const string = (s) => {
26
+ if (typeof s !== 'string' || !s)
27
+ return s;
28
+ let out = s;
29
+ for (const p of patterns) {
30
+ p.lastIndex = 0;
31
+ out = out.replace(p, (m, k) => (typeof k === 'string' && m.includes('=') && !/^\d/.test(m) ? `${k}=${replacement}` : replacement));
32
+ }
33
+ return out;
34
+ };
35
+ const walk = (v, depth) => {
36
+ if (v == null)
37
+ return v;
38
+ if (typeof v === 'string')
39
+ return string(v);
40
+ if (typeof v !== 'object')
41
+ return v;
42
+ if (depth > 6)
43
+ return '[depth]';
44
+ if (Array.isArray(v))
45
+ return v.slice(0, 100).map((x) => walk(x, depth + 1));
46
+ const out = {};
47
+ for (const [k, val] of Object.entries(v)) {
48
+ out[k] = keys.has(k.toLowerCase()) ? replacement : walk(val, depth + 1);
49
+ }
50
+ return out;
51
+ };
52
+ return { string, value: (v) => walk(v, 0) };
53
+ }
54
+ //# sourceMappingURL=redact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":";;AA4BA,wCAiCC;AAhDD,MAAM,YAAY,GAAG;IACnB,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO;IACvF,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe;IAC9F,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB;CAC5E,CAAC;AAEF,MAAM,gBAAgB,GAAa;IACjC,mCAAmC;IACnC,iEAAiE,EAAE,MAAM;IACzE,8BAA8B,EAAE,aAAa;IAC7C,6EAA6E;IAC7E,4DAA4D;IAC5D,yBAAyB,EAAE,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,CAAC,EAAE,CAAC,CAAM,EAAE,CAAC;AAC7D,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Zero-config entry:
4
+ // node -r @obzerver/node/register app.js
5
+ // node --import @obzerver/node/register app.ts
6
+ // Configure with OBZERVER_KEY, OBZERVER_ENDPOINT, OBZERVER_SERVICE, OBZERVER_VERSION.
7
+ const index_1 = require("./index");
8
+ index_1.default.init();
9
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":";;AAAA,qBAAqB;AACrB,2CAA2C;AAC3C,iDAAiD;AACjD,sFAAsF;AACtF,mCAA+B;AAE/B,eAAQ,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { AgentHooks } from './agent-types';
2
+ /** Samples CPU, memory, event loop delay/utilisation and GC on an interval. */
3
+ export declare class RuntimeSampler {
4
+ private readonly agent;
5
+ private readonly hist;
6
+ private lastCpu;
7
+ private lastTime;
8
+ private lastElu;
9
+ private gc;
10
+ private readonly obs;
11
+ private readonly timer;
12
+ constructor(agent: AgentHooks, intervalMs?: number);
13
+ sample(): void;
14
+ stop(): void;
15
+ }
16
+ export interface Counter {
17
+ inc(value?: number): void;
18
+ }
19
+ export interface Gauge {
20
+ set(value: number): void;
21
+ }
22
+ export interface Summary {
23
+ observe(value: number): void;
24
+ }
25
+ /** Counters, gauges and summaries, aggregated in-process and flushed as deltas. */
26
+ export declare class Metrics {
27
+ private readonly agent;
28
+ private readonly series;
29
+ private readonly timer;
30
+ constructor(agent: AgentHooks, intervalMs?: number);
31
+ private get;
32
+ counter(name: string, labels?: Record<string, string>): Counter;
33
+ gauge(name: string, labels?: Record<string, string>): Gauge;
34
+ summary(name: string, labels?: Record<string, string>): Summary;
35
+ flush(): void;
36
+ stop(): void;
37
+ }
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Metrics = exports.RuntimeSampler = void 0;
4
+ const node_perf_hooks_1 = require("node:perf_hooks");
5
+ /** Samples CPU, memory, event loop delay/utilisation and GC on an interval. */
6
+ class RuntimeSampler {
7
+ agent;
8
+ hist;
9
+ lastCpu = process.cpuUsage();
10
+ lastTime = process.hrtime.bigint();
11
+ lastElu = node_perf_hooks_1.performance.eventLoopUtilization();
12
+ gc = { count: 0, ms: 0 };
13
+ obs;
14
+ timer;
15
+ constructor(agent, intervalMs = 15000) {
16
+ this.agent = agent;
17
+ this.hist = (0, node_perf_hooks_1.monitorEventLoopDelay)({ resolution: 10 });
18
+ this.hist.enable();
19
+ let obs = null;
20
+ try {
21
+ obs = new node_perf_hooks_1.PerformanceObserver((list) => {
22
+ for (const e of list.getEntries()) {
23
+ this.gc.count++;
24
+ this.gc.ms += e.duration;
25
+ }
26
+ });
27
+ obs.observe({ entryTypes: ['gc'] });
28
+ }
29
+ catch {
30
+ obs = null;
31
+ }
32
+ this.obs = obs;
33
+ this.timer = setInterval(() => this.sample(), Math.max(5000, intervalMs));
34
+ this.timer.unref();
35
+ }
36
+ sample() {
37
+ const now = process.hrtime.bigint();
38
+ const elapsedUs = Number(now - this.lastTime) / 1000;
39
+ const cpu = process.cpuUsage(this.lastCpu);
40
+ const elu = node_perf_hooks_1.performance.eventLoopUtilization(this.lastElu);
41
+ const mem = process.memoryUsage();
42
+ const ms = (v) => (Number.isFinite(v) ? v / 1e6 : 0);
43
+ this.agent.transport?.push('runtime', {
44
+ ts: Date.now(),
45
+ cpu: Math.min(6400, ((cpu.user + cpu.system) / Math.max(1, elapsedUs)) * 100),
46
+ rss: mem.rss,
47
+ heapUsed: mem.heapUsed,
48
+ heapTotal: mem.heapTotal,
49
+ external: mem.external,
50
+ elDelayP50: ms(this.hist.percentile(50)),
51
+ elDelayP99: ms(this.hist.percentile(99)),
52
+ elDelayMax: ms(this.hist.max),
53
+ elu: elu.utilization * 100,
54
+ gcCount: this.gc.count,
55
+ gcMs: this.gc.ms,
56
+ handles: typeof process.getActiveResourcesInfo === 'function' ? process.getActiveResourcesInfo().length : null,
57
+ inflight: this.agent.inflight,
58
+ });
59
+ this.hist.reset();
60
+ this.gc = { count: 0, ms: 0 };
61
+ this.lastCpu = process.cpuUsage();
62
+ this.lastTime = now;
63
+ this.lastElu = node_perf_hooks_1.performance.eventLoopUtilization();
64
+ }
65
+ stop() { clearInterval(this.timer); this.hist.disable(); this.obs?.disconnect(); }
66
+ }
67
+ exports.RuntimeSampler = RuntimeSampler;
68
+ /** Counters, gauges and summaries, aggregated in-process and flushed as deltas. */
69
+ class Metrics {
70
+ agent;
71
+ series = new Map();
72
+ timer;
73
+ constructor(agent, intervalMs = 10000) {
74
+ this.agent = agent;
75
+ this.timer = setInterval(() => this.flush(), Math.max(5000, intervalMs));
76
+ this.timer.unref();
77
+ }
78
+ get(type, name, labels) {
79
+ const k = `${name}|${labels ? JSON.stringify(Object.entries(labels).sort()) : ''}`;
80
+ let s = this.series.get(k);
81
+ if (!s) {
82
+ if (this.series.size > 5000)
83
+ return null;
84
+ s = { type, name, labels: labels || {}, value: 0, count: 0, sum: 0, min: Infinity, max: -Infinity, dirty: false };
85
+ this.series.set(k, s);
86
+ }
87
+ return s;
88
+ }
89
+ counter(name, labels) {
90
+ return { inc: (v = 1) => { const s = this.get('counter', name, labels); if (s) {
91
+ s.value += v;
92
+ s.count++;
93
+ s.dirty = true;
94
+ } } };
95
+ }
96
+ gauge(name, labels) {
97
+ return { set: (v) => { const s = this.get('gauge', name, labels); if (s) {
98
+ s.value = v;
99
+ s.dirty = true;
100
+ } } };
101
+ }
102
+ summary(name, labels) {
103
+ return {
104
+ observe: (v) => {
105
+ const s = this.get('summary', name, labels);
106
+ if (!s)
107
+ return;
108
+ s.count++;
109
+ s.sum += v;
110
+ s.min = Math.min(s.min, v);
111
+ s.max = Math.max(s.max, v);
112
+ s.value = v;
113
+ s.dirty = true;
114
+ },
115
+ };
116
+ }
117
+ flush() {
118
+ const ts = Date.now();
119
+ for (const s of this.series.values()) {
120
+ if (!s.dirty && s.type !== 'gauge')
121
+ continue;
122
+ this.agent.transport?.push('metrics', {
123
+ ts, name: s.name, type: s.type, labels: s.labels,
124
+ value: s.type === 'summary' ? (s.count ? s.sum / s.count : 0) : s.value,
125
+ count: s.count, sum: s.sum,
126
+ min: Number.isFinite(s.min) ? s.min : null,
127
+ max: Number.isFinite(s.max) ? s.max : null,
128
+ });
129
+ if (s.type !== 'gauge') {
130
+ s.value = 0;
131
+ s.count = 0;
132
+ s.sum = 0;
133
+ s.min = Infinity;
134
+ s.max = -Infinity;
135
+ }
136
+ s.dirty = false;
137
+ }
138
+ }
139
+ stop() { clearInterval(this.timer); this.flush(); }
140
+ }
141
+ exports.Metrics = Metrics;
142
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":";;;AAAA,qDAA6I;AAI7I,+EAA+E;AAC/E,MAAa,cAAc;IASI;IARZ,IAAI,CAAoB;IACjC,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC7B,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACnC,OAAO,GAAyB,6BAAW,CAAC,oBAAoB,EAAE,CAAC;IACnE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;IAChB,GAAG,CAA6B;IAChC,KAAK,CAAiB;IAEvC,YAA6B,KAAiB,EAAE,UAAU,GAAG,KAAK;QAArC,UAAK,GAAL,KAAK,CAAY;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAA,uCAAqB,EAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACnB,IAAI,GAAG,GA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