@stainlessdev/xray-emitter 0.1.0-dev.3b8d877 → 0.1.0-dev.7eabc37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/{chunk-ESBHEKC2.cjs → chunk-22W6MSR2.cjs} +4 -4
  2. package/dist/chunk-22W6MSR2.cjs.map +1 -0
  3. package/dist/{chunk-Q4MTHPUL.cjs → chunk-3LDFK62Q.cjs} +1 -1
  4. package/dist/{chunk-Q4MTHPUL.cjs.map → chunk-3LDFK62Q.cjs.map} +1 -1
  5. package/dist/{chunk-OCXEYDDH.cjs → chunk-BVAENKYE.cjs} +4 -4
  6. package/dist/chunk-BVAENKYE.cjs.map +1 -0
  7. package/dist/{chunk-VRRPTE7W.js → chunk-DKHGODGO.js} +1 -1
  8. package/dist/chunk-DKHGODGO.js.map +1 -0
  9. package/dist/{chunk-W75UIHEF.js → chunk-LJYBYC7N.js} +2 -2
  10. package/dist/chunk-LJYBYC7N.js.map +1 -0
  11. package/dist/{chunk-KU23HQLZ.js → chunk-ZCC372UX.js} +2 -2
  12. package/dist/chunk-ZCC372UX.js.map +1 -0
  13. package/dist/effect.cjs +4 -4
  14. package/dist/effect.cjs.map +1 -1
  15. package/dist/effect.d.cts +30 -3
  16. package/dist/effect.d.ts +30 -3
  17. package/dist/effect.js +2 -2
  18. package/dist/effect.js.map +1 -1
  19. package/dist/emitter-Bi_m_w5h.d.cts +10 -0
  20. package/dist/emitter-Dy7bRGTq.d.ts +10 -0
  21. package/dist/express.cjs +5 -5
  22. package/dist/express.cjs.map +1 -1
  23. package/dist/express.d.cts +9 -2
  24. package/dist/express.d.ts +9 -2
  25. package/dist/express.js +2 -2
  26. package/dist/express.js.map +1 -1
  27. package/dist/fastify.cjs +7 -7
  28. package/dist/fastify.cjs.map +1 -1
  29. package/dist/fastify.d.cts +9 -2
  30. package/dist/fastify.d.ts +9 -2
  31. package/dist/fastify.js +2 -2
  32. package/dist/fastify.js.map +1 -1
  33. package/dist/fetch.cjs +3 -3
  34. package/dist/fetch.d.cts +39 -2
  35. package/dist/fetch.d.ts +39 -2
  36. package/dist/fetch.js +2 -2
  37. package/dist/hono.cjs +6 -6
  38. package/dist/hono.cjs.map +1 -1
  39. package/dist/hono.d.cts +15 -3
  40. package/dist/hono.d.ts +15 -3
  41. package/dist/hono.js +2 -2
  42. package/dist/hono.js.map +1 -1
  43. package/dist/index.cjs +2 -2
  44. package/dist/index.d.cts +8 -2
  45. package/dist/index.d.ts +8 -2
  46. package/dist/index.js +1 -1
  47. package/dist/internal.d.cts +1 -1
  48. package/dist/internal.d.ts +1 -1
  49. package/dist/next.cjs +5 -5
  50. package/dist/next.cjs.map +1 -1
  51. package/dist/next.d.cts +9 -3
  52. package/dist/next.d.ts +9 -3
  53. package/dist/next.js +2 -2
  54. package/dist/next.js.map +1 -1
  55. package/dist/node.cjs +3 -3
  56. package/dist/node.d.cts +42 -1
  57. package/dist/node.d.ts +42 -1
  58. package/dist/node.js +2 -2
  59. package/dist/remix.cjs +5 -5
  60. package/dist/remix.cjs.map +1 -1
  61. package/dist/remix.d.cts +10 -3
  62. package/dist/remix.d.ts +10 -3
  63. package/dist/remix.js +2 -2
  64. package/dist/remix.js.map +1 -1
  65. package/dist/types-BrKvhHbn.d.cts +446 -0
  66. package/dist/types-BrKvhHbn.d.ts +446 -0
  67. package/package.json +1 -1
  68. package/dist/chunk-ESBHEKC2.cjs.map +0 -1
  69. package/dist/chunk-KU23HQLZ.js.map +0 -1
  70. package/dist/chunk-OCXEYDDH.cjs.map +0 -1
  71. package/dist/chunk-VRRPTE7W.js.map +0 -1
  72. package/dist/chunk-W75UIHEF.js.map +0 -1
  73. package/dist/emitter-Cdl6H6vk.d.cts +0 -5
  74. package/dist/emitter-DnDvQw9i.d.ts +0 -5
  75. package/dist/types-Diy-KLjz.d.cts +0 -154
  76. package/dist/types-Diy-KLjz.d.ts +0 -154
package/dist/fetch.d.cts CHANGED
@@ -1,18 +1,55 @@
1
- export { c as createEmitter } from './emitter-Cdl6H6vk.cjs';
2
- import { a as XrayEmitter, e as CaptureConfig, f as RedactionConfig, d as XrayContext, R as RequestLog } from './types-Diy-KLjz.cjs';
1
+ export { c as createEmitter } from './emitter-Bi_m_w5h.cjs';
2
+ import { a as XrayEmitter, e as CaptureConfig, f as RedactionConfig, d as XrayContext, R as RequestLog } from './types-BrKvhHbn.cjs';
3
3
  import '@opentelemetry/sdk-trace-base';
4
4
 
5
5
  interface WrapOptions {
6
+ /**
7
+ * Explicit route pattern for this handler (for example `/users/:id`).
8
+ */
6
9
  route?: string;
10
+ /**
11
+ * Explicit request ID. Skips header lookup/generation when provided.
12
+ */
7
13
  requestId?: string;
14
+ /**
15
+ * Per-handler capture overrides.
16
+ */
8
17
  capture?: Partial<CaptureConfig>;
18
+ /**
19
+ * Per-handler redaction overrides.
20
+ */
9
21
  redaction?: Partial<RedactionConfig>;
22
+ /**
23
+ * Hook called after request context is created.
24
+ */
10
25
  onRequest?: (ctx: XrayContext) => void;
26
+ /**
27
+ * Hook called after the request has been finalized and logged.
28
+ */
11
29
  onResponse?: (ctx: XrayContext, log: RequestLog) => void;
30
+ /**
31
+ * Hook called when request handling fails.
32
+ */
12
33
  onError?: (ctx: XrayContext, err: unknown) => void;
13
34
  }
35
+ /**
36
+ * Wrap a fetch-style handler with X-ray instrumentation.
37
+ *
38
+ * This variant may replace the request/response objects to safely capture
39
+ * bodies and inject a request ID response header when needed.
40
+ */
14
41
  declare function wrapFetch(handler: (req: Request) => Response | Promise<Response>, xray: XrayEmitter, options?: WrapOptions): (req: Request) => Promise<Response>;
42
+ /**
43
+ * Wrap a fetch-style handler while preserving original request/response objects
44
+ * whenever possible.
45
+ *
46
+ * If a missing request ID header must be injected and response headers are
47
+ * immutable, this wrapper may still replace the response object.
48
+ */
15
49
  declare function wrapFetchPreserve(handler: (req: Request) => Response | Promise<Response>, xray: XrayEmitter, options?: WrapOptions): (req: Request) => Promise<Response>;
50
+ /**
51
+ * Retrieve the `XrayContext` bound to a fetch `Request`.
52
+ */
16
53
  declare function getXrayContext(req: Request): XrayContext | undefined;
17
54
 
18
55
  export { type WrapOptions, getXrayContext, wrapFetch, wrapFetchPreserve };
package/dist/fetch.d.ts CHANGED
@@ -1,18 +1,55 @@
1
- export { c as createEmitter } from './emitter-DnDvQw9i.js';
2
- import { a as XrayEmitter, e as CaptureConfig, f as RedactionConfig, d as XrayContext, R as RequestLog } from './types-Diy-KLjz.js';
1
+ export { c as createEmitter } from './emitter-Dy7bRGTq.js';
2
+ import { a as XrayEmitter, e as CaptureConfig, f as RedactionConfig, d as XrayContext, R as RequestLog } from './types-BrKvhHbn.js';
3
3
  import '@opentelemetry/sdk-trace-base';
4
4
 
5
5
  interface WrapOptions {
6
+ /**
7
+ * Explicit route pattern for this handler (for example `/users/:id`).
8
+ */
6
9
  route?: string;
10
+ /**
11
+ * Explicit request ID. Skips header lookup/generation when provided.
12
+ */
7
13
  requestId?: string;
14
+ /**
15
+ * Per-handler capture overrides.
16
+ */
8
17
  capture?: Partial<CaptureConfig>;
18
+ /**
19
+ * Per-handler redaction overrides.
20
+ */
9
21
  redaction?: Partial<RedactionConfig>;
22
+ /**
23
+ * Hook called after request context is created.
24
+ */
10
25
  onRequest?: (ctx: XrayContext) => void;
26
+ /**
27
+ * Hook called after the request has been finalized and logged.
28
+ */
11
29
  onResponse?: (ctx: XrayContext, log: RequestLog) => void;
30
+ /**
31
+ * Hook called when request handling fails.
32
+ */
12
33
  onError?: (ctx: XrayContext, err: unknown) => void;
13
34
  }
