autotel-adapters 3.1.3 → 3.1.5

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 CHANGED
@@ -27,6 +27,23 @@ Use `defineFrameworkIntegration()` from `autotel-adapters/toolkit` to wire a new
27
27
 
28
28
  Toolkit options include route `include` / `exclude`, per-route `service`, serverless `waitUntil`, streaming `finishResponse`, and request-level `keep` callbacks.
29
29
 
30
+ ### Keeping a request through tail sampling
31
+
32
+ Every adapter accepts `keep`. It runs when the request finishes, with the status, duration, method, path and the request logger's context. Set `shouldKeep` and the adapter calls `forceKeep()` for that request's trace:
33
+
34
+ ```typescript
35
+ app.use(
36
+ '*',
37
+ autotelMiddleware({
38
+ keep: (ctx) => {
39
+ if (ctx.status === 402 || ctx.durationMs > 2000) ctx.shouldKeep = true;
40
+ },
41
+ }),
42
+ );
43
+ ```
44
+
45
+ For a streamed response, `keep` runs when the handler returns, before the body finishes.
46
+
30
47
  The request handle also exposes `markOutcome({ status, error })`, which records the status code and error on the span without emitting the snapshot, and `finishResponse(response, { error })` for an error the framework caught on the way to the response.
31
48
 
32
49
  ## Span names and attributes
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_integration = require("./integration-Danzss1R.cjs");
2
+ const require_integration = require("./integration-Dan_PNIh.cjs");
3
3
  const require_core = require("./core.cjs");
4
4
  let autotel = require("autotel");
5
5
 
@@ -1,4 +1,4 @@
1
- import { a as defineFrameworkIntegration, n as buildTracedOptions, o as runWithIntegratedHandle, t as applyLoggerEnrichment } from "./integration-D_ABolGu.js";
1
+ import { a as defineFrameworkIntegration, n as buildTracedOptions, o as runWithIntegratedHandle, t as applyLoggerEnrichment } from "./integration-CFMzJi4W.js";
2
2
  import { createUseLogger, getHeader } from "./core.js";
3
3
  import { createDrainPipeline, createStructuredError, parseError } from "autotel";
4
4
 
package/dist/core.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_integration = require("./integration-Danzss1R.cjs");
2
+ const require_integration = require("./integration-Dan_PNIh.cjs");
3
3
  let autotel = require("autotel");
4
4
  let autotel_edge = require("autotel-edge");
5
5
 
