@sypnia/telemetry 0.0.0-stage → 0.3.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.
@@ -0,0 +1,298 @@
1
+ import { serializePatterns, CONFIG_ENV } from '../chunk-WUAOTFVV.js';
2
+ import { cutChars, baseUrl } from '../chunk-P5DK2OU7.js';
3
+ import { execFileSync } from 'child_process';
4
+ import { existsSync, readdirSync } from 'fs';
5
+ import { join, resolve, relative, sep, dirname } from 'path';
6
+ import { createHash } from 'crypto';
7
+ import { readFile, stat, readdir, rm } from 'fs/promises';
8
+
9
+ var DEFAULT_EXTENSIONS = ["tsx", "ts", "jsx", "js"];
10
+ var PAGES_SPECIAL = /* @__PURE__ */ new Set(["_app", "_document", "_error", "_middleware"]);
11
+ function entries(dir) {
12
+ try {
13
+ return readdirSync(dir, { withFileTypes: true }).map((entry) => ({ name: entry.name, isDirectory: entry.isDirectory() }));
14
+ } catch {
15
+ return [];
16
+ }
17
+ }
18
+ function routeOfSegments(segments) {
19
+ return `/${segments.join("/")}`;
20
+ }
21
+ function scanApp(dir, segments, extensions, out) {
22
+ for (const entry of entries(dir)) {
23
+ if (entry.isDirectory) {
24
+ const name = entry.name;
25
+ if (name.startsWith("_") || name.startsWith("@") || /^\(\.{1,3}\)/.test(name)) continue;
26
+ const next = /^\(.+\)$/.test(name) ? segments : [...segments, name];
27
+ scanApp(join(dir, name), next, extensions, out);
28
+ continue;
29
+ }
30
+ const match = /^(page|route)\.([a-z]+)$/.exec(entry.name);
31
+ if (match && extensions.includes(match[2] ?? "")) out.add(routeOfSegments(segments));
32
+ }
33
+ }
34
+ function scanPages(dir, segments, extensions, out) {
35
+ for (const entry of entries(dir)) {
36
+ if (entry.isDirectory) {
37
+ scanPages(join(dir, entry.name), [...segments, entry.name], extensions, out);
38
+ continue;
39
+ }
40
+ const dot = entry.name.lastIndexOf(".");
41
+ if (dot < 0 || !extensions.includes(entry.name.slice(dot + 1))) continue;
42
+ const base = entry.name.slice(0, dot);
43
+ if (segments.length === 0 && PAGES_SPECIAL.has(base)) continue;
44
+ out.add(routeOfSegments(base === "index" ? segments : [...segments, base]));
45
+ }
46
+ }
47
+ function scanRoutes(projectDir, pageExtensions = DEFAULT_EXTENSIONS) {
48
+ const out = /* @__PURE__ */ new Set();
49
+ for (const root of ["", "src"]) {
50
+ const app = join(projectDir, root, "app");
51
+ const pages = join(projectDir, root, "pages");
52
+ if (existsSync(app)) scanApp(app, [], pageExtensions, out);
53
+ if (existsSync(pages)) scanPages(pages, [], pageExtensions, out);
54
+ }
55
+ return [...out].sort();
56
+ }
57
+ var FILES_PER_CALL = 2e3;
58
+ var UPLOAD_CONCURRENCY = 8;
59
+ async function filesUnder(folder, suffixes) {
60
+ const found = [];
61
+ let entries2;
62
+ try {
63
+ entries2 = await readdir(folder, { withFileTypes: true });
64
+ } catch {
65
+ return found;
66
+ }
67
+ for (const entry of entries2) {
68
+ const path = join(folder, entry.name);
69
+ if (entry.isDirectory()) found.push(...await filesUnder(path, suffixes));
70
+ else if (suffixes.some((suffix) => entry.name.endsWith(suffix))) found.push(path);
71
+ }
72
+ return found;
73
+ }
74
+ function sourceMappingUrlOf(code) {
75
+ const matches = [...code.matchAll(/\/\/[#@]\s*sourceMappingURL=([^\s'"]+)/g)];
76
+ const last = matches.at(-1)?.[1];
77
+ return last && !last.startsWith("data:") ? last : null;
78
+ }
79
+ async function chunkOfEachMap(staticDir) {
80
+ const owner = /* @__PURE__ */ new Map();
81
+ for (const chunk of await filesUnder(staticDir, [".js"])) {
82
+ let code;
83
+ try {
84
+ code = await readFile(chunk, "utf8");
85
+ } catch {
86
+ continue;
87
+ }
88
+ const ref = sourceMappingUrlOf(code);
89
+ if (!ref || /^[a-z]+:/i.test(ref)) continue;
90
+ owner.set(resolve(dirname(chunk), decodeURIComponent(ref.split(/[?#]/)[0] ?? "")), chunk);
91
+ }
92
+ return owner;
93
+ }
94
+ async function inPool(items, limit, work) {
95
+ let next = 0;
96
+ const runners = Array.from({ length: Math.min(limit, items.length) }, async () => {
97
+ while (next < items.length) await work(items[next++]);
98
+ });
99
+ await Promise.all(runners);
100
+ }
101
+ async function api(input, path, body) {
102
+ const send = input.fetch ?? fetch;
103
+ const response = await send(`${input.apiUrl.replace(/\/+$/, "")}/v1${path}`, {
104
+ method: "POST",
105
+ headers: { authorization: `Bearer ${input.token}`, "content-type": "application/json" },
106
+ body: JSON.stringify(body)
107
+ });
108
+ if (!response.ok) {
109
+ let code = "";
110
+ try {
111
+ code = (await response.json()).error?.code ?? "";
112
+ } catch {
113
+ }
114
+ throw new Error(`${path.startsWith("/releases/") ? "upload links" : "release"} refused: ${response.status}${code ? ` ${code}` : ""}`);
115
+ }
116
+ return await response.json();
117
+ }
118
+ function notUploaded(reason, removed) {
119
+ return `Sypnia: source maps not uploaded (${reason})${removed ? `, ${removed} removed from the build output.` : ""}`;
120
+ }
121
+ async function uploadSourceMaps(input) {
122
+ const print = input.print ?? ((line) => console.log(line));
123
+ const staticDir = resolve(input.projectDir, input.distDir, "static");
124
+ const maps = await filesUnder(staticDir, [".js.map"]).catch(() => []);
125
+ const remove = async () => {
126
+ if (!input.removeMaps) return 0;
127
+ let removed = 0;
128
+ for (const map of await filesUnder(staticDir, [".map"]).catch(() => maps)) {
129
+ try {
130
+ await rm(map);
131
+ removed++;
132
+ } catch {
133
+ }
134
+ }
135
+ return removed;
136
+ };
137
+ try {
138
+ if (!input.token) {
139
+ const removed2 = await remove();
140
+ print(notUploaded("SYPNIA_API_TOKEN is not set", removed2));
141
+ return;
142
+ }
143
+ if (!input.release) {
144
+ const removed2 = await remove();
145
+ print(notUploaded("no release: set SYPNIA_RELEASE", removed2));
146
+ return;
147
+ }
148
+ await api(input, "/releases", {
149
+ version: input.release,
150
+ environment: input.environment,
151
+ ...input.commit ? { commit: input.commit } : {}
152
+ });
153
+ const owners = await chunkOfEachMap(staticDir).catch(() => /* @__PURE__ */ new Map());
154
+ const files = await Promise.all(
155
+ maps.map(async (map) => {
156
+ const body = await readFile(map);
157
+ const chunk = owners.get(resolve(map));
158
+ const servedFrom = relative(staticDir, chunk ?? map.replace(/\.map$/, "")).split(sep).join("/");
159
+ return {
160
+ path: map,
161
+ url_path: `${input.basePath}/_next/static/${servedFrom}`,
162
+ map_size: (await stat(map)).size,
163
+ map_sha256: createHash("sha256").update(body).digest("hex")
164
+ };
165
+ })
166
+ );
167
+ let uploaded = 0;
168
+ let failed = 0;
169
+ for (let at = 0; at < files.length; at += FILES_PER_CALL) {
170
+ const chunk = files.slice(at, at + FILES_PER_CALL);
171
+ const answer = await api(input, `/releases/${encodeURIComponent(input.release)}/sourcemaps`, {
172
+ files: chunk.map(({ url_path, map_size, map_sha256 }) => ({ url_path, map_size, map_sha256 }))
173
+ });
174
+ uploaded += (answer.skipped ?? []).filter((item) => item.reason === "already_uploaded").length;
175
+ await inPool(answer.uploads ?? [], UPLOAD_CONCURRENCY, async (link) => {
176
+ const file = chunk.find((item) => item.url_path === link.url_path);
177
+ if (!file) return;
178
+ try {
179
+ const response = await (input.fetch ?? fetch)(link.upload_url, {
180
+ method: link.method ?? "PUT",
181
+ headers: link.headers ?? { "content-type": "application/json" },
182
+ body: await readFile(file.path)
183
+ });
184
+ if (response.ok) uploaded++;
185
+ else failed++;
186
+ } catch {
187
+ failed++;
188
+ }
189
+ });
190
+ }
191
+ const removed = await remove();
192
+ print(
193
+ `Sypnia: release ${input.release} registered, ${uploaded} source maps uploaded${failed ? ` (${failed} failed)` : ""}, ${removed} removed from the build output.`
194
+ );
195
+ } catch (error) {
196
+ const removed = await remove().catch(() => 0);
197
+ const reason = error instanceof Error ? error.message : String(error);
198
+ print(notUploaded(reason, removed));
199
+ }
200
+ }
201
+
202
+ // ../next/src/index.ts
203
+ var DEV_PHASE = "phase-development-server";
204
+ function env(name) {
205
+ const value = process.env[name];
206
+ return value && value.trim() ? value.trim() : void 0;
207
+ }
208
+ function git(args) {
209
+ try {
210
+ return execFileSync("git", args, { stdio: ["ignore", "pipe", "ignore"], encoding: "utf8" }).trim() || void 0;
211
+ } catch {
212
+ return void 0;
213
+ }
214
+ }
215
+ function isDev(phase) {
216
+ if (phase) return phase === DEV_PHASE;
217
+ return process.env.NODE_ENV === "development" || process.argv.includes("dev");
218
+ }
219
+ function resolveRelease(option) {
220
+ const release = option ?? env("SYPNIA_RELEASE") ?? env("VERCEL_GIT_COMMIT_SHA")?.slice(0, 7) ?? git(["rev-parse", "--short", "HEAD"]);
221
+ return release ? cutChars(release, 40) : null;
222
+ }
223
+ function resolveNextConfig(options, nextConfig, phase) {
224
+ const project = options.project ?? env("SYPNIA_PROJECT_KEY");
225
+ if (!project) return null;
226
+ const environment = options.environment ?? env("SYPNIA_ENVIRONMENT") ?? env("VERCEL_ENV") ?? (isDev(phase) ? "development" : "production");
227
+ return {
228
+ project,
229
+ endpoint: baseUrl(options.endpoint ?? env("SYPNIA_ENDPOINT")),
230
+ service: cutChars(options.service ?? env("SYPNIA_SERVICE") ?? "next", 80),
231
+ environment: cutChars(environment, 40),
232
+ release: resolveRelease(options.release),
233
+ debug: options.debug === true,
234
+ distDir: nextConfig.distDir ?? ".next",
235
+ basePath: nextConfig.basePath ?? "",
236
+ routes: scanRoutes(process.cwd(), nextConfig.pageExtensions),
237
+ server: serializeServer(options.server)
238
+ };
239
+ }
240
+ function serializeServer(server) {
241
+ if (!server) return {};
242
+ const out = {};
243
+ for (const [key, value] of Object.entries(server)) {
244
+ if (typeof value === "function") {
245
+ console.warn(`[sypnia] withSypnia: server.${key} is a function, which cannot pass from the build to the server; it is ignored`);
246
+ }
247
+ }
248
+ if (server.enabled !== void 0) out.enabled = server.enabled;
249
+ if (server.ignoreRoutes) out.ignoreRoutes = serializePatterns(server.ignoreRoutes);
250
+ if (server.allowRoutes) out.allowRoutes = serializePatterns(server.allowRoutes);
251
+ if (server.anonymousRoutes) out.anonymousRoutes = serializePatterns(server.anonymousRoutes);
252
+ if (server.captureDbErrors !== void 0) out.captureDbErrors = server.captureDbErrors;
253
+ if (server.capture) out.capture = server.capture;
254
+ if (server.propagate !== void 0) out.propagate = server.propagate;
255
+ if (server.slowRequestMs !== void 0) out.slowRequestMs = server.slowRequestMs;
256
+ if (server.flushBudgetMs !== void 0) out.flushBudgetMs = server.flushBudgetMs;
257
+ return out;
258
+ }
259
+ function apply(nextConfig, options, phase) {
260
+ const config = resolveNextConfig(options, nextConfig, phase);
261
+ if (!config) {
262
+ console.warn("[sypnia] off: no project (set SYPNIA_PROJECT_KEY or the option `project` of withSypnia)");
263
+ return nextConfig;
264
+ }
265
+ const uploading = options.sourceMaps !== false && !isDev(phase);
266
+ const userOwnMaps = nextConfig.productionBrowserSourceMaps === true;
267
+ const userHook = nextConfig.compiler?.runAfterProductionCompile;
268
+ const out = { ...nextConfig, env: { ...nextConfig.env, [CONFIG_ENV]: JSON.stringify(config) } };
269
+ if (!uploading) return out;
270
+ out.productionBrowserSourceMaps = true;
271
+ out.compiler = {
272
+ ...nextConfig.compiler,
273
+ async runAfterProductionCompile(metadata) {
274
+ if (userHook) await userHook(metadata);
275
+ await uploadSourceMaps({
276
+ projectDir: metadata.projectDir,
277
+ distDir: metadata.distDir,
278
+ apiUrl: options.apiUrl ?? env("SYPNIA_BASE_URL") ?? "https://telemetry.api.sypnia.com",
279
+ token: env("SYPNIA_API_TOKEN"),
280
+ release: config.release,
281
+ environment: config.environment,
282
+ commit: env("VERCEL_GIT_COMMIT_SHA") ?? git(["rev-parse", "HEAD"]) ?? null,
283
+ basePath: config.basePath,
284
+ // Maps the app chose to publish stay; the ones Sypnia turned on never ship.
285
+ removeMaps: !userOwnMaps
286
+ }).catch(() => void 0);
287
+ }
288
+ };
289
+ return out;
290
+ }
291
+ function withSypnia(nextConfig, options = {}) {
292
+ if (typeof nextConfig === "function") {
293
+ return async (phase, context) => apply(await nextConfig(phase, context), options, phase);
294
+ }
295
+ return apply(nextConfig, options);
296
+ }
297
+
298
+ export { resolveNextConfig, withSypnia };
@@ -0,0 +1,72 @@
1
+ import { N as NodeSdk } from '../index-BQbAXVDI.js';
2
+ import { S as SypniaNextConfig } from '../config-CrnrvvEQ.js';
3
+
4
+ /**
5
+ * `@sypnia/next/opennext`: server traces for a Next.js app deployed with
6
+ * OpenNext (`@opennextjs/aws`), as SST's `Nextjs` component does on AWS Lambda.
7
+ *
8
+ * OpenNext does not run a Node HTTP server: it turns each Lambda event into a
9
+ * request object of its own and calls Next.js' handler directly, so Node never
10
+ * announces a request and `@sypnia/node` would trace nothing. This adapter
11
+ * wraps the OpenNext wrapper the app uses (`aws-lambda` by default): each
12
+ * request event becomes one traced request, with its calls as spans, and its
13
+ * spans leave before the function returns (within `flushBudgetMs`, or with the
14
+ * wrapper's `waitUntil` where it has one, as the streaming wrapper does).
15
+ *
16
+ * It starts the Node SDK itself, at the cold start, before Next.js loads
17
+ * `instrumentation.ts`: the values of `withSypnia` are read from the build
18
+ * (`.next/required-server-files.json`, where Next.js keeps the resolved
19
+ * config with its `env`), so the first request of an instance, the cold one,
20
+ * is traced too. `register()` then finds the SDK started.
21
+ *
22
+ * In `open-next.config.ts`:
23
+ *
24
+ * import awsLambda from '@opennextjs/aws/overrides/wrappers/aws-lambda.js';
25
+ * import { traceOpenNext } from '@sypnia/next/opennext';
26
+ *
27
+ * export default {
28
+ * default: { override: { wrapper: async () => traceOpenNext(awsLambda) } },
29
+ * };
30
+ */
31
+
32
+ /** The request OpenNext hands to Next.js: an `InternalEvent` of type `core`. */
33
+ interface OpenNextEvent {
34
+ type?: string;
35
+ method: string;
36
+ rawPath: string;
37
+ url?: string;
38
+ headers: Record<string, string | string[] | undefined>;
39
+ }
40
+ /** What Next.js answered: an `InternalResult`. */
41
+ interface OpenNextResult {
42
+ statusCode?: number;
43
+ }
44
+ /** The second argument OpenNext passes to its handler. */
45
+ interface OpenNextHandlerOptions {
46
+ waitUntil?: (work: Promise<unknown>) => void;
47
+ streamCreator?: unknown;
48
+ }
49
+ type OpenNextHandler = (event: OpenNextEvent, options?: OpenNextHandlerOptions) => Promise<OpenNextResult>;
50
+ /** An OpenNext wrapper override (`@opennextjs/aws/types/overrides` `Wrapper`), as far as the adapter reads it. */
51
+ interface OpenNextWrapper {
52
+ name: string;
53
+ supportStreaming: boolean;
54
+ edgeRuntime?: boolean;
55
+ wrapper: (handler: never, converter: never) => Promise<(...args: never[]) => unknown>;
56
+ }
57
+ interface TraceOpenNextOptions {
58
+ /** Where the build lives (`.next` is under it). By default the function's folder (`LAMBDA_TASK_ROOT`), else the working folder. */
59
+ dir?: string;
60
+ }
61
+ /** `withSypnia`'s values, from the build's `required-server-files.json`, else from the environment. */
62
+ declare function readBuildConfig(dir: string): SypniaNextConfig | null;
63
+ /** Traces each request the OpenNext handler serves. Events that are not requests (the warmer's) pass untouched. */
64
+ declare function traceHandler(handler: OpenNextHandler, node: typeof NodeSdk): OpenNextHandler;
65
+ /**
66
+ * The OpenNext wrapper `wrapper`, with every request it serves traced. It
67
+ * keeps the wrapper's name, streaming support and behaviour; if Sypnia cannot
68
+ * start (no `withSypnia`, no project), the app runs exactly as without it.
69
+ */
70
+ declare function traceOpenNext<W extends OpenNextWrapper>(wrapper: W, options?: TraceOpenNextOptions): W;
71
+
72
+ export { type OpenNextEvent, type OpenNextHandler, type OpenNextHandlerOptions, type OpenNextResult, type OpenNextWrapper, type TraceOpenNextOptions, readBuildConfig, traceHandler, traceOpenNext };
@@ -0,0 +1,55 @@
1
+ import { startNode } from '../chunk-LBKUMS7U.js';
2
+ import { CONFIG_ENV, readConfig } from '../chunk-WUAOTFVV.js';
3
+ import { readFileSync } from 'fs';
4
+ import { join } from 'path';
5
+
6
+ function headerOf(headers, name) {
7
+ const wanted = name.toLowerCase();
8
+ for (const [key, value] of Object.entries(headers ?? {})) {
9
+ if (key.toLowerCase() !== wanted) continue;
10
+ const first = Array.isArray(value) ? value[0] : value;
11
+ return typeof first === "string" && first ? first : null;
12
+ }
13
+ return null;
14
+ }
15
+ function readBuildConfig(dir) {
16
+ try {
17
+ const files = JSON.parse(readFileSync(join(dir, ".next", "required-server-files.json"), "utf8"));
18
+ const raw = files.config?.env?.[CONFIG_ENV];
19
+ if (typeof raw === "string") {
20
+ const parsed = JSON.parse(raw);
21
+ if (typeof parsed.project === "string" && parsed.project) return parsed;
22
+ }
23
+ } catch {
24
+ }
25
+ return readConfig();
26
+ }
27
+ function traceHandler(handler, node) {
28
+ return (event, options) => {
29
+ if (!event || event.type !== void 0 && event.type !== "core" || typeof event.method !== "string") {
30
+ return handler(event, options);
31
+ }
32
+ return node.traceRequest(
33
+ { method: event.method, path: event.rawPath || "/", header: (name) => headerOf(event.headers, name) },
34
+ () => handler(event, options),
35
+ { statusOf: (result) => typeof result?.statusCode === "number" ? result.statusCode : 200, waitUntil: options?.waitUntil ?? null }
36
+ );
37
+ };
38
+ }
39
+ function traceOpenNext(wrapper, options = {}) {
40
+ const dir = options.dir ?? process.env.LAMBDA_TASK_ROOT ?? process.cwd();
41
+ const wrap = wrapper.wrapper;
42
+ const traced = async (handler, converter) => {
43
+ let node = null;
44
+ try {
45
+ const config = readBuildConfig(dir);
46
+ if (config) node = await startNode(config, dir);
47
+ } catch {
48
+ node = null;
49
+ }
50
+ return wrap(node ? traceHandler(handler, node) : handler, converter);
51
+ };
52
+ return { ...wrapper, wrapper: traced };
53
+ }
54
+
55
+ export { readBuildConfig, traceHandler, traceOpenNext };
@@ -0,0 +1,48 @@
1
+ import { N as NodeSdk } from '../index-BQbAXVDI.js';
2
+
3
+ /**
4
+ * Starts the Node SDK with `withSypnia`'s values, wherever the server side
5
+ * begins: `register()` in `instrumentation.ts`, or the OpenNext adapter,
6
+ * which runs before Next.js loads that file. The SDK starts once; whoever
7
+ * comes second finds it started.
8
+ */
9
+
10
+ type Node = typeof NodeSdk;
11
+
12
+ /**
13
+ * `@sypnia/next/server`: the server side, switched on from `instrumentation.ts`
14
+ * (docs: sdks/nextjs#set-it-up). Next.js loads that file in the Node.js and
15
+ * the Edge runtimes alike, so nothing here imports Node's modules up front:
16
+ * `@sypnia/node` is loaded inside `register()`, only when `NEXT_RUNTIME` is
17
+ * `nodejs`. The Edge runtime is not covered at launch.
18
+ */
19
+
20
+ /** Starts the Node SDK with `withSypnia`'s values. Next.js calls it once per server. */
21
+ declare function register(): Promise<void>;
22
+ /** The `request` argument of Next's `onRequestError`. */
23
+ interface NextRequestInfo {
24
+ path: string;
25
+ method: string;
26
+ headers: Record<string, string | string[] | undefined>;
27
+ }
28
+ /** The `context` argument of Next's `onRequestError`. */
29
+ interface NextErrorContext {
30
+ routerKind?: string;
31
+ routePath?: string;
32
+ routeType?: string;
33
+ }
34
+ /**
35
+ * Every error Next.js catches on the server, with the digest it gives both
36
+ * sides, so the browser's `error` for the same failure joins it.
37
+ */
38
+ declare function onRequestError(error: unknown, request: NextRequestInfo, context?: NextErrorContext): void;
39
+ /** Says who the current request belongs to (ids only). */
40
+ declare const identify: Node['identify'];
41
+ /** Reports an error your code caught on the server. */
42
+ declare const reportError: Node['reportError'];
43
+ /** Records your own step as a span around `fn`. */
44
+ declare function span<T>(name: string, fn: () => T, attrs?: Record<string, string | number | boolean>): T;
45
+ /** Sends what is waiting. */
46
+ declare const flush: Node['flush'];
47
+
48
+ export { type NextErrorContext, type NextRequestInfo, flush, identify, onRequestError, register, reportError, span };
@@ -0,0 +1,37 @@
1
+ import { readConfig } from '../chunk-WUAOTFVV.js';
2
+
3
+ // ../next/src/server.ts
4
+ var node = null;
5
+ function isNodeRuntime() {
6
+ return typeof process !== "undefined" && process.env.NEXT_RUNTIME === "nodejs";
7
+ }
8
+ async function register() {
9
+ try {
10
+ if (process.env.NEXT_RUNTIME !== "nodejs") return;
11
+ const config = readConfig();
12
+ if (!config) return;
13
+ const { startNode } = await import('../start-TW6OBKK7.js');
14
+ node = await startNode(config);
15
+ } catch {
16
+ }
17
+ }
18
+ function onRequestError(error, request, context = {}) {
19
+ try {
20
+ if (!node || !isNodeRuntime()) return;
21
+ const raw = error && typeof error === "object" ? error.digest : void 0;
22
+ const digest = typeof raw === "string" || typeof raw === "number" ? String(raw) : void 0;
23
+ node.captureRequestError(error, { method: request?.method ?? "GET", path: request?.path ?? "/", headers: request?.headers ?? {} }, {
24
+ ...context.routePath ? { route: context.routePath } : {},
25
+ ...digest ? { digest } : {}
26
+ });
27
+ } catch {
28
+ }
29
+ }
30
+ var identify = (who) => node?.identify(who);
31
+ var reportError = (error) => node?.reportError(error);
32
+ function span(name, fn, attrs) {
33
+ return node ? node.span(name, fn, attrs) : fn();
34
+ }
35
+ var flush = async (timeoutMs) => node?.flush(timeoutMs);
36
+
37
+ export { flush, identify, onRequestError, register, reportError, span };
@@ -0,0 +1 @@
1
+ export { B as BRIDGE_MARKER, F as FailedRequest, H as HostRequest, J as JobAttributes, L as LambdaContextLike, a as LambdaHandlerOptions, b as NodeOptions, P as Pattern, S as SpanForReview, c as SqsBatchResponse, d as SqsHandlerOptions, e as SqsMessageAttribute, f as SqsRecordLike, g as SqsRecordOptions, T as TraceRequestOptions, W as WaitUntil, h as Who, i as captureRequestError, j as continueTrace, k as currentTraceparent, l as flush, m as identify, n as init, o as injectTraceContext, r as reportError, s as setWaitUntil, p as shutdown, q as span, t as sqsTraceAttributes, u as traceRequest, v as traceSqsRecord, w as traceparentOf, x as wrapFetchHandler, y as wrapLambdaHandler, z as wrapSqsHandler } from '../index-BQbAXVDI.js';