35
+ /**
36
+ * Wrap a fetch-style handler with X-ray instrumentation.
37
+ *
38
+ * This variant may replace the request/response objects to safely capture
39
+ * bodies and inject a request ID response header when needed.
40
+ */
14
41
  declare function wrapFetch(handler: (req: Request) => Response | Promise<Response>, xray: XrayEmitter, options?: WrapOptions): (req: Request) => Promise<Response>;
42
+ /**
43
+ * Wrap a fetch-style handler while preserving original request/response objects
44
+ * whenever possible.
45
+ *
46
+ * If a missing request ID header must be injected and response headers are
47
+ * immutable, this wrapper may still replace the response object.
48
+ */
15
49
  declare function wrapFetchPreserve(handler: (req: Request) => Response | Promise<Response>, xray: XrayEmitter, options?: WrapOptions): (req: Request) => Promise<Response>;
50
+ /**
51
+ * Retrieve the `XrayContext` bound to a fetch `Request`.
52
+ */
16
53
  declare function getXrayContext(req: Request): XrayContext | undefined;
17
54
 
18
55
  export { type WrapOptions, getXrayContext, wrapFetch, wrapFetchPreserve };
package/dist/fetch.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  getXrayContext,
4
4
  wrapFetch,
5
5
  wrapFetchPreserve
6
- } from "./chunk-W75UIHEF.js";
7
- import "./chunk-VRRPTE7W.js";
6
+ } from "./chunk-LJYBYC7N.js";
7
+ import "./chunk-DKHGODGO.js";
8
8
  import "./chunk-NTIUR3OC.js";
9
9
  import "./chunk-7KT6EPVZ.js";