@@ -27,9 +27,11 @@ function createUseLogger(options) {
27
27
  */
28
28
  function createRequestRunner(storage) {
29
29
  return function runRequest(spanName, enrich, handler, options) {
30
+ if (options?.route) (0, autotel.setHttpServerRoute)(options.route, { keepExisting: true });
30
31
  if (options?.path && !(0, autotel_edge.shouldInstrumentPath)(options.path, options)) return Promise.resolve(handler());
31
32
  const loggerOptions = require_integration.mergeRequestLoggerOptions(options?.requestLoggerOptions, options?.waitUntil);
32
33
  return autotel.trace.run(spanName, async (ctx) => {
34
+ const startedAt = Date.now();
33
35
  const log = (0, autotel.getRequestLogger)(ctx, loggerOptions);
34
36
  enrich(log);
35
37
  try {
@@ -39,7 +41,17 @@ function createRequestRunner(storage) {
39
41
  throw error;
40
42
  } finally {
41
43
  const finalized = options?.finalize?.();
42
- require_integration.markServerError(ctx, finalized?.["http.response.status_code"]);
44
+ const status = finalized?.["http.response.status_code"];
45
+ require_integration.markServerError(ctx, status);
46
+ const context = log.getContext();
47
+ await require_integration.applyKeep(options?.keep, ctx, {
48
+ status,
49
+ durationMs: Date.now() - startedAt,
50
+ path: options?.path ?? "",
51
+ method: String(context["http.request.method"] ?? ""),
52
+ context,
53
+ shouldKeep: false
54
+ });
43
55
  if (options?.autoEmit !== false) log.emitNow(finalized);
44
56
  }
45
57
  });
package/dist/core.d.cts CHANGED
@@ -12,6 +12,11 @@ export interface RequestRunnerOptions extends RouteAdapterOptions {
12
12
  requestLoggerOptions?: RequestLoggerOptions;
13
13
  /** HTTP route used for include/exclude filtering. */
14
14
  path?: string;
15
+ /**
16
+ * Matched route template, such as `/users/:id`, handed to the HTTP server
17
+ * span unless a fuller one is already recorded there.
18
+ */
19
+ route?: string;
15
20
  /** Emit one wide event automatically when the handler settles. Default `true`. */
16
21
  autoEmit?: boolean;
17
22
  /** Fields merged into the wide event at emit time (e.g. response status). */
package/dist/core.d.ts CHANGED
@@ -12,6 +12,11 @@ export interface RequestRunnerOptions extends RouteAdapterOptions {
12
12
  requestLoggerOptions?: RequestLoggerOptions;
13
13
  /** HTTP route used for include/exclude filtering. */
14
14
  path?: string;
15
+ /**
16
+ * Matched route template, such as `/users/:id`, handed to the HTTP server
17
+ * span unless a fuller one is already recorded there.
18
+ */
19
+ route?: string;
15
20
  /** Emit one wide event automatically when the handler settles. Default `true`. */
16
21
  autoEmit?: boolean;
17
22
  /** Fields merged into the wide event at emit time (e.g. response status). */
package/dist/core.js CHANGED
@@ -1,5 +1,5 @@
1
- import { d as markServerError, m as shouldInstrumentPath, p as mergeRequestLoggerOptions, s as toRouteAdapterOptions } from "./integration-D_ABolGu.js";
2
- import { getRequestLogger, trace } from "autotel";
1
+ import { f as markServerError, h as shouldInstrumentPath, l as applyKeep, m as mergeRequestLoggerOptions, s as toRouteAdapterOptions } from "./integration-CFMzJi4W.js";
2
+ import { getRequestLogger, setHttpServerRoute, trace } from "autotel";
3
3
 
4
4
  //#region src/core.ts
5
5
  function createUseLogger(options) {
@@ -25,9 +25,11 @@ function createUseLogger(options) {
25
25
  */
26
26
  function createRequestRunner(storage) {
27
27
  return function runRequest(spanName, enrich, handler, options) {
28
+ if (options?.route) setHttpServerRoute(options.route, { keepExisting: true });
28
29
  if (options?.path && !shouldInstrumentPath(options.path, options)) return Promise.resolve(handler());
29
30
  const loggerOptions = mergeRequestLoggerOptions(options?.requestLoggerOptions, options?.waitUntil);
30
31
  return trace.run(spanName, async (ctx) => {
32
+ const startedAt = Date.now();
31
33
  const log = getRequestLogger(ctx, loggerOptions);
32
34
  enrich(log);
33
35
  try {
@@ -37,7 +39,17 @@ function createRequestRunner(storage) {
37
39
  throw error;
38
40
  } finally {
39
41
  const finalized = options?.finalize?.();
40
- markServerError(ctx, finalized?.["http.response.status_code"]);
42
+ const status = finalized?.["http.response.status_code"];
43
+ markServerError(ctx, status);
44
+ const context = log.getContext();
45
+ await applyKeep(options?.keep, ctx, {
46
+ status,
47
+ durationMs: Date.now() - startedAt,
48
+ path: options?.path ?? "",
49
+ method: String(context["http.request.method"] ?? ""),
50
+ context,
51
+ shouldKeep: false
52
+ });
41
53
  if (options?.autoEmit !== false) log.emitNow(finalized);
42
54
  }
43
55
  });
package/dist/elysia.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_integration = require("./integration-Danzss1R.cjs");
2
+ const require_integration = require("./integration-Dan_PNIh.cjs");
3
3
  const require_toolkit_storage = require("./toolkit/storage.cjs");
4
4
  const require_core = require("./core.cjs");
5
5
  let autotel = require("autotel");
package/dist/elysia.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as defineFrameworkIntegration, o as runWithIntegratedHandle, t as applyLoggerEnrichment } from "./integration-D_ABolGu.js";
1
+ import { a as defineFrameworkIntegration, o as runWithIntegratedHandle, t as applyLoggerEnrichment } from "./integration-CFMzJi4W.js";
2
2
  import { createLoggerStorage } from "./toolkit/storage.js";
3
3
  import { getHeader } from "./core.js";
4
4
  import { createDrainPipeline, createStructuredError, parseError } from "autotel";
package/dist/express.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_integration = require("./integration-Danzss1R.cjs");
2
+ const require_integration = require("./integration-Dan_PNIh.cjs");
3
3
  const require_core = require("./core.cjs");
4
4
  let autotel = require("autotel");
5
5
  let node_async_hooks = require("node:async_hooks");
@@ -64,6 +64,7 @@ function withAutotel(handler, options) {
64
64
  }, () => handler(req, res, next), {
65
65
  ...require_integration.toRouteAdapterOptions(options),
66
66
  path: route,
67
+ route: req.baseUrl ? void 0 : routeTemplate(req),
67
68
  requestLoggerOptions: options?.requestLoggerOptions,
68
69
  autoEmit: options?.autoEmit,
69
70
  finalize: () => res.statusCode ? { "http.response.status_code": res.statusCode } : void 0
@@ -10,6 +10,7 @@ export interface ExpressRequestLike {
10
10
  route?: {
11
11
  path?: string;
12
12
  };
13
+ baseUrl?: string;
13
14
  headers?: Record<string, string | string[] | undefined>;
14
15
  }
15
16
  export interface ExpressResponseLike {
package/dist/express.d.ts CHANGED
@@ -10,6 +10,7 @@ export interface ExpressRequestLike {
10
10
  route?: {
11
11
  path?: string;
12
12
  };
13
+ baseUrl?: string;
13
14
  headers?: Record<string, string | string[] | undefined>;
14
15
  }
15
16
  export interface ExpressResponseLike {
package/dist/express.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as defaultSpanName, s as toRouteAdapterOptions } from "./integration-D_ABolGu.js";
1
+ import { i as defaultSpanName, s as toRouteAdapterOptions } from "./integration-CFMzJi4W.js";
2
2
  import { createRequestRunner, createUseLogger } from "./core.js";
3
3
  import { createDrainPipeline, createStructuredError, parseError } from "autotel";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -63,6 +63,7 @@ function withAutotel(handler, options) {
63
63
  }, () => handler(req, res, next), {
64
64
  ...toRouteAdapterOptions(options),
65
65
  path: route,
66
+ route: req.baseUrl ? void 0 : routeTemplate(req),
66
67
  requestLoggerOptions: options?.requestLoggerOptions,
67
68
  autoEmit: options?.autoEmit,
68
69
  finalize: () => res.statusCode ? { "http.response.status_code": res.statusCode } : void 0
package/dist/fastify.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_integration = require("./integration-Danzss1R.cjs");
2
+ const require_integration = require("./integration-Dan_PNIh.cjs");
3
3
  const require_core = require("./core.cjs");
4
4
  let autotel = require("autotel");
5
5
  let node_async_hooks = require("node:async_hooks");
@@ -53,6 +53,7 @@ function withAutotel(handler, options) {
53
53
  }, () => handler(request, reply), {
54
54
  ...require_integration.toRouteAdapterOptions(options),
55
55
  path: route,
56
+ route: routeTemplate(request),
56
57
  requestLoggerOptions: options?.requestLoggerOptions,
57
58
  autoEmit: options?.autoEmit,
58
59
  finalize: () => reply.statusCode ? { "http.response.status_code": reply.statusCode } : void 0
package/dist/fastify.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as defaultSpanName, s as toRouteAdapterOptions } from "./integration-D_ABolGu.js";
1
+ import { i as defaultSpanName, s as toRouteAdapterOptions } from "./integration-CFMzJi4W.js";
2
2
  import { createRequestRunner, createUseLogger } from "./core.js";
3
3
  import { createDrainPipeline, createStructuredError, parseError } from "autotel";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -52,6 +52,7 @@ function withAutotel(handler, options) {
52
52
  }, () => handler(request, reply), {
53
53
  ...toRouteAdapterOptions(options),
54
54
  path: route,
55
+ route: routeTemplate(request),
55
56
  requestLoggerOptions: options?.requestLoggerOptions,
56
57
  autoEmit: options?.autoEmit,
57
58
  finalize: () => reply.statusCode ? { "http.response.status_code": reply.statusCode } : void 0
package/dist/hono.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_integration = require("./integration-Danzss1R.cjs");
2
+ const require_integration = require("./integration-Dan_PNIh.cjs");
3
3
  const require_toolkit_storage = require("./toolkit/storage.cjs");
4
4
  const require_core = require("./core.cjs");
5
5
  let autotel = require("autotel");
package/dist/hono.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as defineFrameworkIntegration, t as applyLoggerEnrichment } from "./integration-D_ABolGu.js";
1
+ import { a as defineFrameworkIntegration, t as applyLoggerEnrichment } from "./integration-CFMzJi4W.js";
2
2
  import { createLoggerStorage } from "./toolkit/storage.js";
3
3
  import { createUseLogger } from "./core.js";
4
4
  import { createDrainPipeline, createStructuredError, parseError } from "autotel";
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_integration = require("./integration-Danzss1R.cjs");
2
+ const require_integration = require("./integration-Dan_PNIh.cjs");
3
3
  const require_core = require("./core.cjs");
4
4
  const require_next = require("./next.cjs");
5
5
  const require_nitro = require("./nitro.cjs");
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { s as toRouteAdapterOptions } from "./integration-D_ABolGu.js";
1
+ import { s as toRouteAdapterOptions } from "./integration-CFMzJi4W.js";
2
2
  import { createRequestRunner, createUseLogger, getHeader, resolveAdapterConfig, shouldProbeRuntime } from "./core.js";
3
3
  import { withAutotel } from "./next.js";
4
4
  import { withAutotelEventHandler } from "./nitro.js";
@@ -1,5 +1,5 @@
1
1
  import { createStorageForkLifecycle } from "./toolkit/storage.js";
2
- import { SpanStatusCode, createNoopRequestLogger, getRequestLogger, recordStructuredError, trace } from "autotel";
2
+ import { AUTOTEL_SAMPLING_TAIL_EVALUATED, AUTOTEL_SAMPLING_TAIL_KEEP, SpanStatusCode, createNoopRequestLogger, forceKeep, getRequestLogger, recordStructuredError, setHttpServerRoute, trace } from "autotel";
3
3
  import { getServiceForPath, matchesRoutePattern, shouldInstrumentPath } from "autotel-edge";
4
4
 
5
5
  //#region src/toolkit/deferred-drain.ts
@@ -146,20 +146,45 @@ function recordOutcome(logger, span, { status, error }, emitted) {
146
146
  markServerError(span, status);
147
147
  }
148
148
  }
149
- async function performFinish(logger, options, startedAt, span, emitted, opts) {
150
- const { status, overrides } = opts ?? {};
151
- recordOutcome(logger, span, opts ?? {}, emitted);
152
- const durationMs = Date.now() - startedAt;
153
- logger.set({ duration_ms: durationMs });
154
- const tailCtx = {
155
- status: status ?? logger.getContext()["http.response.status_code"],
156
- durationMs,
149
+ /**
150
+ * Run the `keep` callback and, when it sets `shouldKeep`, keep the trace.
151
+ * The attributes go on the request span itself for an adapter that finishes
152
+ * outside the active context; `forceKeep()` stops the tracing wrapper
153
+ * overwriting them when the finish runs inside it.
154
+ */
155
+ async function applyKeep(keep, span, tailCtx) {
156
+ if (!keep) return;
157
+ try {
158
+ await keep(tailCtx);
159
+ } catch (err) {
160
+ console.error("[autotel-adapters] keep failed:", err);
161
+ return;
162
+ }
163
+ if (!tailCtx.shouldKeep) return;
164
+ span?.setAttributes({
165
+ [AUTOTEL_SAMPLING_TAIL_EVALUATED]: true,
166
+ [AUTOTEL_SAMPLING_TAIL_KEEP]: true
167
+ });
168
+ forceKeep();
169
+ }
170
+ function tailContext(logger, options, startedAt, status) {
171
+ const context = logger.getContext();
172
+ return {
173
+ status: status ?? context["http.response.status_code"],
174
+ durationMs: Date.now() - startedAt,
157
175
  path: options.path,
158
176
  method: options.method,
159
- context: logger.getContext(),
177
+ context,
160
178
  shouldKeep: false
161
179
  };
162
- if (options.keep) await options.keep(tailCtx);
180
+ }
181
+ async function performFinish(logger, options, startedAt, span, emitted, opts) {
182
+ const { status, overrides } = opts ?? {};
183
+ recordOutcome(logger, span, opts ?? {}, emitted);
184
+ const tailCtx = tailContext(logger, options, startedAt, status);
185
+ const { durationMs } = tailCtx;
186
+ logger.set({ duration_ms: durationMs });
187
+ if (!opts?.keepDecided) await applyKeep(options.keep, span, tailCtx);
163
188
  if (options.onFinish) try {
164
189
  await options.onFinish({
165
190
  logger,
@@ -171,11 +196,7 @@ async function performFinish(logger, options, startedAt, span, emitted, opts) {
171
196
  } catch (err) {
172
197
  console.error("[autotel-adapters] onFinish failed:", err);
173
198
  }
174
- const mergedOverrides = {
175
- ...overrides ?? {},
176
- "autotel.sampling.tail.keep": true
177
- };
178
- return logger.emitNow(Object.keys(mergedOverrides).length > 0 ? mergedOverrides : void 0);
199
+ return logger.emitNow(overrides);
179
200
  }
180
201
  /**
181
202
  * Create a request logger handle for use inside an active autotel trace span.
@@ -213,11 +234,13 @@ function createMiddlewareLogger(logger, options, span) {
213
234
  status,
214
235
  error: opts?.error
215
236
  }, emitted);
237
+ await applyKeep(options.keep, span, tailContext(logger, options, startedAt, status));
216
238
  return bindStreamingResponseLifecycle(response, async (meta) => {
217
239
  await performFinish(logger, options, startedAt, span, emitted, {
218
240
  status: meta.status ?? status,
219
241
  error: meta.error,
220
- overrides: opts?.overrides
242
+ overrides: opts?.overrides,
243
+ keepDecided: true
221
244
  });
222
245
  });
223
246
  }
@@ -321,6 +344,7 @@ function buildHandle(spec, ctx, traceCtx, options = {}, defaultNamed = false) {
321
344
  "http.route": extracted.route,
322
345
  "http.request.id": extracted.requestId
323
346
  });
347
+ if (extracted.route) setHttpServerRoute(extracted.route, { keepExisting: true });
324
348
  if (spec.storage) attachForkToLogger(log, spec.forkLifecycle ?? createStorageForkLifecycle(spec.storage));
325
349
  spec.attachLogger(ctx, log);
326
350
  const result = createMiddlewareLogger(log, middlewareOptions, traceCtx);
@@ -335,6 +359,7 @@ function buildHandle(spec, ctx, traceCtx, options = {}, defaultNamed = false) {
335
359
  setRoute: (route) => {
336
360
  if (!route) return;
337
361
  log.set({ "http.route": route });
362
+ setHttpServerRoute(route);
338
363
  if (defaultNamed) traceCtx.updateName(defaultSpanName(extracted.method, route));
339
364
  }
340
365
  };
@@ -387,4 +412,4 @@ function defineFrameworkIntegration(spec) {
387
412
  }
388
413
 
389
414
  //#endregion
390
- export { shouldDeferEmitForResponse as _, defineFrameworkIntegration as a, attachForkToLogger as c, markServerError as d, matchesRoutePattern as f, isStreamingResponse as g, bindStreamingResponseLifecycle as h, defaultSpanName as i, createMiddlewareLogger as l, shouldInstrumentPath as m, buildTracedOptions as n, runWithIntegratedHandle as o, mergeRequestLoggerOptions as p, completeIntegratedRequest as r, toRouteAdapterOptions as s, applyLoggerEnrichment as t, getServiceForPath as u, extendDeferredDrain as v };
415
+ export { isStreamingResponse as _, defineFrameworkIntegration as a, attachForkToLogger as c, getServiceForPath as d, markServerError as f, bindStreamingResponseLifecycle as g, shouldInstrumentPath as h, defaultSpanName as i, applyKeep as l, mergeRequestLoggerOptions as m, buildTracedOptions as n, runWithIntegratedHandle as o, matchesRoutePattern as p, completeIntegratedRequest as r, toRouteAdapterOptions as s, applyLoggerEnrichment as t, createMiddlewareLogger as u, shouldDeferEmitForResponse as v, extendDeferredDrain as y };
@@ -146,20 +146,45 @@ function recordOutcome(logger, span, { status, error }, emitted) {
146
146
  markServerError(span, status);
147
147
  }
148
148
  }
149
- async function performFinish(logger, options, startedAt, span, emitted, opts) {
150
- const { status, overrides } = opts ?? {};
151
- recordOutcome(logger, span, opts ?? {}, emitted);
152
- const durationMs = Date.now() - startedAt;
153
- logger.set({ duration_ms: durationMs });
154
- const tailCtx = {
155
- status: status ?? logger.getContext()["http.response.status_code"],
156
- durationMs,
149
+ /**
150
+ * Run the `keep` callback and, when it sets `shouldKeep`, keep the trace.
151
+ * The attributes go on the request span itself for an adapter that finishes
152
+ * outside the active context; `forceKeep()` stops the tracing wrapper
153
+ * overwriting them when the finish runs inside it.
154
+ */
155
+ async function applyKeep(keep, span, tailCtx) {
156
+ if (!keep) return;
157
+ try {
158
+ await keep(tailCtx);
159
+ } catch (err) {
160
+ console.error("[autotel-adapters] keep failed:", err);
161
+ return;
162
+ }
163
+ if (!tailCtx.shouldKeep) return;
164
+ span?.setAttributes({
165
+ [autotel.AUTOTEL_SAMPLING_TAIL_EVALUATED]: true,
166
+ [autotel.AUTOTEL_SAMPLING_TAIL_KEEP]: true
167
+ });
168
+ (0, autotel.forceKeep)();
169
+ }
170
+ function tailContext(logger, options, startedAt, status) {
171
+ const context = logger.getContext();
172
+ return {
173
+ status: status ?? context["http.response.status_code"],
174
+ durationMs: Date.now() - startedAt,
157
175
  path: options.path,
158
176
  method: options.method,
159
- context: logger.getContext(),
177
+ context,
160
178
  shouldKeep: false
161
179
  };
162
- if (options.keep) await options.keep(tailCtx);
180
+ }
181
+ async function performFinish(logger, options, startedAt, span, emitted, opts) {
182
+ const { status, overrides } = opts ?? {};
183
+ recordOutcome(logger, span, opts ?? {}, emitted);
184
+ const tailCtx = tailContext(logger, options, startedAt, status);
185
+ const { durationMs } = tailCtx;
186
+ logger.set({ duration_ms: durationMs });
187
+ if (!opts?.keepDecided) await applyKeep(options.keep, span, tailCtx);
163
188
  if (options.onFinish) try {
164
189
  await options.onFinish({
165
190
  logger,
@@ -171,11 +196,7 @@ async function performFinish(logger, options, startedAt, span, emitted, opts) {
171
196
  } catch (err) {
172
197
  console.error("[autotel-adapters] onFinish failed:", err);
173
198
  }
174
- const mergedOverrides = {
175
- ...overrides ?? {},
176
- "autotel.sampling.tail.keep": true
177
- };
178
- return logger.emitNow(Object.keys(mergedOverrides).length > 0 ? mergedOverrides : void 0);
199
+ return logger.emitNow(overrides);
179
200
  }
180
201
  /**
181
202
  * Create a request logger handle for use inside an active autotel trace span.
@@ -213,11 +234,13 @@ function createMiddlewareLogger(logger, options, span) {
213
234
  status,
214
235
  error: opts?.error
215
236
  }, emitted);
237
+ await applyKeep(options.keep, span, tailContext(logger, options, startedAt, status));
216
238
  return bindStreamingResponseLifecycle(response, async (meta) => {
217
239
  await performFinish(logger, options, startedAt, span, emitted, {
218
240
  status: meta.status ?? status,
219
241
  error: meta.error,
220
- overrides: opts?.overrides
242
+ overrides: opts?.overrides,
243
+ keepDecided: true
221
244
  });
222
245
  });
223
246
  }
@@ -321,6 +344,7 @@ function buildHandle(spec, ctx, traceCtx, options = {}, defaultNamed = false) {
321
344
  "http.route": extracted.route,
322
345
  "http.request.id": extracted.requestId
323
346
  });
347
+ if (extracted.route) (0, autotel.setHttpServerRoute)(extracted.route, { keepExisting: true });
324
348
  if (spec.storage) attachForkToLogger(log, spec.forkLifecycle ?? require_toolkit_storage.createStorageForkLifecycle(spec.storage));
325
349
  spec.attachLogger(ctx, log);
326
350
  const result = createMiddlewareLogger(log, middlewareOptions, traceCtx);
@@ -335,6 +359,7 @@ function buildHandle(spec, ctx, traceCtx, options = {}, defaultNamed = false) {
335
359
  setRoute: (route) => {
336
360
  if (!route) return;
337
361
  log.set({ "http.route": route });
362
+ (0, autotel.setHttpServerRoute)(route);
338
363
  if (defaultNamed) traceCtx.updateName(defaultSpanName(extracted.method, route));
339
364
  }
340
365
  };
@@ -387,6 +412,12 @@ function defineFrameworkIntegration(spec) {
387
412
  }
388
413
 
389
414
  //#endregion
415
+ Object.defineProperty(exports, "applyKeep", {
416
+ enumerable: true,
417
+ get: function () {
418
+ return applyKeep;
419
+ }
420
+ });
390
421
  Object.defineProperty(exports, "applyLoggerEnrichment", {
391
422
  enumerable: true,
392
423
  get: function () {
package/dist/nestjs.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_integration = require("./integration-Danzss1R.cjs");
2
+ const require_integration = require("./integration-Dan_PNIh.cjs");
3
3
  const require_toolkit_storage = require("./toolkit/storage.cjs");
4
4
  let autotel = require("autotel");
5
5
  let rxjs = require("rxjs");
package/dist/nestjs.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as defineFrameworkIntegration, t as applyLoggerEnrichment } from "./integration-D_ABolGu.js";
1
+ import { a as defineFrameworkIntegration, t as applyLoggerEnrichment } from "./integration-CFMzJi4W.js";
2
2
  import { createLoggerStorage } from "./toolkit/storage.js";
3
3
  import { createDrainPipeline, createStructuredError, parseError } from "autotel";
4
4
  import { Observable, from, isObservable } from "rxjs";
package/dist/next.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_integration = require("./integration-Danzss1R.cjs");
2
+ const require_integration = require("./integration-Dan_PNIh.cjs");
3
3
  const require_toolkit_storage = require("./toolkit/storage.cjs");
4
4
  const require_core = require("./core.cjs");
5
5
  let autotel = require("autotel");
package/dist/next.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as defineFrameworkIntegration, n as buildTracedOptions, o as runWithIntegratedHandle, t as applyLoggerEnrichment } from "./integration-D_ABolGu.js";
1
+ import { a as defineFrameworkIntegration, n as buildTracedOptions, o as runWithIntegratedHandle, t as applyLoggerEnrichment } from "./integration-CFMzJi4W.js";
2
2
  import { createLoggerStorage } from "./toolkit/storage.js";
3
3
  import { createUseLogger, getHeader } from "./core.js";
4
4
  import { createDrainPipeline, createStructuredError, getRequestLogger, parseError, trace } from "autotel";
package/dist/nitro.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_integration = require("./integration-Danzss1R.cjs");
2
+ const require_integration = require("./integration-Dan_PNIh.cjs");
3
3
  const require_toolkit_storage = require("./toolkit/storage.cjs");
4
4
  const require_core = require("./core.cjs");
5
5
  let autotel = require("autotel");
package/dist/nitro.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as defineFrameworkIntegration, n as buildTracedOptions, o as runWithIntegratedHandle, t as applyLoggerEnrichment } from "./integration-D_ABolGu.js";
1
+ import { a as defineFrameworkIntegration, n as buildTracedOptions, o as runWithIntegratedHandle, t as applyLoggerEnrichment } from "./integration-CFMzJi4W.js";
2
2
  import { createLoggerStorage } from "./toolkit/storage.js";
3
3
  import { createUseLogger } from "./core.js";
4
4
  import { createDrainPipeline, createStructuredError, parseError } from "autotel";
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_integration = require("./integration-Danzss1R.cjs");
2
+ const require_integration = require("./integration-Dan_PNIh.cjs");
3
3
  const require_toolkit_storage = require("./toolkit/storage.cjs");
4
4
  let autotel = require("autotel");
5
5
 
package/dist/sveltekit.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as defineFrameworkIntegration, o as runWithIntegratedHandle, t as applyLoggerEnrichment } from "./integration-D_ABolGu.js";
1
+ import { a as defineFrameworkIntegration, o as runWithIntegratedHandle, t as applyLoggerEnrichment } from "./integration-CFMzJi4W.js";
2
2
  import { createLoggerStorage } from "./toolkit/storage.js";
3
3
  import { createDrainPipeline, createStructuredError, parseError } from "autotel";
4
4
 
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_integration = require("../integration-Danzss1R.cjs");
2
+ const require_integration = require("../integration-Dan_PNIh.cjs");
3
3
  const require_toolkit_storage = require("./storage.cjs");
4
4
  let autotel_edge = require("autotel-edge");
5
5
 
@@ -1,4 +1,4 @@
1
- import { _ as shouldDeferEmitForResponse, a as defineFrameworkIntegration, c as attachForkToLogger, f as matchesRoutePattern, g as isStreamingResponse, h as bindStreamingResponseLifecycle, l as createMiddlewareLogger, m as shouldInstrumentPath, n as buildTracedOptions, o as runWithIntegratedHandle, p as mergeRequestLoggerOptions, r as completeIntegratedRequest, s as toRouteAdapterOptions, t as applyLoggerEnrichment, u as getServiceForPath, v as extendDeferredDrain } from "../integration-D_ABolGu.js";
1
+ import { _ as isStreamingResponse, a as defineFrameworkIntegration, c as attachForkToLogger, d as getServiceForPath, g as bindStreamingResponseLifecycle, h as shouldInstrumentPath, m as mergeRequestLoggerOptions, n as buildTracedOptions, o as runWithIntegratedHandle, p as matchesRoutePattern, r as completeIntegratedRequest, s as toRouteAdapterOptions, t as applyLoggerEnrichment, u as createMiddlewareLogger, v as shouldDeferEmitForResponse, y as extendDeferredDrain } from "../integration-CFMzJi4W.js";
2
2
  import { createLoggerStorage, createStorageForkLifecycle } from "./storage.js";
3
3
 
4
4
  export { applyLoggerEnrichment, attachForkToLogger, bindStreamingResponseLifecycle, buildTracedOptions, completeIntegratedRequest, createLoggerStorage, createMiddlewareLogger, createStorageForkLifecycle, defineFrameworkIntegration, extendDeferredDrain, getServiceForPath, isStreamingResponse, matchesRoutePattern, mergeRequestLoggerOptions, runWithIntegratedHandle, shouldDeferEmitForResponse, shouldInstrumentPath, toRouteAdapterOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel-adapters",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "description": "Framework adapters and composable DX helpers for autotel",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -91,8 +91,8 @@
91
91
  "NOTICE"
92
92
  ],
93
93
  "dependencies": {
94
- "autotel": "8.8.1",
95
- "autotel-edge": "6.1.4"
94
+ "autotel": "9.0.0",
95
+ "autotel-edge": "7.0.0"
96
96
  },
97
97
  "peerDependencies": {
98
98
  "hono": ">=4.13.13",