@autter/runtime-node 1.9.0 → 1.10.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/README.md +30 -6
- package/dist/chunk-3UODRQBD.js +878 -0
- package/dist/chunk-HBH64LWQ.cjs +878 -0
- package/dist/{chunk-ZKM76SDP.js → chunk-KWAJIELR.js} +304 -201
- package/dist/{chunk-BHYHORUD.cjs → chunk-S6WJ5YLP.cjs} +304 -201
- package/dist/{chunk-YWTIKZSI.cjs → chunk-STOXJZ7Z.cjs} +38 -15
- package/dist/{chunk-HHKQ3UCH.js → chunk-V65UY6LU.js} +30 -7
- package/dist/cli.cjs +36 -9
- package/dist/cli.js +32 -5
- package/dist/index.cjs +655 -292
- package/dist/index.d.cts +154 -13
- package/dist/index.d.ts +154 -13
- package/dist/index.js +434 -71
- package/dist/{sinks-CLtQFPnn.d.ts → sinks-BfUoE96B.d.cts} +3 -1
- package/dist/{sinks-CLtQFPnn.d.cts → sinks-BfUoE96B.d.ts} +3 -1
- package/dist/testing.cjs +8 -8
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +2 -2
- package/package.json +2 -1
- package/dist/chunk-AN45KLWD.cjs +0 -202
- package/dist/chunk-JSGGUWRD.js +0 -202
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { b as RedactOptions, c as Redactor$1, d as RuntimeLogLevel, e as RuntimeOperationKind, f as RuntimeSink, F as FileSinkOptions, g as RuntimeLogContext, a as RuntimeOutcome, h as RuntimeCarrier, I as IgnoreErrorPattern, i as CaptureLoggedErrorsOption, B as BreadcrumbInput } from './sinks-
|
|
3
|
-
export { j as Breadcrumb, k as BreadcrumbLevel, l as BreadcrumbType, n as CODE_PATTERN, o as ClientErrorBody, p as ConsoleSinkOptions, L as LoggedErrorSource, O as OtlpSinkOptions, q as RuntimeError, r as RuntimeErrorCatalog, s as RuntimeErrorDefinition, t as RuntimeErrorExtras, u as RuntimeErrorFactory, v as RuntimeErrorLike, w as RuntimeErrorOptions, R as RuntimeEvent, x as RuntimeLogContextValue, y as RuntimeSinkContext, z as consoleSink, A as defineRuntimeErrors, D as errorAttributes, E as fileSink, G as isRuntimeErrorLike, H as otlpSink, J as redactAttributes, K as redactText, N as toClientError } from './sinks-
|
|
2
|
+
import { b as RedactOptions, c as Redactor$1, d as RuntimeLogLevel, e as RuntimeOperationKind, f as RuntimeSink, F as FileSinkOptions, g as RuntimeLogContext, a as RuntimeOutcome, h as RuntimeCarrier, I as IgnoreErrorPattern, i as CaptureLoggedErrorsOption, B as BreadcrumbInput } from './sinks-BfUoE96B.cjs';
|
|
3
|
+
export { j as Breadcrumb, k as BreadcrumbLevel, l as BreadcrumbType, n as CODE_PATTERN, o as ClientErrorBody, p as ConsoleSinkOptions, L as LoggedErrorSource, O as OtlpSinkOptions, q as RuntimeError, r as RuntimeErrorCatalog, s as RuntimeErrorDefinition, t as RuntimeErrorExtras, u as RuntimeErrorFactory, v as RuntimeErrorLike, w as RuntimeErrorOptions, R as RuntimeEvent, x as RuntimeLogContextValue, y as RuntimeSinkContext, z as consoleSink, A as defineRuntimeErrors, D as errorAttributes, E as fileSink, G as isRuntimeErrorLike, H as otlpSink, J as redactAttributes, K as redactText, N as toClientError } from './sinks-BfUoE96B.cjs';
|
|
4
4
|
import { Attributes } from '@opentelemetry/api';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -11,8 +11,12 @@ import { Attributes } from '@opentelemetry/api';
|
|
|
11
11
|
* the browser, and there is no CORS/CSP surface.
|
|
12
12
|
*/
|
|
13
13
|
interface RelayOptions {
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Private ingest key (autter_rt_…). Keep it in an env var. Default:
|
|
16
|
+
* AUTTER_RUNTIME_KEY. Without one the relay answers 500 and warns once
|
|
17
|
+
* at startup, instead of forwarding with "Bearer undefined".
|
|
18
|
+
*/
|
|
19
|
+
apiKey?: string;
|
|
16
20
|
/** Ingester base URL. Default: https://otlp.autter.dev */
|
|
17
21
|
endpoint?: string;
|
|
18
22
|
/** Max accepted request body. Default 64 KB. */
|
|
@@ -75,6 +79,22 @@ interface RelayOptions {
|
|
|
75
79
|
compatCheck?: boolean;
|
|
76
80
|
}
|
|
77
81
|
declare function sanitizeBrowserPayload(raw: unknown, redactor?: Redactor$1): object | null;
|
|
82
|
+
/** Why a browser payload was refused: the field and what was wrong. Same
|
|
83
|
+
* shape as the ingester's `issues` (a path into the payload, a message). */
|
|
84
|
+
interface RelayPayloadIssue {
|
|
85
|
+
path: Array<string | number>;
|
|
86
|
+
message: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Validate and sanitise a browser payload. On failure, the first few
|
|
90
|
+
* problems with their field paths (`["events", 3, "type"]`), so a 400 from
|
|
91
|
+
* the relay says what to fix instead of only "invalid payload".
|
|
92
|
+
*/
|
|
93
|
+
declare function checkBrowserPayload(raw: unknown, redactor?: Redactor$1): {
|
|
94
|
+
payload: object;
|
|
95
|
+
} | {
|
|
96
|
+
issues: RelayPayloadIssue[];
|
|
97
|
+
};
|
|
78
98
|
/**
|
|
79
99
|
* Fetch-style handler (Next.js App Router route, Remix, Hono, Bun, Deno):
|
|
80
100
|
*
|
|
@@ -259,8 +279,11 @@ type RuntimeContextHandle = typeof runtimeContext;
|
|
|
259
279
|
interface AutterServerOptions {
|
|
260
280
|
/** Structured logs and completed operation summaries. */
|
|
261
281
|
logging?: RuntimeLoggingOptions;
|
|
262
|
-
/**
|
|
263
|
-
|
|
282
|
+
/**
|
|
283
|
+
* Private ingest key (autter_rt_…). Default: AUTTER_RUNTIME_KEY. Without
|
|
284
|
+
* one nothing is sent and one warning says so at startup.
|
|
285
|
+
*/
|
|
286
|
+
apiKey?: string;
|
|
264
287
|
/** Ingester base URL. Default: https://otlp.autter.dev */
|
|
265
288
|
endpoint?: string;
|
|
266
289
|
service: string;
|
|
@@ -337,6 +360,18 @@ interface AutterServerOptions {
|
|
|
337
360
|
* crashes the process. Default true.
|
|
338
361
|
*/
|
|
339
362
|
captureUnhandledRejections?: boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Express (4 and 5): report the error behind a 5xx response with no
|
|
365
|
+
* setup. Every error a handler throws, rejects with (Express 5) or passes
|
|
366
|
+
* to `next(err)`, in any router, is noted on its request; when the
|
|
367
|
+
* response ends with a 5xx, the error is recorded on the request span
|
|
368
|
+
* with its type, message and stack, once (an error `autterErrorHandler`
|
|
369
|
+
* or `captureException` already reported is skipped). Errors answered
|
|
370
|
+
* with a 4xx are not reported here. Express's own behaviour is
|
|
371
|
+
* unchanged. Default true; false leaves Express errors to
|
|
372
|
+
* `autterErrorHandler()`.
|
|
373
|
+
*/
|
|
374
|
+
captureExpressErrors?: boolean;
|
|
340
375
|
/**
|
|
341
376
|
* Flush all exporters when the process exits (`beforeExit`, SIGINT,
|
|
342
377
|
* SIGTERM) so a forgotten `shutdown()` doesn't silently drop buffered
|
|
@@ -1021,11 +1056,42 @@ declare function fetchIngesterCompat(endpoint: string, options?: {
|
|
|
1021
1056
|
}>;
|
|
1022
1057
|
|
|
1023
1058
|
/**
|
|
1024
|
-
*
|
|
1025
|
-
*
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1059
|
+
* Where the path to an ingester breaks: DNS, TCP, TLS or HTTP. Used by
|
|
1060
|
+
* `doctor` when the ingester can't be reached and as the first step of
|
|
1061
|
+
* `verify`. "Timed out" alone (what an exporter reports) can mean a
|
|
1062
|
+
* firewall dropping packets, an IPv6 route that goes nowhere, a proxy
|
|
1063
|
+
* that is required but not used, or TLS interception; each step below
|
|
1064
|
+
* narrows it to one.
|
|
1065
|
+
*/
|
|
1066
|
+
type ConnectivityStepName = "dns" | "tcp" | "tls" | "http";
|
|
1067
|
+
interface ConnectivityStep {
|
|
1068
|
+
step: ConnectivityStepName;
|
|
1069
|
+
ok: boolean;
|
|
1070
|
+
ms: number;
|
|
1071
|
+
detail: string;
|
|
1072
|
+
}
|
|
1073
|
+
interface ConnectivityReport {
|
|
1074
|
+
ok: boolean;
|
|
1075
|
+
host: string;
|
|
1076
|
+
port: number;
|
|
1077
|
+
steps: ConnectivityStep[];
|
|
1078
|
+
/** The first failed step, with what to try. */
|
|
1079
|
+
failed?: {
|
|
1080
|
+
step: ConnectivityStepName;
|
|
1081
|
+
detail: string;
|
|
1082
|
+
hint: string;
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* `npx @autter/runtime-node doctor` — one-shot setup report: installed
|
|
1088
|
+
* Autter SDK versions against the ingester's (version skew), which features
|
|
1089
|
+
* are active, whether the ingester can store anything right now (`/healthz`),
|
|
1090
|
+
* and the ingest key ("not checked" when none is given). When the ingester
|
|
1091
|
+
* can't be reached it says where the path breaks (DNS, TCP, TLS, HTTP).
|
|
1092
|
+
* Exit codes: 0 everything checked is fine, 1 a mismatch, rejected key or
|
|
1093
|
+
* unready storage, 2 the ingester could not be reached or identified.
|
|
1094
|
+
* `verify` goes further: it sends a test event and reads it back.
|
|
1029
1095
|
*/
|
|
1030
1096
|
interface DoctorOptions {
|
|
1031
1097
|
endpoint?: string;
|
|
@@ -1040,17 +1106,92 @@ interface DoctorReport {
|
|
|
1040
1106
|
sdks: SdkIdentity[];
|
|
1041
1107
|
ingester: IngesterCompatInfo | null;
|
|
1042
1108
|
ingesterError?: string;
|
|
1043
|
-
|
|
1109
|
+
/** Always set: "not_checked" when no key was given. */
|
|
1110
|
+
key: "accepted" | "rejected" | "client_key" | "storage_unavailable" | "unverified" | "unknown" | "not_checked";
|
|
1111
|
+
/** The ingester's reason when it refused the key. */
|
|
1112
|
+
keyDetail?: string;
|
|
1113
|
+
/** `/healthz`: can the ingester store what it is sent right now? */
|
|
1114
|
+
storage: StorageReport | null;
|
|
1115
|
+
/** "ok" = active: the SDK sends it and the ingester stores it. */
|
|
1044
1116
|
features: Array<{
|
|
1045
1117
|
id: string;
|
|
1046
1118
|
title: string;
|
|
1047
1119
|
status: "ok" | "incompatible" | "unknown";
|
|
1048
1120
|
}>;
|
|
1121
|
+
/** Each SDK against the ingester: who is behind, and on what. */
|
|
1122
|
+
skew: SkewLine[];
|
|
1049
1123
|
issues: CompatIssue[];
|
|
1124
|
+
/** Only when the ingester could not be reached. */
|
|
1125
|
+
connectivity?: ConnectivityReport;
|
|
1050
1126
|
exitCode: 0 | 1 | 2;
|
|
1051
1127
|
}
|
|
1128
|
+
interface StorageReport {
|
|
1129
|
+
/** up | down | auth_failed | schema_missing | unconfigured | unknown */
|
|
1130
|
+
state: string;
|
|
1131
|
+
ok: boolean;
|
|
1132
|
+
/** False for ingesters before 1.12, whose /healthz only pinged ClickHouse. */
|
|
1133
|
+
writeChecked: boolean;
|
|
1134
|
+
detail: string;
|
|
1135
|
+
}
|
|
1136
|
+
interface SkewLine {
|
|
1137
|
+
sdk: string;
|
|
1138
|
+
version: string;
|
|
1139
|
+
/** "in_sync", "ingester_behind" (features it can't store), "sdk_behind" (features it doesn't send yet). */
|
|
1140
|
+
status: "in_sync" | "ingester_behind" | "sdk_behind" | "unknown";
|
|
1141
|
+
detail: string;
|
|
1142
|
+
}
|
|
1052
1143
|
declare function runDoctor(options?: DoctorOptions): Promise<DoctorReport>;
|
|
1053
1144
|
|
|
1145
|
+
/**
|
|
1146
|
+
* `npx @autter/runtime-node verify` — send one tagged test event through the
|
|
1147
|
+
* real path and read it back, step by step, stopping at the first step
|
|
1148
|
+
* that fails and naming it:
|
|
1149
|
+
*
|
|
1150
|
+
* key → network → ingester → storage → auth → ingest → stored → trace → release → logs
|
|
1151
|
+
*
|
|
1152
|
+
* The test request carries `autter.verify.id` on its resource, so the
|
|
1153
|
+
* ingester stores it (that is what is checked) but never rolls it up or
|
|
1154
|
+
* forwards it to the sink: it never opens an issue or moves a dashboard.
|
|
1155
|
+
* Against an ingester without `/v1/verify` (older than this feature) only
|
|
1156
|
+
* a plain span is sent, and "stored" is reported as not checked.
|
|
1157
|
+
*
|
|
1158
|
+
* Exit codes: 0 every check passed, 1 a step failed, 2 the ingester could
|
|
1159
|
+
* not be reached.
|
|
1160
|
+
*/
|
|
1161
|
+
type VerifyStepName = "key" | "network" | "ingester" | "storage" | "auth" | "ingest" | "stored" | "trace" | "release" | "logs";
|
|
1162
|
+
interface VerifyStep {
|
|
1163
|
+
step: VerifyStepName;
|
|
1164
|
+
status: "pass" | "fail" | "warn" | "skip";
|
|
1165
|
+
detail: string;
|
|
1166
|
+
/** On failure: what to do. */
|
|
1167
|
+
fix?: string;
|
|
1168
|
+
}
|
|
1169
|
+
interface VerifyReport {
|
|
1170
|
+
endpoint: string;
|
|
1171
|
+
service: string;
|
|
1172
|
+
environment: string;
|
|
1173
|
+
release: string | null;
|
|
1174
|
+
traceId: string;
|
|
1175
|
+
steps: VerifyStep[];
|
|
1176
|
+
firstFailure: VerifyStep | null;
|
|
1177
|
+
exitCode: 0 | 1 | 2;
|
|
1178
|
+
}
|
|
1179
|
+
interface VerifyOptions {
|
|
1180
|
+
endpoint?: string;
|
|
1181
|
+
key?: string;
|
|
1182
|
+
service?: string;
|
|
1183
|
+
environment?: string;
|
|
1184
|
+
release?: string;
|
|
1185
|
+
/** How long to wait for the test event to be stored. Default 20 s. */
|
|
1186
|
+
waitMs?: number;
|
|
1187
|
+
timeoutMs?: number;
|
|
1188
|
+
json?: boolean;
|
|
1189
|
+
cwd?: string;
|
|
1190
|
+
/** Test hook: the poll interval. */
|
|
1191
|
+
pollMs?: number;
|
|
1192
|
+
}
|
|
1193
|
+
declare function runVerify(options?: VerifyOptions, env?: NodeJS.ProcessEnv): Promise<VerifyReport>;
|
|
1194
|
+
|
|
1054
1195
|
/**
|
|
1055
1196
|
* Record a step (type "custom" unless you say otherwise) on the current
|
|
1056
1197
|
* request. The next exception captured in it carries the last 30. Message
|
|
@@ -1060,4 +1201,4 @@ declare function runDoctor(options?: DoctorOptions): Promise<DoctorReport>;
|
|
|
1060
1201
|
*/
|
|
1061
1202
|
declare function addBreadcrumb(input: BreadcrumbInput): void;
|
|
1062
1203
|
|
|
1063
|
-
export { type AutoFlushHandle, type AutoFlushOptions, type AutterErrorHandlerOptions, type AutterErrorResponseOptions, type AutterLogging, type AutterLoggingOptions, type AutterRequestsOptions, type AutterServer, type AutterServerOptions, type AutterSeverity, BreadcrumbInput, COMPAT_MANIFEST, CaptureLoggedErrorsOption, type CompatIssue, type DoctorOptions, type DoctorReport, FileSinkOptions, type FlushTarget, INGESTER_VERSION_HEADER, type IngesterCompatInfo, type InstrumentLlmOptions, type LlmCallHandle, type LlmCallInfo, type LlmUsage, RedactOptions, type RelayOptions, RuntimeCarrier, type RuntimeContextHandle, type RuntimeEnrichContext, type RuntimeEnrichEvent, type RuntimeEnricher, RuntimeLogContext, RuntimeLogLevel, type RuntimeLoggingOptions, type RuntimeOperation, RuntimeOperationKind, type RuntimeOperationOptions, RuntimeOutcome, type RuntimeRequestOptions, RuntimeSink, SDK_IDENTITY, type SafeCapture, type SdkIdentity, type TrackedLlmCall, type UnhandledRejectionsMode, addBreadcrumb, autterErrorHandler, autterErrorResponse, autterFastify, autterFastifyErrors, autterKoa, autterRequests, captureException, captureMessage, captureRequestError, createBrowserRelayFetchHandler, createBrowserRelayHandler, createRuntimeLogger, emitLlmSelftestTrace, enrichDeployment, enrichEdgeGeo, enrichRequestSize, enrichUserAgent, evaluateCompat, fetchIngesterCompat, flushRuntimeLogs, initAutterLogging, initAutterServer, installAutterAutoFlush, instrumentLlmClient, makeSafeCapture, reportOutcome, runDoctor, runInBackground, runtimeContext, runtimeLogStats, runtimeLogger, sanitizeBrowserPayload, startCaughtExceptionSampler, trackLlmCall, unhandledRejectionsMode, withLlmCall, withProcessSpan, withRuntimeOperation, withRuntimeRequest };
|
|
1204
|
+
export { type AutoFlushHandle, type AutoFlushOptions, type AutterErrorHandlerOptions, type AutterErrorResponseOptions, type AutterLogging, type AutterLoggingOptions, type AutterRequestsOptions, type AutterServer, type AutterServerOptions, type AutterSeverity, BreadcrumbInput, COMPAT_MANIFEST, CaptureLoggedErrorsOption, type CompatIssue, type DoctorOptions, type DoctorReport, FileSinkOptions, type FlushTarget, INGESTER_VERSION_HEADER, type IngesterCompatInfo, type InstrumentLlmOptions, type LlmCallHandle, type LlmCallInfo, type LlmUsage, RedactOptions, type RelayOptions, type RelayPayloadIssue, RuntimeCarrier, type RuntimeContextHandle, type RuntimeEnrichContext, type RuntimeEnrichEvent, type RuntimeEnricher, RuntimeLogContext, RuntimeLogLevel, type RuntimeLoggingOptions, type RuntimeOperation, RuntimeOperationKind, type RuntimeOperationOptions, RuntimeOutcome, type RuntimeRequestOptions, RuntimeSink, SDK_IDENTITY, type SafeCapture, type SdkIdentity, type TrackedLlmCall, type UnhandledRejectionsMode, type VerifyOptions, type VerifyReport, type VerifyStep, addBreadcrumb, autterErrorHandler, autterErrorResponse, autterFastify, autterFastifyErrors, autterKoa, autterRequests, captureException, captureMessage, captureRequestError, checkBrowserPayload, createBrowserRelayFetchHandler, createBrowserRelayHandler, createRuntimeLogger, emitLlmSelftestTrace, enrichDeployment, enrichEdgeGeo, enrichRequestSize, enrichUserAgent, evaluateCompat, fetchIngesterCompat, flushRuntimeLogs, initAutterLogging, initAutterServer, installAutterAutoFlush, instrumentLlmClient, makeSafeCapture, reportOutcome, runDoctor, runInBackground, runVerify, runtimeContext, runtimeLogStats, runtimeLogger, sanitizeBrowserPayload, startCaughtExceptionSampler, trackLlmCall, unhandledRejectionsMode, withLlmCall, withProcessSpan, withRuntimeOperation, withRuntimeRequest };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { b as RedactOptions, c as Redactor$1, d as RuntimeLogLevel, e as RuntimeOperationKind, f as RuntimeSink, F as FileSinkOptions, g as RuntimeLogContext, a as RuntimeOutcome, h as RuntimeCarrier, I as IgnoreErrorPattern, i as CaptureLoggedErrorsOption, B as BreadcrumbInput } from './sinks-
|
|
3
|
-
export { j as Breadcrumb, k as BreadcrumbLevel, l as BreadcrumbType, n as CODE_PATTERN, o as ClientErrorBody, p as ConsoleSinkOptions, L as LoggedErrorSource, O as OtlpSinkOptions, q as RuntimeError, r as RuntimeErrorCatalog, s as RuntimeErrorDefinition, t as RuntimeErrorExtras, u as RuntimeErrorFactory, v as RuntimeErrorLike, w as RuntimeErrorOptions, R as RuntimeEvent, x as RuntimeLogContextValue, y as RuntimeSinkContext, z as consoleSink, A as defineRuntimeErrors, D as errorAttributes, E as fileSink, G as isRuntimeErrorLike, H as otlpSink, J as redactAttributes, K as redactText, N as toClientError } from './sinks-
|
|
2
|
+
import { b as RedactOptions, c as Redactor$1, d as RuntimeLogLevel, e as RuntimeOperationKind, f as RuntimeSink, F as FileSinkOptions, g as RuntimeLogContext, a as RuntimeOutcome, h as RuntimeCarrier, I as IgnoreErrorPattern, i as CaptureLoggedErrorsOption, B as BreadcrumbInput } from './sinks-BfUoE96B.js';
|
|
3
|
+
export { j as Breadcrumb, k as BreadcrumbLevel, l as BreadcrumbType, n as CODE_PATTERN, o as ClientErrorBody, p as ConsoleSinkOptions, L as LoggedErrorSource, O as OtlpSinkOptions, q as RuntimeError, r as RuntimeErrorCatalog, s as RuntimeErrorDefinition, t as RuntimeErrorExtras, u as RuntimeErrorFactory, v as RuntimeErrorLike, w as RuntimeErrorOptions, R as RuntimeEvent, x as RuntimeLogContextValue, y as RuntimeSinkContext, z as consoleSink, A as defineRuntimeErrors, D as errorAttributes, E as fileSink, G as isRuntimeErrorLike, H as otlpSink, J as redactAttributes, K as redactText, N as toClientError } from './sinks-BfUoE96B.js';
|
|
4
4
|
import { Attributes } from '@opentelemetry/api';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -11,8 +11,12 @@ import { Attributes } from '@opentelemetry/api';
|
|
|
11
11
|
* the browser, and there is no CORS/CSP surface.
|
|
12
12
|
*/
|
|
13
13
|
interface RelayOptions {
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Private ingest key (autter_rt_…). Keep it in an env var. Default:
|
|
16
|
+
* AUTTER_RUNTIME_KEY. Without one the relay answers 500 and warns once
|
|
17
|
+
* at startup, instead of forwarding with "Bearer undefined".
|
|
18
|
+
*/
|
|
19
|
+
apiKey?: string;
|
|
16
20
|
/** Ingester base URL. Default: https://otlp.autter.dev */
|
|
17
21
|
endpoint?: string;
|
|
18
22
|
/** Max accepted request body. Default 64 KB. */
|
|
@@ -75,6 +79,22 @@ interface RelayOptions {
|
|
|
75
79
|
compatCheck?: boolean;
|
|
76
80
|
}
|
|
77
81
|
declare function sanitizeBrowserPayload(raw: unknown, redactor?: Redactor$1): object | null;
|
|
82
|
+
/** Why a browser payload was refused: the field and what was wrong. Same
|
|
83
|
+
* shape as the ingester's `issues` (a path into the payload, a message). */
|
|
84
|
+
interface RelayPayloadIssue {
|
|
85
|
+
path: Array<string | number>;
|
|
86
|
+
message: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Validate and sanitise a browser payload. On failure, the first few
|
|
90
|
+
* problems with their field paths (`["events", 3, "type"]`), so a 400 from
|
|
91
|
+
* the relay says what to fix instead of only "invalid payload".
|
|
92
|
+
*/
|
|
93
|
+
declare function checkBrowserPayload(raw: unknown, redactor?: Redactor$1): {
|
|
94
|
+
payload: object;
|
|
95
|
+
} | {
|
|
96
|
+
issues: RelayPayloadIssue[];
|
|
97
|
+
};
|
|
78
98
|
/**
|
|
79
99
|
* Fetch-style handler (Next.js App Router route, Remix, Hono, Bun, Deno):
|
|
80
100
|
*
|
|
@@ -259,8 +279,11 @@ type RuntimeContextHandle = typeof runtimeContext;
|
|
|
259
279
|
interface AutterServerOptions {
|
|
260
280
|
/** Structured logs and completed operation summaries. */
|
|
261
281
|
logging?: RuntimeLoggingOptions;
|
|
262
|
-
/**
|
|
263
|
-
|
|
282
|
+
/**
|
|
283
|
+
* Private ingest key (autter_rt_…). Default: AUTTER_RUNTIME_KEY. Without
|
|
284
|
+
* one nothing is sent and one warning says so at startup.
|
|
285
|
+
*/
|
|
286
|
+
apiKey?: string;
|
|
264
287
|
/** Ingester base URL. Default: https://otlp.autter.dev */
|
|
265
288
|
endpoint?: string;
|
|
266
289
|
service: string;
|
|
@@ -337,6 +360,18 @@ interface AutterServerOptions {
|
|
|
337
360
|
* crashes the process. Default true.
|
|
338
361
|
*/
|
|
339
362
|
captureUnhandledRejections?: boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Express (4 and 5): report the error behind a 5xx response with no
|
|
365
|
+
* setup. Every error a handler throws, rejects with (Express 5) or passes
|
|
366
|
+
* to `next(err)`, in any router, is noted on its request; when the
|
|
367
|
+
* response ends with a 5xx, the error is recorded on the request span
|
|
368
|
+
* with its type, message and stack, once (an error `autterErrorHandler`
|
|
369
|
+
* or `captureException` already reported is skipped). Errors answered
|
|
370
|
+
* with a 4xx are not reported here. Express's own behaviour is
|
|
371
|
+
* unchanged. Default true; false leaves Express errors to
|
|
372
|
+
* `autterErrorHandler()`.
|
|
373
|
+
*/
|
|
374
|
+
captureExpressErrors?: boolean;
|
|
340
375
|
/**
|
|
341
376
|
* Flush all exporters when the process exits (`beforeExit`, SIGINT,
|
|
342
377
|
* SIGTERM) so a forgotten `shutdown()` doesn't silently drop buffered
|
|
@@ -1021,11 +1056,42 @@ declare function fetchIngesterCompat(endpoint: string, options?: {
|
|
|
1021
1056
|
}>;
|
|
1022
1057
|
|
|
1023
1058
|
/**
|
|
1024
|
-
*
|
|
1025
|
-
*
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1059
|
+
* Where the path to an ingester breaks: DNS, TCP, TLS or HTTP. Used by
|
|
1060
|
+
* `doctor` when the ingester can't be reached and as the first step of
|
|
1061
|
+
* `verify`. "Timed out" alone (what an exporter reports) can mean a
|
|
1062
|
+
* firewall dropping packets, an IPv6 route that goes nowhere, a proxy
|
|
1063
|
+
* that is required but not used, or TLS interception; each step below
|
|
1064
|
+
* narrows it to one.
|
|
1065
|
+
*/
|
|
1066
|
+
type ConnectivityStepName = "dns" | "tcp" | "tls" | "http";
|
|
1067
|
+
interface ConnectivityStep {
|
|
1068
|
+
step: ConnectivityStepName;
|
|
1069
|
+
ok: boolean;
|
|
1070
|
+
ms: number;
|
|
1071
|
+
detail: string;
|
|
1072
|
+
}
|
|
1073
|
+
interface ConnectivityReport {
|
|
1074
|
+
ok: boolean;
|
|
1075
|
+
host: string;
|
|
1076
|
+
port: number;
|
|
1077
|
+
steps: ConnectivityStep[];
|
|
1078
|
+
/** The first failed step, with what to try. */
|
|
1079
|
+
failed?: {
|
|
1080
|
+
step: ConnectivityStepName;
|
|
1081
|
+
detail: string;
|
|
1082
|
+
hint: string;
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* `npx @autter/runtime-node doctor` — one-shot setup report: installed
|
|
1088
|
+
* Autter SDK versions against the ingester's (version skew), which features
|
|
1089
|
+
* are active, whether the ingester can store anything right now (`/healthz`),
|
|
1090
|
+
* and the ingest key ("not checked" when none is given). When the ingester
|
|
1091
|
+
* can't be reached it says where the path breaks (DNS, TCP, TLS, HTTP).
|
|
1092
|
+
* Exit codes: 0 everything checked is fine, 1 a mismatch, rejected key or
|
|
1093
|
+
* unready storage, 2 the ingester could not be reached or identified.
|
|
1094
|
+
* `verify` goes further: it sends a test event and reads it back.
|
|
1029
1095
|
*/
|
|
1030
1096
|
interface DoctorOptions {
|
|
1031
1097
|
endpoint?: string;
|
|
@@ -1040,17 +1106,92 @@ interface DoctorReport {
|
|
|
1040
1106
|
sdks: SdkIdentity[];
|
|
1041
1107
|
ingester: IngesterCompatInfo | null;
|
|
1042
1108
|
ingesterError?: string;
|
|
1043
|
-
|
|
1109
|
+
/** Always set: "not_checked" when no key was given. */
|
|
1110
|
+
key: "accepted" | "rejected" | "client_key" | "storage_unavailable" | "unverified" | "unknown" | "not_checked";
|
|
1111
|
+
/** The ingester's reason when it refused the key. */
|
|
1112
|
+
keyDetail?: string;
|
|
1113
|
+
/** `/healthz`: can the ingester store what it is sent right now? */
|
|
1114
|
+
storage: StorageReport | null;
|
|
1115
|
+
/** "ok" = active: the SDK sends it and the ingester stores it. */
|
|
1044
1116
|
features: Array<{
|
|
1045
1117
|
id: string;
|
|
1046
1118
|
title: string;
|
|
1047
1119
|
status: "ok" | "incompatible" | "unknown";
|
|
1048
1120
|
}>;
|
|
1121
|
+
/** Each SDK against the ingester: who is behind, and on what. */
|
|
1122
|
+
skew: SkewLine[];
|
|
1049
1123
|
issues: CompatIssue[];
|
|
1124
|
+
/** Only when the ingester could not be reached. */
|
|
1125
|
+
connectivity?: ConnectivityReport;
|
|
1050
1126
|
exitCode: 0 | 1 | 2;
|
|
1051
1127
|
}
|
|
1128
|
+
interface StorageReport {
|
|
1129
|
+
/** up | down | auth_failed | schema_missing | unconfigured | unknown */
|
|
1130
|
+
state: string;
|
|
1131
|
+
ok: boolean;
|
|
1132
|
+
/** False for ingesters before 1.12, whose /healthz only pinged ClickHouse. */
|
|
1133
|
+
writeChecked: boolean;
|
|
1134
|
+
detail: string;
|
|
1135
|
+
}
|
|
1136
|
+
interface SkewLine {
|
|
1137
|
+
sdk: string;
|
|
1138
|
+
version: string;
|
|
1139
|
+
/** "in_sync", "ingester_behind" (features it can't store), "sdk_behind" (features it doesn't send yet). */
|
|
1140
|
+
status: "in_sync" | "ingester_behind" | "sdk_behind" | "unknown";
|
|
1141
|
+
detail: string;
|
|
1142
|
+
}
|
|
1052
1143
|
declare function runDoctor(options?: DoctorOptions): Promise<DoctorReport>;
|
|
1053
1144
|
|
|
1145
|
+
/**
|
|
1146
|
+
* `npx @autter/runtime-node verify` — send one tagged test event through the
|
|
1147
|
+
* real path and read it back, step by step, stopping at the first step
|
|
1148
|
+
* that fails and naming it:
|
|
1149
|
+
*
|
|
1150
|
+
* key → network → ingester → storage → auth → ingest → stored → trace → release → logs
|
|
1151
|
+
*
|
|
1152
|
+
* The test request carries `autter.verify.id` on its resource, so the
|
|
1153
|
+
* ingester stores it (that is what is checked) but never rolls it up or
|
|
1154
|
+
* forwards it to the sink: it never opens an issue or moves a dashboard.
|
|
1155
|
+
* Against an ingester without `/v1/verify` (older than this feature) only
|
|
1156
|
+
* a plain span is sent, and "stored" is reported as not checked.
|
|
1157
|
+
*
|
|
1158
|
+
* Exit codes: 0 every check passed, 1 a step failed, 2 the ingester could
|
|
1159
|
+
* not be reached.
|
|
1160
|
+
*/
|
|
1161
|
+
type VerifyStepName = "key" | "network" | "ingester" | "storage" | "auth" | "ingest" | "stored" | "trace" | "release" | "logs";
|
|
1162
|
+
interface VerifyStep {
|
|
1163
|
+
step: VerifyStepName;
|
|
1164
|
+
status: "pass" | "fail" | "warn" | "skip";
|
|
1165
|
+
detail: string;
|
|
1166
|
+
/** On failure: what to do. */
|
|
1167
|
+
fix?: string;
|
|
1168
|
+
}
|
|
1169
|
+
interface VerifyReport {
|
|
1170
|
+
endpoint: string;
|
|
1171
|
+
service: string;
|
|
1172
|
+
environment: string;
|
|
1173
|
+
release: string | null;
|
|
1174
|
+
traceId: string;
|
|
1175
|
+
steps: VerifyStep[];
|
|
1176
|
+
firstFailure: VerifyStep | null;
|
|
1177
|
+
exitCode: 0 | 1 | 2;
|
|
1178
|
+
}
|
|
1179
|
+
interface VerifyOptions {
|
|
1180
|
+
endpoint?: string;
|
|
1181
|
+
key?: string;
|
|
1182
|
+
service?: string;
|
|
1183
|
+
environment?: string;
|
|
1184
|
+
release?: string;
|
|
1185
|
+
/** How long to wait for the test event to be stored. Default 20 s. */
|
|
1186
|
+
waitMs?: number;
|
|
1187
|
+
timeoutMs?: number;
|
|
1188
|
+
json?: boolean;
|
|
1189
|
+
cwd?: string;
|
|
1190
|
+
/** Test hook: the poll interval. */
|
|
1191
|
+
pollMs?: number;
|
|
1192
|
+
}
|
|
1193
|
+
declare function runVerify(options?: VerifyOptions, env?: NodeJS.ProcessEnv): Promise<VerifyReport>;
|
|
1194
|
+
|
|
1054
1195
|
/**
|
|
1055
1196
|
* Record a step (type "custom" unless you say otherwise) on the current
|
|
1056
1197
|
* request. The next exception captured in it carries the last 30. Message
|
|
@@ -1060,4 +1201,4 @@ declare function runDoctor(options?: DoctorOptions): Promise<DoctorReport>;
|
|
|
1060
1201
|
*/
|
|
1061
1202
|
declare function addBreadcrumb(input: BreadcrumbInput): void;
|
|
1062
1203
|
|
|
1063
|
-
export { type AutoFlushHandle, type AutoFlushOptions, type AutterErrorHandlerOptions, type AutterErrorResponseOptions, type AutterLogging, type AutterLoggingOptions, type AutterRequestsOptions, type AutterServer, type AutterServerOptions, type AutterSeverity, BreadcrumbInput, COMPAT_MANIFEST, CaptureLoggedErrorsOption, type CompatIssue, type DoctorOptions, type DoctorReport, FileSinkOptions, type FlushTarget, INGESTER_VERSION_HEADER, type IngesterCompatInfo, type InstrumentLlmOptions, type LlmCallHandle, type LlmCallInfo, type LlmUsage, RedactOptions, type RelayOptions, RuntimeCarrier, type RuntimeContextHandle, type RuntimeEnrichContext, type RuntimeEnrichEvent, type RuntimeEnricher, RuntimeLogContext, RuntimeLogLevel, type RuntimeLoggingOptions, type RuntimeOperation, RuntimeOperationKind, type RuntimeOperationOptions, RuntimeOutcome, type RuntimeRequestOptions, RuntimeSink, SDK_IDENTITY, type SafeCapture, type SdkIdentity, type TrackedLlmCall, type UnhandledRejectionsMode, addBreadcrumb, autterErrorHandler, autterErrorResponse, autterFastify, autterFastifyErrors, autterKoa, autterRequests, captureException, captureMessage, captureRequestError, createBrowserRelayFetchHandler, createBrowserRelayHandler, createRuntimeLogger, emitLlmSelftestTrace, enrichDeployment, enrichEdgeGeo, enrichRequestSize, enrichUserAgent, evaluateCompat, fetchIngesterCompat, flushRuntimeLogs, initAutterLogging, initAutterServer, installAutterAutoFlush, instrumentLlmClient, makeSafeCapture, reportOutcome, runDoctor, runInBackground, runtimeContext, runtimeLogStats, runtimeLogger, sanitizeBrowserPayload, startCaughtExceptionSampler, trackLlmCall, unhandledRejectionsMode, withLlmCall, withProcessSpan, withRuntimeOperation, withRuntimeRequest };
|
|
1204
|
+
export { type AutoFlushHandle, type AutoFlushOptions, type AutterErrorHandlerOptions, type AutterErrorResponseOptions, type AutterLogging, type AutterLoggingOptions, type AutterRequestsOptions, type AutterServer, type AutterServerOptions, type AutterSeverity, BreadcrumbInput, COMPAT_MANIFEST, CaptureLoggedErrorsOption, type CompatIssue, type DoctorOptions, type DoctorReport, FileSinkOptions, type FlushTarget, INGESTER_VERSION_HEADER, type IngesterCompatInfo, type InstrumentLlmOptions, type LlmCallHandle, type LlmCallInfo, type LlmUsage, RedactOptions, type RelayOptions, type RelayPayloadIssue, RuntimeCarrier, type RuntimeContextHandle, type RuntimeEnrichContext, type RuntimeEnrichEvent, type RuntimeEnricher, RuntimeLogContext, RuntimeLogLevel, type RuntimeLoggingOptions, type RuntimeOperation, RuntimeOperationKind, type RuntimeOperationOptions, RuntimeOutcome, type RuntimeRequestOptions, RuntimeSink, SDK_IDENTITY, type SafeCapture, type SdkIdentity, type TrackedLlmCall, type UnhandledRejectionsMode, type VerifyOptions, type VerifyReport, type VerifyStep, addBreadcrumb, autterErrorHandler, autterErrorResponse, autterFastify, autterFastifyErrors, autterKoa, autterRequests, captureException, captureMessage, captureRequestError, checkBrowserPayload, createBrowserRelayFetchHandler, createBrowserRelayHandler, createRuntimeLogger, emitLlmSelftestTrace, enrichDeployment, enrichEdgeGeo, enrichRequestSize, enrichUserAgent, evaluateCompat, fetchIngesterCompat, flushRuntimeLogs, initAutterLogging, initAutterServer, installAutterAutoFlush, instrumentLlmClient, makeSafeCapture, reportOutcome, runDoctor, runInBackground, runVerify, runtimeContext, runtimeLogStats, runtimeLogger, sanitizeBrowserPayload, startCaughtExceptionSampler, trackLlmCall, unhandledRejectionsMode, withLlmCall, withProcessSpan, withRuntimeOperation, withRuntimeRequest };
|