10
10
  export {
package/dist/hono.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkESBHEKC2cjs = require('./chunk-ESBHEKC2.cjs');
6
- require('./chunk-Q4MTHPUL.cjs');
5
+ var _chunk22W6MSR2cjs = require('./chunk-22W6MSR2.cjs');
6
+ require('./chunk-3LDFK62Q.cjs');
7
7
 
8
8
 
9
9
  var _chunkCPHFCOA5cjs = require('./chunk-CPHFCOA5.cjs');
@@ -11,7 +11,7 @@ require('./chunk-DNBARLGB.cjs');
11
11
 
12
12
  // src/hono/hono.ts
13
13
  function createEmitter2(config, options) {
14
- const emitter = _chunkESBHEKC2cjs.createEmitter.call(void 0, config);
14
+ const emitter = _chunk22W6MSR2cjs.createEmitter.call(void 0, config);
15
15
  const middleware = createHonoMiddleware(emitter, options);
16
16
  middleware.flush = emitter.flush;
17
17
  middleware.shutdown = emitter.shutdown;
@@ -25,9 +25,9 @@ function createHonoMiddleware(xray, options) {
25
25
  await next();
26
26
  return;
27
27
  }
28
- const wrapped = _chunkESBHEKC2cjs.wrapFetchPreserve.call(void 0,
28
+ const wrapped = _chunk22W6MSR2cjs.wrapFetchPreserve.call(void 0,
29
29
  async (req) => {
30
- const ctx = _chunkESBHEKC2cjs.getXrayContext.call(void 0, req);
30
+ const ctx = _chunk22W6MSR2cjs.getXrayContext.call(void 0, req);
31
31
  if (ctx) {
32
32
  c.set("xray", ctx);
33
33
  }
@@ -67,5 +67,5 @@ function resolveRoutePath(fn, ctx, index) {
67
67
 
68
68
 
69
69
 
70
- exports.createCoreEmitter = _chunkESBHEKC2cjs.createEmitter; exports.createEmitter = createEmitter2; exports.createHonoMiddleware = createHonoMiddleware;
70
+ exports.createCoreEmitter = _chunk22W6MSR2cjs.createEmitter; exports.createEmitter = createEmitter2; exports.createHonoMiddleware = createHonoMiddleware;
71
71
  //# sourceMappingURL=hono.cjs.map
package/dist/hono.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/xray-emitter-js/xray-emitter-js/dist/hono.cjs","../src/hono/hono.ts"],"names":["createEmitter"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACmCO,SAASA,cAAAA,CAAc,MAAA,EAA2B,OAAA,EAAwC;AAC/F,EAAA,MAAM,QAAA,EAAU,6CAAA,MAAyB,CAAA;AACzC,EAAA,MAAM,WAAA,EAAa,oBAAA,CAAqB,OAAA,EAAS,OAAO,CAAA;AACxD,EAAA,UAAA,CAAW,MAAA,EAAQ,OAAA,CAAQ,KAAA;AAC3B,EAAA,UAAA,CAAW,SAAA,EAAW,OAAA,CAAQ,QAAA;AAC9B,EAAA,OAAO,UAAA;AACT;AAEO,SAAS,oBAAA,CAAqB,IAAA,EAAmB,OAAA,EAA2C;AACjG,EAAA,MAAM,YAAA,kBAAc,OAAA,2BAAS,WAAA;AAE7B,EAAA,OAAO,MAAA,CAAO,CAAA,EAAG,IAAA,EAAA,GAAS;AACxB,IAAA,MAAM,QAAA,EAAU,CAAA,CAAE,GAAA,CAAI,GAAA;AACtB,IAAA,GAAA,CAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAA,CAAK,CAAA;AACX,MAAA,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,QAAA,EAAU,iDAAA;AAAA,MACd,MAAA,CAAO,GAAA,EAAA,GAAQ;AACb,QAAA,MAAM,IAAA,EAAM,8CAAA,GAAkB,CAAA;AAC9B,QAAA,GAAA,CAAI,GAAA,EAAK;AACP,UAAA,CAAA,CAAE,GAAA,CAAI,MAAA,EAAQ,GAAG,CAAA;AAAA,QACnB;AAEA,QAAA,IAAI,MAAA,EAAQ,gBAAA,CAAiB,WAAA,EAAa,CAAA,EAAG,CAAA,CAAE,CAAA;AAC/C,QAAA,IAAI;AACF,UAAA,MAAM,IAAA,CAAK,CAAA;AACX,UAAA,OAAO,CAAA,CAAE,GAAA;AAAA,QACX,EAAA,QAAE;AACA,UAAA,GAAA,CAAI,CAAC,KAAA,EAAO;AACV,YAAA,MAAA,EAAQ,gBAAA,CAAiB,WAAA,EAAa,CAAC,CAAA;AAAA,UACzC;AACA,UAAA,GAAA,CAAI,MAAA,GAAS,GAAA,EAAK;AAChB,YAAA,+CAAA,GAAgB,EAAK,KAAK,CAAA;AAAA,UAC5B;AAAA,QACF;AAAA,MACF,CAAA;AAAA,MACA,IAAA;AAAA,MACA;AAAA,IACF,CAAA;AAEA,IAAA,MAAM,SAAA,EAAW,MAAM,OAAA,CAAQ,OAAO,CAAA;AACtC,IAAA,GAAA,CAAI,SAAA,WAAoB,SAAA,GAAY,SAAA,IAAa,CAAA,CAAE,GAAA,EAAK;AACtD,MAAA,CAAA,CAAE,IAAA,EAAM,QAAA;AAAA,IACV;AAAA,EACF,CAAA;AACF;AAEA,SAAS,gBAAA,CACP,EAAA,EACA,GAAA,EACA,KAAA,EACoB;AACpB,EAAA,GAAA,CAAI,CAAC,EAAA,EAAI;AACP,IAAA,OAAO,KAAA,CAAA;AAAA,EACT;AACA,EAAA,IAAI;AACF,IAAA,OAAO,MAAA,IAAU,KAAA,EAAA,EAAY,EAAA,CAAG,GAAG,EAAA,EAAI,EAAA,CAAG,GAAA,EAAK,KAAK,CAAA;AAAA,EACtD,EAAA,UAAQ;AACN,IAAA,OAAO,KAAA,CAAA;AAAA,EACT;AACF;AD3CA;AACE;AACA;AACA;AACF,yJAAC","file":"/home/runner/work/xray-emitter-js/xray-emitter-js/dist/hono.cjs","sourcesContent":[null,"import type { XrayEmitter, XrayContext, XrayRuntimeConfig } from '../core/index';\nimport { setContextRoute } from '../core/internal';\nimport {\n createEmitter as createFetchEmitter,\n getXrayContext,\n wrapFetchPreserve,\n type WrapOptions,\n} from '../fetch/fetch';\n\nexport { createFetchEmitter as createCoreEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n XrayRuntimeConfig,\n} from '../core/index';\nexport type { WrapOptions } from '../fetch/fetch';\n\n// copy types from Hono to avoid a package dependency\ninterface HonoCompatibleContext {\n req: { raw: Request };\n res: Response;\n set(key: string, value: unknown): void;\n}\n\ntype HonoMiddleware = (\n c: HonoCompatibleContext,\n next: () => Promise<void>,\n) => Promise<void | Response>;\n\nexport type HonoXrayEnv = {\n Variables: { xray?: XrayContext };\n};\n\ntype HonoEmitter = HonoMiddleware & {\n flush: XrayEmitter['flush'];\n shutdown: XrayEmitter['shutdown'];\n};\n\nexport interface HonoWrapOptions extends WrapOptions {\n routePath?(ctx: HonoCompatibleContext, index?: number): string;\n}\n\nexport function createEmitter(config: XrayRuntimeConfig, options?: HonoWrapOptions): HonoEmitter {\n const emitter = createFetchEmitter(config);\n const middleware = createHonoMiddleware(emitter, options) as HonoEmitter;\n middleware.flush = emitter.flush;\n middleware.shutdown = emitter.shutdown;\n return middleware;\n}\n\nexport function createHonoMiddleware(xray: XrayEmitter, options?: HonoWrapOptions): HonoMiddleware {\n const routePathFn = options?.routePath;\n\n return async (c, next) => {\n const request = c.req.raw;\n if (!request) {\n await next();\n return;\n }\n\n const wrapped = wrapFetchPreserve(\n async (req) => {\n const ctx = getXrayContext(req);\n if (ctx) {\n c.set('xray', ctx);\n }\n\n let route = resolveRoutePath(routePathFn, c, -1);\n try {\n await next();\n return c.res;\n } finally {\n if (!route) {\n route = resolveRoutePath(routePathFn, c);\n }\n if (route && ctx) {\n setContextRoute(ctx, route);\n }\n }\n },\n xray,\n options,\n );\n\n const response = await wrapped(request);\n if (response instanceof Response && response !== c.res) {\n c.res = response;\n }\n };\n}\n\nfunction resolveRoutePath(\n fn: ((ctx: HonoCompatibleContext, index?: number) => string) | undefined,\n ctx: HonoCompatibleContext,\n index?: number,\n): string | undefined {\n if (!fn) {\n return undefined;\n }\n try {\n return index === undefined ? fn(ctx) : fn(ctx, index);\n } catch {\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/xray-emitter-js/xray-emitter-js/dist/hono.cjs","../src/hono/hono.ts"],"names":["createEmitter"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACA;AC4CO,SAASA,cAAAA,CAAc,MAAA,EAA2B,OAAA,EAAwC;AAC/F,EAAA,MAAM,QAAA,EAAU,6CAAA,MAAyB,CAAA;AACzC,EAAA,MAAM,WAAA,EAAa,oBAAA,CAAqB,OAAA,EAAS,OAAO,CAAA;AACxD,EAAA,UAAA,CAAW,MAAA,EAAQ,OAAA,CAAQ,KAAA;AAC3B,EAAA,UAAA,CAAW,SAAA,EAAW,OAAA,CAAQ,QAAA;AAC9B,EAAA,OAAO,UAAA;AACT;AAKO,SAAS,oBAAA,CAAqB,IAAA,EAAmB,OAAA,EAA2C;AACjG,EAAA,MAAM,YAAA,kBAAc,OAAA,2BAAS,WAAA;AAE7B,EAAA,OAAO,MAAA,CAAO,CAAA,EAAG,IAAA,EAAA,GAAS;AACxB,IAAA,MAAM,QAAA,EAAU,CAAA,CAAE,GAAA,CAAI,GAAA;AACtB,IAAA,GAAA,CAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAA,CAAK,CAAA;AACX,MAAA,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,QAAA,EAAU,iDAAA;AAAA,MACd,MAAA,CAAO,GAAA,EAAA,GAAQ;AACb,QAAA,MAAM,IAAA,EAAM,8CAAA,GAAkB,CAAA;AAC9B,QAAA,GAAA,CAAI,GAAA,EAAK;AACP,UAAA,CAAA,CAAE,GAAA,CAAI,MAAA,EAAQ,GAAG,CAAA;AAAA,QACnB;AAEA,QAAA,IAAI,MAAA,EAAQ,gBAAA,CAAiB,WAAA,EAAa,CAAA,EAAG,CAAA,CAAE,CAAA;AAC/C,QAAA,IAAI;AACF,UAAA,MAAM,IAAA,CAAK,CAAA;AACX,UAAA,OAAO,CAAA,CAAE,GAAA;AAAA,QACX,EAAA,QAAE;AACA,UAAA,GAAA,CAAI,CAAC,KAAA,EAAO;AACV,YAAA,MAAA,EAAQ,gBAAA,CAAiB,WAAA,EAAa,CAAC,CAAA;AAAA,UACzC;AACA,UAAA,GAAA,CAAI,MAAA,GAAS,GAAA,EAAK;AAChB,YAAA,+CAAA,GAAgB,EAAK,KAAK,CAAA;AAAA,UAC5B;AAAA,QACF;AAAA,MACF,CAAA;AAAA,MACA,IAAA;AAAA,MACA;AAAA,IACF,CAAA;AAEA,IAAA,MAAM,SAAA,EAAW,MAAM,OAAA,CAAQ,OAAO,CAAA;AACtC,IAAA,GAAA,CAAI,SAAA,WAAoB,SAAA,GAAY,SAAA,IAAa,CAAA,CAAE,GAAA,EAAK;AACtD,MAAA,CAAA,CAAE,IAAA,EAAM,QAAA;AAAA,IACV;AAAA,EACF,CAAA;AACF;AAEA,SAAS,gBAAA,CACP,EAAA,EACA,GAAA,EACA,KAAA,EACoB;AACpB,EAAA,GAAA,CAAI,CAAC,EAAA,EAAI;AACP,IAAA,OAAO,KAAA,CAAA;AAAA,EACT;AACA,EAAA,IAAI;AACF,IAAA,OAAO,MAAA,IAAU,KAAA,EAAA,EAAY,EAAA,CAAG,GAAG,EAAA,EAAI,EAAA,CAAG,GAAA,EAAK,KAAK,CAAA;AAAA,EACtD,EAAA,UAAQ;AACN,IAAA,OAAO,KAAA,CAAA;AAAA,EACT;AACF;ADvDA;AACE;AACA;AACA;AACF,yJAAC","file":"/home/runner/work/xray-emitter-js/xray-emitter-js/dist/hono.cjs","sourcesContent":[null,"import type { XrayEmitter, XrayContext, XrayRuntimeConfig } from '../core/index';\nimport { setContextRoute } from '../core/internal';\nimport {\n createEmitter as createFetchEmitter,\n getXrayContext,\n wrapFetchPreserve,\n type WrapOptions,\n} from '../fetch/fetch';\n\nexport { createFetchEmitter as createCoreEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n XrayRuntimeConfig,\n} from '../core/index';\nexport type { WrapOptions } from '../fetch/fetch';\n\n// copy types from Hono to avoid a package dependency\ninterface HonoCompatibleContext {\n req: { raw: Request };\n res: Response;\n set(key: string, value: unknown): void;\n}\n\ntype HonoMiddleware = (\n c: HonoCompatibleContext,\n next: () => Promise<void>,\n) => Promise<void | Response>;\n\n/**\n * Hono env helper that adds `xray` to `c.get(...)` variables.\n */\nexport type HonoXrayEnv = {\n Variables: { xray?: XrayContext };\n};\n\ntype HonoEmitter = HonoMiddleware & {\n flush: XrayEmitter['flush'];\n shutdown: XrayEmitter['shutdown'];\n};\n\nexport interface HonoWrapOptions extends WrapOptions {\n /**\n * Optional route resolver used to capture Hono route patterns.\n */\n routePath?(ctx: HonoCompatibleContext, index?: number): string;\n}\n\n/**\n * Create Hono middleware and expose `flush()`/`shutdown()` helpers.\n */\nexport function createEmitter(config: XrayRuntimeConfig, options?: HonoWrapOptions): HonoEmitter {\n const emitter = createFetchEmitter(config);\n const middleware = createHonoMiddleware(emitter, options) as HonoEmitter;\n middleware.flush = emitter.flush;\n middleware.shutdown = emitter.shutdown;\n return middleware;\n}\n\n/**\n * Create Hono middleware from an existing core `XrayEmitter`.\n */\nexport function createHonoMiddleware(xray: XrayEmitter, options?: HonoWrapOptions): HonoMiddleware {\n const routePathFn = options?.routePath;\n\n return async (c, next) => {\n const request = c.req.raw;\n if (!request) {\n await next();\n return;\n }\n\n const wrapped = wrapFetchPreserve(\n async (req) => {\n const ctx = getXrayContext(req);\n if (ctx) {\n c.set('xray', ctx);\n }\n\n let route = resolveRoutePath(routePathFn, c, -1);\n try {\n await next();\n return c.res;\n } finally {\n if (!route) {\n route = resolveRoutePath(routePathFn, c);\n }\n if (route && ctx) {\n setContextRoute(ctx, route);\n }\n }\n },\n xray,\n options,\n );\n\n const response = await wrapped(request);\n if (response instanceof Response && response !== c.res) {\n c.res = response;\n }\n };\n}\n\nfunction resolveRoutePath(\n fn: ((ctx: HonoCompatibleContext, index?: number) => string) | undefined,\n ctx: HonoCompatibleContext,\n index?: number,\n): string | undefined {\n if (!fn) {\n return undefined;\n }\n try {\n return index === undefined ? fn(ctx) : fn(ctx, index);\n } catch {\n return undefined;\n }\n}\n"]}
package/dist/hono.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { d as XrayContext, j as XrayRuntimeConfig, a as XrayEmitter } from './types-Diy-KLjz.cjs';
2
- export { e as CaptureConfig, f as RedactionConfig, R as RequestLog, X as XrayConfig } from './types-Diy-KLjz.cjs';
3
- export { c as createCoreEmitter } from './emitter-Cdl6H6vk.cjs';
1
+ import { d as XrayContext, j as XrayRuntimeConfig, a as XrayEmitter } from './types-BrKvhHbn.cjs';
2
+ export { e as CaptureConfig, f as RedactionConfig, R as RequestLog, X as XrayConfig } from './types-BrKvhHbn.cjs';
3
+ export { c as createCoreEmitter } from './emitter-Bi_m_w5h.cjs';
4
4
  import { WrapOptions } from './fetch.cjs';
5
5
  import '@opentelemetry/sdk-trace-base';
6
6
 
@@ -12,6 +12,9 @@ interface HonoCompatibleContext {
12
12
  set(key: string, value: unknown): void;
13
13
  }
14
14
  type HonoMiddleware = (c: HonoCompatibleContext, next: () => Promise<void>) => Promise<void | Response>;
15
+ /**
16
+ * Hono env helper that adds `xray` to `c.get(...)` variables.
17
+ */
15
18
  type HonoXrayEnv = {
16
19
  Variables: {
17
20
  xray?: XrayContext;
@@ -22,9 +25,18 @@ type HonoEmitter = HonoMiddleware & {
22
25
  shutdown: XrayEmitter['shutdown'];
23
26
  };
24
27
  interface HonoWrapOptions extends WrapOptions {
28
+ /**
29
+ * Optional route resolver used to capture Hono route patterns.
30
+ */
25
31
  routePath?(ctx: HonoCompatibleContext, index?: number): string;
26
32
  }
33
+ /**
34
+ * Create Hono middleware and expose `flush()`/`shutdown()` helpers.
35
+ */
27
36
  declare function createEmitter(config: XrayRuntimeConfig, options?: HonoWrapOptions): HonoEmitter;
37
+ /**
38
+ * Create Hono middleware from an existing core `XrayEmitter`.
39
+ */
28
40
  declare function createHonoMiddleware(xray: XrayEmitter, options?: HonoWrapOptions): HonoMiddleware;
29
41
 
30
42
  export { type HonoWrapOptions, type HonoXrayEnv, WrapOptions, XrayContext, XrayEmitter, XrayRuntimeConfig, createEmitter, createHonoMiddleware };
package/dist/hono.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { d as XrayContext, j as XrayRuntimeConfig, a as XrayEmitter } from './types-Diy-KLjz.js';
2
- export { e as CaptureConfig, f as RedactionConfig, R as RequestLog, X as XrayConfig } from './types-Diy-KLjz.js';
3
- export { c as createCoreEmitter } from './emitter-DnDvQw9i.js';
1
+ import { d as XrayContext, j as XrayRuntimeConfig, a as XrayEmitter } from './types-BrKvhHbn.js';
2
+ export { e as CaptureConfig, f as RedactionConfig, R as RequestLog, X as XrayConfig } from './types-BrKvhHbn.js';
3
+ export { c as createCoreEmitter } from './emitter-Dy7bRGTq.js';
4
4
  import { WrapOptions } from './fetch.js';
5
5
  import '@opentelemetry/sdk-trace-base';
6
6
 
@@ -12,6 +12,9 @@ interface HonoCompatibleContext {
12
12
  set(key: string, value: unknown): void;
13
13
  }
14
14
  type HonoMiddleware = (c: HonoCompatibleContext, next: () => Promise<void>) => Promise<void | Response>;
15
+ /**
16
+ * Hono env helper that adds `xray` to `c.get(...)` variables.
17
+ */
15
18
  type HonoXrayEnv = {
16
19
  Variables: {
17
20
  xray?: XrayContext;
@@ -22,9 +25,18 @@ type HonoEmitter = HonoMiddleware & {
22
25
  shutdown: XrayEmitter['shutdown'];
23
26
  };
24
27
  interface HonoWrapOptions extends WrapOptions {
28
+ /**
29
+ * Optional route resolver used to capture Hono route patterns.
30
+ */
25
31
  routePath?(ctx: HonoCompatibleContext, index?: number): string;
26
32
  }
33
+ /**
34
+ * Create Hono middleware and expose `flush()`/`shutdown()` helpers.
35
+ */
27
36
  declare function createEmitter(config: XrayRuntimeConfig, options?: HonoWrapOptions): HonoEmitter;
37
+ /**
38
+ * Create Hono middleware from an existing core `XrayEmitter`.
39
+ */
28
40
  declare function createHonoMiddleware(xray: XrayEmitter, options?: HonoWrapOptions): HonoMiddleware;
29
41
 
30
42
  export { type HonoWrapOptions, type HonoXrayEnv, WrapOptions, XrayContext, XrayEmitter, XrayRuntimeConfig, createEmitter, createHonoMiddleware };
package/dist/hono.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  createEmitter,
3
3
  getXrayContext,
4
4
  wrapFetchPreserve
5
- } from "./chunk-W75UIHEF.js";
6
- import "./chunk-VRRPTE7W.js";
5
+ } from "./chunk-LJYBYC7N.js";
6
+ import "./chunk-DKHGODGO.js";
7
7
  import {
8
8
  setContextRoute
9
9
  } from "./chunk-NTIUR3OC.js";
package/dist/hono.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hono/hono.ts"],"sourcesContent":["import type { XrayEmitter, XrayContext, XrayRuntimeConfig } from '../core/index';\nimport { setContextRoute } from '../core/internal';\nimport {\n createEmitter as createFetchEmitter,\n getXrayContext,\n wrapFetchPreserve,\n type WrapOptions,\n} from '../fetch/fetch';\n\nexport { createFetchEmitter as createCoreEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n XrayRuntimeConfig,\n} from '../core/index';\nexport type { WrapOptions } from '../fetch/fetch';\n\n// copy types from Hono to avoid a package dependency\ninterface HonoCompatibleContext {\n req: { raw: Request };\n res: Response;\n set(key: string, value: unknown): void;\n}\n\ntype HonoMiddleware = (\n c: HonoCompatibleContext,\n next: () => Promise<void>,\n) => Promise<void | Response>;\n\nexport type HonoXrayEnv = {\n Variables: { xray?: XrayContext };\n};\n\ntype HonoEmitter = HonoMiddleware & {\n flush: XrayEmitter['flush'];\n shutdown: XrayEmitter['shutdown'];\n};\n\nexport interface HonoWrapOptions extends WrapOptions {\n routePath?(ctx: HonoCompatibleContext, index?: number): string;\n}\n\nexport function createEmitter(config: XrayRuntimeConfig, options?: HonoWrapOptions): HonoEmitter {\n const emitter = createFetchEmitter(config);\n const middleware = createHonoMiddleware(emitter, options) as HonoEmitter;\n middleware.flush = emitter.flush;\n middleware.shutdown = emitter.shutdown;\n return middleware;\n}\n\nexport function createHonoMiddleware(xray: XrayEmitter, options?: HonoWrapOptions): HonoMiddleware {\n const routePathFn = options?.routePath;\n\n return async (c, next) => {\n const request = c.req.raw;\n if (!request) {\n await next();\n return;\n }\n\n const wrapped = wrapFetchPreserve(\n async (req) => {\n const ctx = getXrayContext(req);\n if (ctx) {\n c.set('xray', ctx);\n }\n\n let route = resolveRoutePath(routePathFn, c, -1);\n try {\n await next();\n return c.res;\n } finally {\n if (!route) {\n route = resolveRoutePath(routePathFn, c);\n }\n if (route && ctx) {\n setContextRoute(ctx, route);\n }\n }\n },\n xray,\n options,\n );\n\n const response = await wrapped(request);\n if (response instanceof Response && response !== c.res) {\n c.res = response;\n }\n };\n}\n\nfunction resolveRoutePath(\n fn: ((ctx: HonoCompatibleContext, index?: number) => string) | undefined,\n ctx: HonoCompatibleContext,\n index?: number,\n): string | undefined {\n if (!fn) {\n return undefined;\n }\n try {\n return index === undefined ? fn(ctx) : fn(ctx, index);\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;AA8CO,SAASA,eAAc,QAA2B,SAAwC;AAC/F,QAAM,UAAU,cAAmB,MAAM;AACzC,QAAM,aAAa,qBAAqB,SAAS,OAAO;AACxD,aAAW,QAAQ,QAAQ;AAC3B,aAAW,WAAW,QAAQ;AAC9B,SAAO;AACT;AAEO,SAAS,qBAAqB,MAAmB,SAA2C;AACjG,QAAM,cAAc,SAAS;AAE7B,SAAO,OAAO,GAAG,SAAS;AACxB,UAAM,UAAU,EAAE,IAAI;AACtB,QAAI,CAAC,SAAS;AACZ,YAAM,KAAK;AACX;AAAA,IACF;AAEA,UAAM,UAAU;AAAA,MACd,OAAO,QAAQ;AACb,cAAM,MAAM,eAAe,GAAG;AAC9B,YAAI,KAAK;AACP,YAAE,IAAI,QAAQ,GAAG;AAAA,QACnB;AAEA,YAAI,QAAQ,iBAAiB,aAAa,GAAG,EAAE;AAC/C,YAAI;AACF,gBAAM,KAAK;AACX,iBAAO,EAAE;AAAA,QACX,UAAE;AACA,cAAI,CAAC,OAAO;AACV,oBAAQ,iBAAiB,aAAa,CAAC;AAAA,UACzC;AACA,cAAI,SAAS,KAAK;AAChB,4BAAgB,KAAK,KAAK;AAAA,UAC5B;AAAA,QACF;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,QAAQ,OAAO;AACtC,QAAI,oBAAoB,YAAY,aAAa,EAAE,KAAK;AACtD,QAAE,MAAM;AAAA,IACV;AAAA,EACF;AACF;AAEA,SAAS,iBACP,IACA,KACA,OACoB;AACpB,MAAI,CAAC,IAAI;AACP,WAAO;AAAA,EACT;AACA,MAAI;AACF,WAAO,UAAU,SAAY,GAAG,GAAG,IAAI,GAAG,KAAK,KAAK;AAAA,EACtD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["createEmitter"]}
1
+ {"version":3,"sources":["../src/hono/hono.ts"],"sourcesContent":["import type { XrayEmitter, XrayContext, XrayRuntimeConfig } from '../core/index';\nimport { setContextRoute } from '../core/internal';\nimport {\n createEmitter as createFetchEmitter,\n getXrayContext,\n wrapFetchPreserve,\n type WrapOptions,\n} from '../fetch/fetch';\n\nexport { createFetchEmitter as createCoreEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n XrayRuntimeConfig,\n} from '../core/index';\nexport type { WrapOptions } from '../fetch/fetch';\n\n// copy types from Hono to avoid a package dependency\ninterface HonoCompatibleContext {\n req: { raw: Request };\n res: Response;\n set(key: string, value: unknown): void;\n}\n\ntype HonoMiddleware = (\n c: HonoCompatibleContext,\n next: () => Promise<void>,\n) => Promise<void | Response>;\n\n/**\n * Hono env helper that adds `xray` to `c.get(...)` variables.\n */\nexport type HonoXrayEnv = {\n Variables: { xray?: XrayContext };\n};\n\ntype HonoEmitter = HonoMiddleware & {\n flush: XrayEmitter['flush'];\n shutdown: XrayEmitter['shutdown'];\n};\n\nexport interface HonoWrapOptions extends WrapOptions {\n /**\n * Optional route resolver used to capture Hono route patterns.\n */\n routePath?(ctx: HonoCompatibleContext, index?: number): string;\n}\n\n/**\n * Create Hono middleware and expose `flush()`/`shutdown()` helpers.\n */\nexport function createEmitter(config: XrayRuntimeConfig, options?: HonoWrapOptions): HonoEmitter {\n const emitter = createFetchEmitter(config);\n const middleware = createHonoMiddleware(emitter, options) as HonoEmitter;\n middleware.flush = emitter.flush;\n middleware.shutdown = emitter.shutdown;\n return middleware;\n}\n\n/**\n * Create Hono middleware from an existing core `XrayEmitter`.\n */\nexport function createHonoMiddleware(xray: XrayEmitter, options?: HonoWrapOptions): HonoMiddleware {\n const routePathFn = options?.routePath;\n\n return async (c, next) => {\n const request = c.req.raw;\n if (!request) {\n await next();\n return;\n }\n\n const wrapped = wrapFetchPreserve(\n async (req) => {\n const ctx = getXrayContext(req);\n if (ctx) {\n c.set('xray', ctx);\n }\n\n let route = resolveRoutePath(routePathFn, c, -1);\n try {\n await next();\n return c.res;\n } finally {\n if (!route) {\n route = resolveRoutePath(routePathFn, c);\n }\n if (route && ctx) {\n setContextRoute(ctx, route);\n }\n }\n },\n xray,\n options,\n );\n\n const response = await wrapped(request);\n if (response instanceof Response && response !== c.res) {\n c.res = response;\n }\n };\n}\n\nfunction resolveRoutePath(\n fn: ((ctx: HonoCompatibleContext, index?: number) => string) | undefined,\n ctx: HonoCompatibleContext,\n index?: number,\n): string | undefined {\n if (!fn) {\n return undefined;\n }\n try {\n return index === undefined ? fn(ctx) : fn(ctx, index);\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAuDO,SAASA,eAAc,QAA2B,SAAwC;AAC/F,QAAM,UAAU,cAAmB,MAAM;AACzC,QAAM,aAAa,qBAAqB,SAAS,OAAO;AACxD,aAAW,QAAQ,QAAQ;AAC3B,aAAW,WAAW,QAAQ;AAC9B,SAAO;AACT;AAKO,SAAS,qBAAqB,MAAmB,SAA2C;AACjG,QAAM,cAAc,SAAS;AAE7B,SAAO,OAAO,GAAG,SAAS;AACxB,UAAM,UAAU,EAAE,IAAI;AACtB,QAAI,CAAC,SAAS;AACZ,YAAM,KAAK;AACX;AAAA,IACF;AAEA,UAAM,UAAU;AAAA,MACd,OAAO,QAAQ;AACb,cAAM,MAAM,eAAe,GAAG;AAC9B,YAAI,KAAK;AACP,YAAE,IAAI,QAAQ,GAAG;AAAA,QACnB;AAEA,YAAI,QAAQ,iBAAiB,aAAa,GAAG,EAAE;AAC/C,YAAI;AACF,gBAAM,KAAK;AACX,iBAAO,EAAE;AAAA,QACX,UAAE;AACA,cAAI,CAAC,OAAO;AACV,oBAAQ,iBAAiB,aAAa,CAAC;AAAA,UACzC;AACA,cAAI,SAAS,KAAK;AAChB,4BAAgB,KAAK,KAAK;AAAA,UAC5B;AAAA,QACF;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,QAAQ,OAAO;AACtC,QAAI,oBAAoB,YAAY,aAAa,EAAE,KAAK;AACtD,QAAE,MAAM;AAAA,IACV;AAAA,EACF;AACF;AAEA,SAAS,iBACP,IACA,KACA,OACoB;AACpB,MAAI,CAAC,IAAI;AACP,WAAO;AAAA,EACT;AACA,MAAI;AACF,WAAO,UAAU,SAAY,GAAG,GAAG,IAAI,GAAG,KAAK,KAAK;AAAA,EACtD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["createEmitter"]}
package/dist/index.cjs CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkQ4MTHPULcjs = require('./chunk-Q4MTHPUL.cjs');
5
+ var _chunk3LDFK62Qcjs = require('./chunk-3LDFK62Q.cjs');
6
6
  require('./chunk-DNBARLGB.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
- exports.XrayConfigError = _chunkQ4MTHPULcjs.XrayConfigError; exports.createEmitter = _chunkQ4MTHPULcjs.createEmitter; exports.normalizeConfig = _chunkQ4MTHPULcjs.normalizeConfig;
11
+ exports.XrayConfigError = _chunk3LDFK62Qcjs.XrayConfigError; exports.createEmitter = _chunk3LDFK62Qcjs.createEmitter; exports.normalizeConfig = _chunk3LDFK62Qcjs.normalizeConfig;
12
12
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -1,7 +1,13 @@
1
- import { X as XrayConfig, a as XrayEmitter } from './types-Diy-KLjz.cjs';
2
- export { A as AttributeValue, e as CaptureConfig, C as CapturedBody, E as ExporterConfig, L as LogLevel, b as Logger, N as NormalizedRequest, c as NormalizedResponse, f as RedactionConfig, g as RequestIdConfig, R as RequestLog, h as ResolvedXrayConfig, i as RouteConfig, k as XrayConfigError, d as XrayContext, j as XrayRuntimeConfig, n as normalizeConfig } from './types-Diy-KLjz.cjs';
1
+ import { X as XrayConfig, a as XrayEmitter } from './types-BrKvhHbn.cjs';
2
+ export { A as AttributeValue, e as CaptureConfig, C as CapturedBody, E as ExporterConfig, L as LogLevel, b as Logger, N as NormalizedRequest, c as NormalizedResponse, f as RedactionConfig, g as RequestIdConfig, R as RequestLog, h as ResolvedXrayConfig, i as RouteConfig, k as XrayConfigError, d as XrayContext, j as XrayRuntimeConfig, n as normalizeConfig } from './types-BrKvhHbn.cjs';
3
3
  import { SpanExporter } from '@opentelemetry/sdk-trace-base';
4
4
 
5
+ /**
6
+ * Create a runtime-agnostic X-ray emitter with a provided SpanExporter.
7
+ *
8
+ * Most applications should use a runtime adapter (`/node`, `/fetch`,
9
+ * or framework-specific entrypoints) unless they need custom transport logic.
10
+ */
5
11
  declare function createEmitter(config: XrayConfig, exporter: SpanExporter): XrayEmitter;
6
12
 
7
13
  export { XrayConfig, XrayEmitter, createEmitter };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,13 @@
1
- import { X as XrayConfig, a as XrayEmitter } from './types-Diy-KLjz.js';
2
- export { A as AttributeValue, e as CaptureConfig, C as CapturedBody, E as ExporterConfig, L as LogLevel, b as Logger, N as NormalizedRequest, c as NormalizedResponse, f as RedactionConfig, g as RequestIdConfig, R as RequestLog, h as ResolvedXrayConfig, i as RouteConfig, k as XrayConfigError, d as XrayContext, j as XrayRuntimeConfig, n as normalizeConfig } from './types-Diy-KLjz.js';
1
+ import { X as XrayConfig, a as XrayEmitter } from './types-BrKvhHbn.js';
2
+ export { A as AttributeValue, e as CaptureConfig, C as CapturedBody, E as ExporterConfig, L as LogLevel, b as Logger, N as NormalizedRequest, c as NormalizedResponse, f as RedactionConfig, g as RequestIdConfig, R as RequestLog, h as ResolvedXrayConfig, i as RouteConfig, k as XrayConfigError, d as XrayContext, j as XrayRuntimeConfig, n as normalizeConfig } from './types-BrKvhHbn.js';
3
3
  import { SpanExporter } from '@opentelemetry/sdk-trace-base';
4
4
 
5
+ /**
6
+ * Create a runtime-agnostic X-ray emitter with a provided SpanExporter.
7
+ *
8
+ * Most applications should use a runtime adapter (`/node`, `/fetch`,
9
+ * or framework-specific entrypoints) unless they need custom transport logic.
10
+ */
5
11
  declare function createEmitter(config: XrayConfig, exporter: SpanExporter): XrayEmitter;
6
12
 
7
13
  export { XrayConfig, XrayEmitter, createEmitter };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  XrayConfigError,
3
3
  createEmitter,
4
4
  normalizeConfig
5
- } from "./chunk-VRRPTE7W.js";
5
+ } from "./chunk-DKHGODGO.js";
6
6
  import "./chunk-7KT6EPVZ.js";
7
7
  export {
8
8
  XrayConfigError,
@@ -1,4 +1,4 @@
1
- import { C as CapturedBody, b as Logger, L as LogLevel, d as XrayContext, e as CaptureConfig, f as RedactionConfig } from './types-Diy-KLjz.cjs';
1
+ import { C as CapturedBody, b as Logger, L as LogLevel, d as XrayContext, e as CaptureConfig, f as RedactionConfig } from './types-BrKvhHbn.cjs';
2
2
  import '@opentelemetry/sdk-trace-base';
3
3
 
4
4
  declare function makeCapturedBody(bytes: Uint8Array | undefined, totalBytes: number, truncated: boolean, mode: 'text' | 'base64'): CapturedBody | undefined;
@@ -1,4 +1,4 @@
1
- import { C as CapturedBody, b as Logger, L as LogLevel, d as XrayContext, e as CaptureConfig, f as RedactionConfig } from './types-Diy-KLjz.js';
1
+ import { C as CapturedBody, b as Logger, L as LogLevel, d as XrayContext, e as CaptureConfig, f as RedactionConfig } from './types-BrKvhHbn.js';
2
2
  import '@opentelemetry/sdk-trace-base';
3
3
 
4
4
  declare function makeCapturedBody(bytes: Uint8Array | undefined, totalBytes: number, truncated: boolean, mode: 'text' | 'base64'): CapturedBody | undefined;
package/dist/next.cjs CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkESBHEKC2cjs = require('./chunk-ESBHEKC2.cjs');
6
- require('./chunk-Q4MTHPUL.cjs');
5
+ var _chunk22W6MSR2cjs = require('./chunk-22W6MSR2.cjs');
6
+ require('./chunk-3LDFK62Q.cjs');
7
7
  require('./chunk-CPHFCOA5.cjs');
8
8
  require('./chunk-DNBARLGB.cjs');
9
9
 
10
10
  // src/next/next.ts
11
11
  function createEmitter2(config, options) {
12
- const emitter = _chunkESBHEKC2cjs.createEmitter.call(void 0, config);
12
+ const emitter = _chunk22W6MSR2cjs.createEmitter.call(void 0, config);
13
13
  const wrap = ((handler) => wrapNextRoute(handler, emitter, options));
14
14
  wrap.flush = emitter.flush;
15
15
  wrap.shutdown = emitter.shutdown;
@@ -17,7 +17,7 @@ function createEmitter2(config, options) {
17
17
  }
18
18
  function wrapNextRoute(handler, xray, options) {
19
19
  return async (request, context) => {
20
- const wrapped = _chunkESBHEKC2cjs.wrapFetchPreserve.call(void 0, (req) => handler(req, context), xray, options);
20
+ const wrapped = _chunk22W6MSR2cjs.wrapFetchPreserve.call(void 0, (req) => handler(req, context), xray, options);
21
21
  return wrapped(request);
22
22
  };
23
23
  }
@@ -26,5 +26,5 @@ function wrapNextRoute(handler, xray, options) {
26
26
 
27
27
 
28
28
 
29
- exports.createCoreEmitter = _chunkESBHEKC2cjs.createEmitter; exports.createEmitter = createEmitter2; exports.getXrayContext = _chunkESBHEKC2cjs.getXrayContext; exports.wrapNextRoute = wrapNextRoute;
29
+ exports.createCoreEmitter = _chunk22W6MSR2cjs.createEmitter; exports.createEmitter = createEmitter2; exports.getXrayContext = _chunk22W6MSR2cjs.getXrayContext; exports.wrapNextRoute = wrapNextRoute;
30
30
  //# sourceMappingURL=next.cjs.map
package/dist/next.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/xray-emitter-js/xray-emitter-js/dist/next.cjs","../src/next/next.ts"],"names":["createEmitter"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACA;AC2BO,SAASA,cAAAA,CAAc,MAAA,EAA2B,OAAA,EAAoC;AAC3F,EAAA,MAAM,QAAA,EAAU,6CAAA,MAAyB,CAAA;AACzC,EAAA,MAAM,KAAA,EAAA,CAAQ,CAAC,OAAA,EAAA,GACb,aAAA,CAAc,OAAA,EAAS,OAAA,EAAS,OAAO,CAAA,CAAA;AACzC,EAAA,IAAA,CAAK,MAAA,EAAQ,OAAA,CAAQ,KAAA;AACrB,EAAA,IAAA,CAAK,SAAA,EAAW,OAAA,CAAQ,QAAA;AACxB,EAAA,OAAO,IAAA;AACT;AAEO,SAAS,aAAA,CACd,OAAA,EACA,IAAA,EACA,OAAA,EACoE;AACpE,EAAA,OAAO,MAAA,CAAO,OAAA,EAAS,OAAA,EAAA,GAAY;AACjC,IAAA,MAAM,QAAA,EAAU,iDAAA,CAAmB,GAAA,EAAA,GAAiB,OAAA,CAAQ,GAAA,EAAK,OAAO,CAAA,EAAG,IAAA,EAAM,OAAO,CAAA;AACxF,IAAA,OAAO,OAAA,CAAQ,OAAO,CAAA;AAAA,EACxB,CAAA;AACF;AD/BA;AACE;AACA;AACA;AACA;AACF,sMAAC","file":"/home/runner/work/xray-emitter-js/xray-emitter-js/dist/next.cjs","sourcesContent":[null,"import type { XrayEmitter, XrayRuntimeConfig } from '../core/index';\nimport {\n createEmitter as createFetchEmitter,\n getXrayContext,\n wrapFetchPreserve,\n type WrapOptions,\n} from '../fetch/fetch';\n\nexport { createFetchEmitter as createCoreEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n XrayRuntimeConfig,\n} from '../core/index';\nexport type { WrapOptions } from '../fetch/fetch';\nexport { getXrayContext };\n\n// copy types from Next.js to avoid a package dependency\ntype NextRouteContext = {\n params: Promise<Record<string, string | string[]>>;\n};\n\ntype NextRouteHandler = (\n request: Request,\n context: NextRouteContext,\n) => Response | Promise<Response>;\n\ntype NextEmitter = ((handler: NextRouteHandler) => ReturnType<typeof wrapNextRoute>) & {\n flush: XrayEmitter['flush'];\n shutdown: XrayEmitter['shutdown'];\n};\n\nexport function createEmitter(config: XrayRuntimeConfig, options?: WrapOptions): NextEmitter {\n const emitter = createFetchEmitter(config);\n const wrap = ((handler: NextRouteHandler) =>\n wrapNextRoute(handler, emitter, options)) as NextEmitter;\n wrap.flush = emitter.flush;\n wrap.shutdown = emitter.shutdown;\n return wrap;\n}\n\nexport function wrapNextRoute(\n handler: NextRouteHandler,\n xray: XrayEmitter,\n options?: WrapOptions,\n): (request: Request, context: NextRouteContext) => Promise<Response> {\n return async (request, context) => {\n const wrapped = wrapFetchPreserve((req: Request) => handler(req, context), xray, options);\n return wrapped(request);\n };\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/xray-emitter-js/xray-emitter-js/dist/next.cjs","../src/next/next.ts"],"names":["createEmitter"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACA;AC8BO,SAASA,cAAAA,CAAc,MAAA,EAA2B,OAAA,EAAoC;AAC3F,EAAA,MAAM,QAAA,EAAU,6CAAA,MAAyB,CAAA;AACzC,EAAA,MAAM,KAAA,EAAA,CAAQ,CAAC,OAAA,EAAA,GACb,aAAA,CAAc,OAAA,EAAS,OAAA,EAAS,OAAO,CAAA,CAAA;AACzC,EAAA,IAAA,CAAK,MAAA,EAAQ,OAAA,CAAQ,KAAA;AACrB,EAAA,IAAA,CAAK,SAAA,EAAW,OAAA,CAAQ,QAAA;AACxB,EAAA,OAAO,IAAA;AACT;AAKO,SAAS,aAAA,CACd,OAAA,EACA,IAAA,EACA,OAAA,EACoE;AACpE,EAAA,OAAO,MAAA,CAAO,OAAA,EAAS,OAAA,EAAA,GAAY;AACjC,IAAA,MAAM,QAAA,EAAU,iDAAA,CAAmB,GAAA,EAAA,GAAiB,OAAA,CAAQ,GAAA,EAAK,OAAO,CAAA,EAAG,IAAA,EAAM,OAAO,CAAA;AACxF,IAAA,OAAO,OAAA,CAAQ,OAAO,CAAA;AAAA,EACxB,CAAA;AACF;ADrCA;AACE;AACA;AACA;AACA;AACF,sMAAC","file":"/home/runner/work/xray-emitter-js/xray-emitter-js/dist/next.cjs","sourcesContent":[null,"import type { XrayEmitter, XrayRuntimeConfig } from '../core/index';\nimport {\n createEmitter as createFetchEmitter,\n getXrayContext,\n wrapFetchPreserve,\n type WrapOptions,\n} from '../fetch/fetch';\n\nexport { createFetchEmitter as createCoreEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n XrayRuntimeConfig,\n} from '../core/index';\nexport type { WrapOptions } from '../fetch/fetch';\nexport { getXrayContext };\n\n// copy types from Next.js to avoid a package dependency\ntype NextRouteContext = {\n params: Promise<Record<string, string | string[]>>;\n};\n\ntype NextRouteHandler = (\n request: Request,\n context: NextRouteContext,\n) => Response | Promise<Response>;\n\ntype NextEmitter = ((handler: NextRouteHandler) => ReturnType<typeof wrapNextRoute>) & {\n flush: XrayEmitter['flush'];\n shutdown: XrayEmitter['shutdown'];\n};\n\n/**\n * Create a Next.js App Router wrapper and expose `flush()`/`shutdown()`.\n */\nexport function createEmitter(config: XrayRuntimeConfig, options?: WrapOptions): NextEmitter {\n const emitter = createFetchEmitter(config);\n const wrap = ((handler: NextRouteHandler) =>\n wrapNextRoute(handler, emitter, options)) as NextEmitter;\n wrap.flush = emitter.flush;\n wrap.shutdown = emitter.shutdown;\n return wrap;\n}\n\n/**\n * Wrap a Next.js route handler using an existing core `XrayEmitter`.\n */\nexport function wrapNextRoute(\n handler: NextRouteHandler,\n xray: XrayEmitter,\n options?: WrapOptions,\n): (request: Request, context: NextRouteContext) => Promise<Response> {\n return async (request, context) => {\n const wrapped = wrapFetchPreserve((req: Request) => handler(req, context), xray, options);\n return wrapped(request);\n };\n}\n"]}
package/dist/next.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { j as XrayRuntimeConfig, a as XrayEmitter } from './types-Diy-KLjz.cjs';
2
- export { e as CaptureConfig, f as RedactionConfig, R as RequestLog, X as XrayConfig, d as XrayContext } from './types-Diy-KLjz.cjs';
3
- export { c as createCoreEmitter } from './emitter-Cdl6H6vk.cjs';
1
+ import { j as XrayRuntimeConfig, a as XrayEmitter } from './types-BrKvhHbn.cjs';
2
+ export { e as CaptureConfig, f as RedactionConfig, R as RequestLog, X as XrayConfig, d as XrayContext } from './types-BrKvhHbn.cjs';
3
+ export { c as createCoreEmitter } from './emitter-Bi_m_w5h.cjs';
4
4
  import { WrapOptions } from './fetch.cjs';
5
5
  export { getXrayContext } from './fetch.cjs';
6
6
  import '@opentelemetry/sdk-trace-base';
@@ -13,7 +13,13 @@ type NextEmitter = ((handler: NextRouteHandler) => ReturnType<typeof wrapNextRou
13
13
  flush: XrayEmitter['flush'];
14
14
  shutdown: XrayEmitter['shutdown'];
15
15
  };
16
+ /**
17
+ * Create a Next.js App Router wrapper and expose `flush()`/`shutdown()`.
18
+ */
16
19
  declare function createEmitter(config: XrayRuntimeConfig, options?: WrapOptions): NextEmitter;
20
+ /**
21
+ * Wrap a Next.js route handler using an existing core `XrayEmitter`.
22
+ */
17
23
  declare function wrapNextRoute(handler: NextRouteHandler, xray: XrayEmitter, options?: WrapOptions): (request: Request, context: NextRouteContext) => Promise<Response>;
18
24
 
19
25
  export { WrapOptions, XrayEmitter, XrayRuntimeConfig, createEmitter, wrapNextRoute };
package/dist/next.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { j as XrayRuntimeConfig, a as XrayEmitter } from './types-Diy-KLjz.js';
2
- export { e as CaptureConfig, f as RedactionConfig, R as RequestLog, X as XrayConfig, d as XrayContext } from './types-Diy-KLjz.js';
3
- export { c as createCoreEmitter } from './emitter-DnDvQw9i.js';
1
+ import { j as XrayRuntimeConfig, a as XrayEmitter } from './types-BrKvhHbn.js';
2
+ export { e as CaptureConfig, f as RedactionConfig, R as RequestLog, X as XrayConfig, d as XrayContext } from './types-BrKvhHbn.js';
3
+ export { c as createCoreEmitter } from './emitter-Dy7bRGTq.js';
4
4
  import { WrapOptions } from './fetch.js';
5
5
  export { getXrayContext } from './fetch.js';
6
6
  import '@opentelemetry/sdk-trace-base';
@@ -13,7 +13,13 @@ type NextEmitter = ((handler: NextRouteHandler) => ReturnType<typeof wrapNextRou
13
13
  flush: XrayEmitter['flush'];
14
14
  shutdown: XrayEmitter['shutdown'];
15
15
  };
16
+ /**
17
+ * Create a Next.js App Router wrapper and expose `flush()`/`shutdown()`.
18
+ */
16
19
  declare function createEmitter(config: XrayRuntimeConfig, options?: WrapOptions): NextEmitter;
20
+ /**
21
+ * Wrap a Next.js route handler using an existing core `XrayEmitter`.
22
+ */
17
23
  declare function wrapNextRoute(handler: NextRouteHandler, xray: XrayEmitter, options?: WrapOptions): (request: Request, context: NextRouteContext) => Promise<Response>;
18
24
 
19
25
  export { WrapOptions, XrayEmitter, XrayRuntimeConfig, createEmitter, wrapNextRoute };
package/dist/next.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  createEmitter,
3
3
  getXrayContext,
4
4
  wrapFetchPreserve
5
- } from "./chunk-W75UIHEF.js";
6
- import "./chunk-VRRPTE7W.js";
5
+ } from "./chunk-LJYBYC7N.js";
6
+ import "./chunk-DKHGODGO.js";
7
7
  import "./chunk-NTIUR3OC.js";
8
8
  import "./chunk-7KT6EPVZ.js";
9
9
 
package/dist/next.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/next/next.ts"],"sourcesContent":["import type { XrayEmitter, XrayRuntimeConfig } from '../core/index';\nimport {\n createEmitter as createFetchEmitter,\n getXrayContext,\n wrapFetchPreserve,\n type WrapOptions,\n} from '../fetch/fetch';\n\nexport { createFetchEmitter as createCoreEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n XrayRuntimeConfig,\n} from '../core/index';\nexport type { WrapOptions } from '../fetch/fetch';\nexport { getXrayContext };\n\n// copy types from Next.js to avoid a package dependency\ntype NextRouteContext = {\n params: Promise<Record<string, string | string[]>>;\n};\n\ntype NextRouteHandler = (\n request: Request,\n context: NextRouteContext,\n) => Response | Promise<Response>;\n\ntype NextEmitter = ((handler: NextRouteHandler) => ReturnType<typeof wrapNextRoute>) & {\n flush: XrayEmitter['flush'];\n shutdown: XrayEmitter['shutdown'];\n};\n\nexport function createEmitter(config: XrayRuntimeConfig, options?: WrapOptions): NextEmitter {\n const emitter = createFetchEmitter(config);\n const wrap = ((handler: NextRouteHandler) =>\n wrapNextRoute(handler, emitter, options)) as NextEmitter;\n wrap.flush = emitter.flush;\n wrap.shutdown = emitter.shutdown;\n return wrap;\n}\n\nexport function wrapNextRoute(\n handler: NextRouteHandler,\n xray: XrayEmitter,\n options?: WrapOptions,\n): (request: Request, context: NextRouteContext) => Promise<Response> {\n return async (request, context) => {\n const wrapped = wrapFetchPreserve((req: Request) => handler(req, context), xray, options);\n return wrapped(request);\n };\n}\n"],"mappings":";;;;;;;;;;AAoCO,SAASA,eAAc,QAA2B,SAAoC;AAC3F,QAAM,UAAU,cAAmB,MAAM;AACzC,QAAM,QAAQ,CAAC,YACb,cAAc,SAAS,SAAS,OAAO;AACzC,OAAK,QAAQ,QAAQ;AACrB,OAAK,WAAW,QAAQ;AACxB,SAAO;AACT;AAEO,SAAS,cACd,SACA,MACA,SACoE;AACpE,SAAO,OAAO,SAAS,YAAY;AACjC,UAAM,UAAU,kBAAkB,CAAC,QAAiB,QAAQ,KAAK,OAAO,GAAG,MAAM,OAAO;AACxF,WAAO,QAAQ,OAAO;AAAA,EACxB;AACF;","names":["createEmitter"]}
1
+ {"version":3,"sources":["../src/next/next.ts"],"sourcesContent":["import type { XrayEmitter, XrayRuntimeConfig } from '../core/index';\nimport {\n createEmitter as createFetchEmitter,\n getXrayContext,\n wrapFetchPreserve,\n type WrapOptions,\n} from '../fetch/fetch';\n\nexport { createFetchEmitter as createCoreEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n XrayRuntimeConfig,\n} from '../core/index';\nexport type { WrapOptions } from '../fetch/fetch';\nexport { getXrayContext };\n\n// copy types from Next.js to avoid a package dependency\ntype NextRouteContext = {\n params: Promise<Record<string, string | string[]>>;\n};\n\ntype NextRouteHandler = (\n request: Request,\n context: NextRouteContext,\n) => Response | Promise<Response>;\n\ntype NextEmitter = ((handler: NextRouteHandler) => ReturnType<typeof wrapNextRoute>) & {\n flush: XrayEmitter['flush'];\n shutdown: XrayEmitter['shutdown'];\n};\n\n/**\n * Create a Next.js App Router wrapper and expose `flush()`/`shutdown()`.\n */\nexport function createEmitter(config: XrayRuntimeConfig, options?: WrapOptions): NextEmitter {\n const emitter = createFetchEmitter(config);\n const wrap = ((handler: NextRouteHandler) =>\n wrapNextRoute(handler, emitter, options)) as NextEmitter;\n wrap.flush = emitter.flush;\n wrap.shutdown = emitter.shutdown;\n return wrap;\n}\n\n/**\n * Wrap a Next.js route handler using an existing core `XrayEmitter`.\n */\nexport function wrapNextRoute(\n handler: NextRouteHandler,\n xray: XrayEmitter,\n options?: WrapOptions,\n): (request: Request, context: NextRouteContext) => Promise<Response> {\n return async (request, context) => {\n const wrapped = wrapFetchPreserve((req: Request) => handler(req, context), xray, options);\n return wrapped(request);\n };\n}\n"],"mappings":";;;;;;;;;;AAuCO,SAASA,eAAc,QAA2B,SAAoC;AAC3F,QAAM,UAAU,cAAmB,MAAM;AACzC,QAAM,QAAQ,CAAC,YACb,cAAc,SAAS,SAAS,OAAO;AACzC,OAAK,QAAQ,QAAQ;AACrB,OAAK,WAAW,QAAQ;AACxB,SAAO;AACT;AAKO,SAAS,cACd,SACA,MACA,SACoE;AACpE,SAAO,OAAO,SAAS,YAAY;AACjC,UAAM,UAAU,kBAAkB,CAAC,QAAiB,QAAQ,KAAK,OAAO,GAAG,MAAM,OAAO;AACxF,WAAO,QAAQ,OAAO;AAAA,EACxB;AACF;","names":["createEmitter"]}
package/dist/node.cjs CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkOCXEYDDHcjs = require('./chunk-OCXEYDDH.cjs');
6
- require('./chunk-Q4MTHPUL.cjs');
5
+ var _chunkBVAENKYEcjs = require('./chunk-BVAENKYE.cjs');
6
+ require('./chunk-3LDFK62Q.cjs');
7
7
  require('./chunk-CPHFCOA5.cjs');
8
8
  require('./chunk-DNBARLGB.cjs');
9
9
 
10
10
 
11
11
 
12
12
 
13
- exports.createEmitter = _chunkOCXEYDDHcjs.createEmitter; exports.getXrayContext = _chunkOCXEYDDHcjs.getXrayContext; exports.wrapHttpHandler = _chunkOCXEYDDHcjs.wrapHttpHandler;
13
+ exports.createEmitter = _chunkBVAENKYEcjs.createEmitter; exports.getXrayContext = _chunkBVAENKYEcjs.getXrayContext; exports.wrapHttpHandler = _chunkBVAENKYEcjs.wrapHttpHandler;
14
14
  //# sourceMappingURL=node.cjs.map
package/dist/node.d.cts CHANGED
@@ -1,20 +1,61 @@
1
- import { j as XrayRuntimeConfig, a as XrayEmitter, e as CaptureConfig, f as RedactionConfig, d as XrayContext, R as RequestLog } from './types-Diy-KLjz.cjs';
1
+ import { j as XrayRuntimeConfig, a as XrayEmitter, e as CaptureConfig, f as RedactionConfig, d as XrayContext, R as RequestLog } from './types-BrKvhHbn.cjs';
2
2
  import { IncomingMessage, ServerResponse } from 'node:http';
3
3
  import '@opentelemetry/sdk-trace-base';
4
4
 
5
+ /**
6
+ * Create a Node runtime emitter using OTLP HTTP transport by default.
7
+ *
8
+ * Pass `config.exporter.instance` to provide a custom `SpanExporter`.
9
+ */
5
10
  declare function createEmitter(config: XrayRuntimeConfig): XrayEmitter;
6
11
 
12
+ /**
13
+ * Handler signature for `node:http` request listeners.
14
+ */
7
15
  type NodeHttpHandler = (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
16
+ /**
17
+ * Per-handler overrides for `wrapHttpHandler`.
18
+ */
8
19
  interface WrapOptions {
20
+ /**
21
+ * Explicit route pattern for this handler (for example `/users/:id`).
22
+ */
9
23
  route?: string;
24
+ /**
25
+ * Explicit request ID. Skips header lookup/generation when provided.
26
+ */
10
27
  requestId?: string;
28
+ /**
29
+ * Per-handler capture overrides.
30
+ */
11
31
  capture?: Partial<CaptureConfig>;
32
+ /**
33
+ * Per-handler redaction overrides.
34
+ */
12
35
  redaction?: Partial<RedactionConfig>;
36
+ /**
37
+ * Hook called after request context is created.
38
+ */
13
39
  onRequest?: (ctx: XrayContext) => void;
40
+ /**
41
+ * Hook called after the request has been finalized and logged.
42
+ */
14
43
  onResponse?: (ctx: XrayContext, log: RequestLog) => void;
44
+ /**
45
+ * Hook called when request handling fails.
46
+ */
15
47
  onError?: (ctx: XrayContext, err: unknown) => void;
16
48
  }
49
+ /**
50
+ * Wrap a `node:http` request handler with X-ray instrumentation.
51
+ *
52
+ * The wrapper binds `XrayContext` to both `req` and `res`, captures configured
53
+ * request/response metadata, and ensures a response request ID header is set.
54
+ */
17
55
  declare function wrapHttpHandler(handler: NodeHttpHandler, xray: XrayEmitter, options?: WrapOptions): NodeHttpHandler;
56
+ /**
57
+ * Retrieve the `XrayContext` bound to a Node `IncomingMessage`.
58
+ */
18
59
  declare function getXrayContext(req: IncomingMessage): XrayContext | undefined;
19
60
 
20
61
  export { type NodeHttpHandler, type WrapOptions, createEmitter, getXrayContext, wrapHttpHandler };