@sherlock-labs/node 0.0.0-stage → 0.3.0-rc.1
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/CHANGELOG.md +85 -0
- package/LICENSE +202 -0
- package/README.md +680 -2
- package/dist/express.d.mts +18 -0
- package/dist/express.d.ts +18 -0
- package/dist/express.js +320 -0
- package/dist/express.js.map +1 -0
- package/dist/express.mjs +318 -0
- package/dist/express.mjs.map +1 -0
- package/dist/fastify.d.mts +62 -0
- package/dist/fastify.d.ts +62 -0
- package/dist/fastify.js +659 -0
- package/dist/fastify.js.map +1 -0
- package/dist/fastify.mjs +656 -0
- package/dist/fastify.mjs.map +1 -0
- package/dist/httpServerMetrics-BfVoFAxd.d.mts +15 -0
- package/dist/httpServerMetrics-BfVoFAxd.d.ts +15 -0
- package/dist/index.d.mts +198 -0
- package/dist/index.d.ts +198 -0
- package/dist/index.js +1552 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1527 -0
- package/dist/index.mjs.map +1 -0
- package/dist/koa.d.mts +14 -0
- package/dist/koa.d.ts +14 -0
- package/dist/koa.js +309 -0
- package/dist/koa.js.map +1 -0
- package/dist/koa.mjs +307 -0
- package/dist/koa.mjs.map +1 -0
- package/dist/register.d.mts +2 -0
- package/dist/register.d.ts +2 -0
- package/dist/register.js +1641 -0
- package/dist/register.js.map +1 -0
- package/dist/register.mjs +1691 -0
- package/dist/register.mjs.map +1 -0
- package/package.json +108 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { Attributes } from '@opentelemetry/api';
|
|
2
|
+
export { Attributes, Span, SpanContext, SpanKind, SpanStatusCode, Tracer, context, trace } from '@opentelemetry/api';
|
|
3
|
+
import { Instrumentation } from '@opentelemetry/instrumentation';
|
|
4
|
+
|
|
5
|
+
/** The default bucket boundaries, in seconds, of a duration histogram. */
|
|
6
|
+
declare const DEFAULT_DURATION_BOUNDARIES_S: readonly number[];
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The default bucket boundaries of a histogram defined without `boundaries`
|
|
10
|
+
* whose unit is not `'s'`. Same numbers as the fallback `@opentelemetry/sdk-metrics`
|
|
11
|
+
* applies to a histogram created without boundaries
|
|
12
|
+
* (`HistogramAggregation.DEFAULT_INSTANCE`, private). Upstream changes do not
|
|
13
|
+
* propagate; the upgrade checklist re-compares.
|
|
14
|
+
*/
|
|
15
|
+
declare const DEFAULT_HISTOGRAM_BOUNDARIES: readonly number[];
|
|
16
|
+
interface CounterOptions {
|
|
17
|
+
description?: string;
|
|
18
|
+
unit?: string;
|
|
19
|
+
/** Instrumentation scope name; defaults to 'app'. */
|
|
20
|
+
meterName?: string;
|
|
21
|
+
}
|
|
22
|
+
type GaugeOptions = CounterOptions;
|
|
23
|
+
interface HistogramOptions extends CounterOptions {
|
|
24
|
+
/** Defaults to 's' — durations record in seconds. */
|
|
25
|
+
unit?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Explicit bucket boundaries, ascending. Shared with the exemplar reservoir.
|
|
28
|
+
* Defaults to DEFAULT_DURATION_BOUNDARIES_S when the unit is 's', else to
|
|
29
|
+
* DEFAULT_HISTOGRAM_BOUNDARIES.
|
|
30
|
+
*/
|
|
31
|
+
boundaries?: readonly number[];
|
|
32
|
+
}
|
|
33
|
+
declare class CounterDef {
|
|
34
|
+
readonly name: string;
|
|
35
|
+
private readonly opts;
|
|
36
|
+
private counter;
|
|
37
|
+
private counterEpoch;
|
|
38
|
+
constructor(name: string, opts: CounterOptions);
|
|
39
|
+
add(value: number, attrs?: Attributes): void;
|
|
40
|
+
}
|
|
41
|
+
declare class GaugeDef {
|
|
42
|
+
readonly name: string;
|
|
43
|
+
private readonly opts;
|
|
44
|
+
private gauge;
|
|
45
|
+
private gaugeEpoch;
|
|
46
|
+
constructor(name: string, opts: GaugeOptions);
|
|
47
|
+
/** Records the current value; the export carries the last one per attribute set. */
|
|
48
|
+
record(value: number, attrs?: Attributes): void;
|
|
49
|
+
}
|
|
50
|
+
declare class HistogramDef {
|
|
51
|
+
readonly name: string;
|
|
52
|
+
private readonly opts;
|
|
53
|
+
private histogram;
|
|
54
|
+
private histogramEpoch;
|
|
55
|
+
private readonly unit;
|
|
56
|
+
private readonly boundaries;
|
|
57
|
+
constructor(name: string, opts: HistogramOptions);
|
|
58
|
+
record(value: number, attrs?: Attributes): void;
|
|
59
|
+
recordWithExemplar(value: number, attrs?: Attributes, exemplarAttrs?: Record<string, string>): void;
|
|
60
|
+
}
|
|
61
|
+
declare function defineCounter(name: string, opts?: CounterOptions): CounterDef;
|
|
62
|
+
declare function defineGauge(name: string, opts?: GaugeOptions): GaugeDef;
|
|
63
|
+
declare function defineHistogram(name: string, opts?: HistogramOptions): HistogramDef;
|
|
64
|
+
/** Definition factories bound to one instrumentation scope. */
|
|
65
|
+
interface MeterDef {
|
|
66
|
+
counter(name: string, opts?: Omit<CounterOptions, 'meterName'>): CounterDef;
|
|
67
|
+
gauge(name: string, opts?: Omit<GaugeOptions, 'meterName'>): GaugeDef;
|
|
68
|
+
histogram(name: string, opts?: Omit<HistogramOptions, 'meterName'>): HistogramDef;
|
|
69
|
+
}
|
|
70
|
+
declare function defineMeter(meterName: string): MeterDef;
|
|
71
|
+
|
|
72
|
+
/** A pino-compatible logger for the OpenTelemetry SDK's own diagnostics. */
|
|
73
|
+
interface DistroLogger {
|
|
74
|
+
debug(...args: unknown[]): void;
|
|
75
|
+
info(...args: unknown[]): void;
|
|
76
|
+
warn(...args: unknown[]): void;
|
|
77
|
+
error(...args: unknown[]): void;
|
|
78
|
+
}
|
|
79
|
+
interface TracingOptions {
|
|
80
|
+
/**
|
|
81
|
+
* Share of NEW traces to sample, 0..1. Parent-based: a request is traced
|
|
82
|
+
* whole or not at all. Defaults to OTEL_TRACES_SAMPLER_ARG, else 1.
|
|
83
|
+
*/
|
|
84
|
+
sampleRatio?: number;
|
|
85
|
+
}
|
|
86
|
+
interface MetricsOptions {
|
|
87
|
+
/** Export interval in milliseconds. Defaults to SHERLOCK_METRICS_EXPORT_INTERVAL, else 30000. */
|
|
88
|
+
exportIntervalMillis?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Bucket boundaries, in SECONDS, for every HTTP duration histogram — the
|
|
91
|
+
* auto-instrumented ones, the adapters' `app.http.server.duration`, and the
|
|
92
|
+
* exemplar reservoirs for all of them.
|
|
93
|
+
*/
|
|
94
|
+
httpDurationBoundaries?: number[];
|
|
95
|
+
/** Exemplars kept per histogram bucket per export interval. Defaults to 5. */
|
|
96
|
+
exemplarsPerBucket?: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Narrows the auto-instrumentation bundle by name. Both keys may be given:
|
|
100
|
+
* `enabled` narrows the bundle and `disabled` then subtracts from what is left.
|
|
101
|
+
* A name is the package suffix, exactly as in
|
|
102
|
+
* OTEL_NODE_ENABLED_INSTRUMENTATIONS, so `"http"` means
|
|
103
|
+
* `@opentelemetry/instrumentation-http`. A name the bundle does not hold logs a
|
|
104
|
+
* warning.
|
|
105
|
+
*/
|
|
106
|
+
interface InstrumentationSelection {
|
|
107
|
+
/** Keep only these. Everything else in the bundle is disabled. */
|
|
108
|
+
enabled?: string[];
|
|
109
|
+
/** Keep everything except these. */
|
|
110
|
+
disabled?: string[];
|
|
111
|
+
}
|
|
112
|
+
interface ExporterOptions {
|
|
113
|
+
/** Extra headers on every export request, merged with the auth header. */
|
|
114
|
+
headers?: Record<string, string>;
|
|
115
|
+
/**
|
|
116
|
+
* Overrides the `Host` header on export requests, for deployments that route
|
|
117
|
+
* by host. The transport is `node:http`, which is why this survives — `fetch`
|
|
118
|
+
* and `undici` treat `Host` as a forbidden header and drop it.
|
|
119
|
+
*/
|
|
120
|
+
host?: string;
|
|
121
|
+
}
|
|
122
|
+
interface StartOptions {
|
|
123
|
+
/** Ingest token. Defaults to SHERLOCK_ACCESS_TOKEN. Without one the distribution stays off. */
|
|
124
|
+
accessToken?: string;
|
|
125
|
+
/** Your Sherlock ingest base URL. Defaults to SHERLOCK_ENDPOINT. Required: there is no default. */
|
|
126
|
+
endpoint?: string;
|
|
127
|
+
/** Service name on every span and metric. Defaults to OTEL_SERVICE_NAME. Required. */
|
|
128
|
+
serviceName?: string;
|
|
129
|
+
/** Merged into the resource; these values win over OTEL_RESOURCE_ATTRIBUTES. */
|
|
130
|
+
resourceAttributes?: Attributes;
|
|
131
|
+
/** `false` disables traces entirely. */
|
|
132
|
+
tracing?: boolean | TracingOptions;
|
|
133
|
+
/** `false` disables metrics entirely. */
|
|
134
|
+
metrics?: boolean | MetricsOptions;
|
|
135
|
+
/**
|
|
136
|
+
* Which instrumentations run: `{ enabled }` / `{ disabled }` filter the
|
|
137
|
+
* bundle `./register` installed. An `Instrumentation[]` is for an app that
|
|
138
|
+
* does not load `./register` (`[]` means none). Omit to keep the whole bundle.
|
|
139
|
+
*
|
|
140
|
+
* Either filter form wins over OTEL_NODE_ENABLED_INSTRUMENTATIONS and
|
|
141
|
+
* OTEL_NODE_DISABLED_INSTRUMENTATIONS. The package's own http hooks — the
|
|
142
|
+
* self-export guard, the ignored paths, and the HTTP exemplars — survive all
|
|
143
|
+
* three forms.
|
|
144
|
+
*/
|
|
145
|
+
instrumentations?: Instrumentation[] | InstrumentationSelection;
|
|
146
|
+
exporter?: ExporterOptions;
|
|
147
|
+
/**
|
|
148
|
+
* Extra request paths the HTTP instrumentation must ignore, on top of the
|
|
149
|
+
* defaults (/healthz, /livez, /healthcheck).
|
|
150
|
+
*/
|
|
151
|
+
ignorePaths?: string[];
|
|
152
|
+
fastify?: FastifyOptions;
|
|
153
|
+
/** Prefer this over the console for the SDK's own diagnostics. */
|
|
154
|
+
logger?: DistroLogger;
|
|
155
|
+
}
|
|
156
|
+
interface FastifyOptions {
|
|
157
|
+
/**
|
|
158
|
+
* A span for every Fastify lifecycle hook and route handler, under the
|
|
159
|
+
* request's server span. Off by default;
|
|
160
|
+
* `SHERLOCK_FASTIFY_LIFECYCLE_SPANS=true` turns it on too. Applies to
|
|
161
|
+
* Fastify instances created after it is set.
|
|
162
|
+
*/
|
|
163
|
+
lifecycleSpans?: boolean;
|
|
164
|
+
}
|
|
165
|
+
/** Runtime kill switch. Omitted pipelines keep their current state. */
|
|
166
|
+
interface TelemetryToggle {
|
|
167
|
+
traces?: boolean;
|
|
168
|
+
metrics?: boolean;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Turns the pipelines on. Safe to call once config is available — the patches
|
|
173
|
+
* `./register` installed record nothing until this runs, and the whole call is
|
|
174
|
+
* a no-op without an access token and a service name.
|
|
175
|
+
*
|
|
176
|
+
* Works with no `./register` import ever having run: you get metrics and
|
|
177
|
+
* exemplars with nothing monkey-patched.
|
|
178
|
+
*
|
|
179
|
+
* Never throws because of its own errors or a throwing `logger` option. A
|
|
180
|
+
* misconfiguration that cannot be recovered from leaves telemetry off and logs
|
|
181
|
+
* an error. A global diag logger the app installs itself sits outside this
|
|
182
|
+
* guarantee: OpenTelemetry calls it directly.
|
|
183
|
+
*/
|
|
184
|
+
declare function start(options?: StartOptions): void;
|
|
185
|
+
/**
|
|
186
|
+
* Flushes the last metric interval and the pending span batch, then tears the
|
|
187
|
+
* pipelines down. Safe to call twice, and safe to call when `start()` never
|
|
188
|
+
* ran.
|
|
189
|
+
*/
|
|
190
|
+
declare function stop(): Promise<void>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Turns either pipeline on or off while the process runs. An omitted field
|
|
194
|
+
* leaves that pipeline as it is.
|
|
195
|
+
*/
|
|
196
|
+
declare function setTelemetryEnabled(toggle: TelemetryToggle): void;
|
|
197
|
+
|
|
198
|
+
export { CounterDef, type CounterOptions, DEFAULT_DURATION_BOUNDARIES_S, DEFAULT_HISTOGRAM_BOUNDARIES, type DistroLogger, type ExporterOptions, type FastifyOptions, GaugeDef, type GaugeOptions, HistogramDef, type HistogramOptions, type InstrumentationSelection, type MeterDef, type MetricsOptions, type StartOptions, type TelemetryToggle, type TracingOptions, defineCounter, defineGauge, defineHistogram, defineMeter, setTelemetryEnabled, start, stop };
|