@stainlessdev/xray-emitter 0.1.0-branch.brandur-package-versions.64733fc

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 (86) hide show
  1. package/README.md +80 -0
  2. package/dist/chunk-2HW4AEKB.cjs +634 -0
  3. package/dist/chunk-2HW4AEKB.cjs.map +1 -0
  4. package/dist/chunk-6UH43LVD.js +281 -0
  5. package/dist/chunk-6UH43LVD.js.map +1 -0
  6. package/dist/chunk-DBI3HXNR.cjs +613 -0
  7. package/dist/chunk-DBI3HXNR.cjs.map +1 -0
  8. package/dist/chunk-GNSXLLEC.cjs +281 -0
  9. package/dist/chunk-GNSXLLEC.cjs.map +1 -0
  10. package/dist/chunk-JKW6E4L3.cjs +304 -0
  11. package/dist/chunk-JKW6E4L3.cjs.map +1 -0
  12. package/dist/chunk-TSCMZ5TV.js +1340 -0
  13. package/dist/chunk-TSCMZ5TV.js.map +1 -0
  14. package/dist/chunk-WTHVUHGI.js +634 -0
  15. package/dist/chunk-WTHVUHGI.js.map +1 -0
  16. package/dist/chunk-XO6YWDFL.cjs +1340 -0
  17. package/dist/chunk-XO6YWDFL.cjs.map +1 -0
  18. package/dist/chunk-YVMMCTXW.js +304 -0
  19. package/dist/chunk-YVMMCTXW.js.map +1 -0
  20. package/dist/chunk-ZP5OEA4I.js +613 -0
  21. package/dist/chunk-ZP5OEA4I.js.map +1 -0
  22. package/dist/effect.cjs +186 -0
  23. package/dist/effect.cjs.map +1 -0
  24. package/dist/effect.d.cts +33 -0
  25. package/dist/effect.d.ts +33 -0
  26. package/dist/effect.js +186 -0
  27. package/dist/effect.js.map +1 -0
  28. package/dist/emitter-BqfrGIod.d.cts +5 -0
  29. package/dist/emitter-CScYhwGA.d.ts +5 -0
  30. package/dist/express.cjs +45 -0
  31. package/dist/express.cjs.map +1 -0
  32. package/dist/express.d.cts +17 -0
  33. package/dist/express.d.ts +17 -0
  34. package/dist/express.js +45 -0
  35. package/dist/express.js.map +1 -0
  36. package/dist/fastify.cjs +64 -0
  37. package/dist/fastify.cjs.map +1 -0
  38. package/dist/fastify.d.cts +21 -0
  39. package/dist/fastify.d.ts +21 -0
  40. package/dist/fastify.js +64 -0
  41. package/dist/fastify.js.map +1 -0
  42. package/dist/fetch.cjs +16 -0
  43. package/dist/fetch.cjs.map +1 -0
  44. package/dist/fetch.d.cts +18 -0
  45. package/dist/fetch.d.ts +18 -0
  46. package/dist/fetch.js +16 -0
  47. package/dist/fetch.js.map +1 -0
  48. package/dist/hono.cjs +71 -0
  49. package/dist/hono.cjs.map +1 -0
  50. package/dist/hono.d.cts +30 -0
  51. package/dist/hono.d.ts +30 -0
  52. package/dist/hono.js +71 -0
  53. package/dist/hono.js.map +1 -0
  54. package/dist/index.cjs +12 -0
  55. package/dist/index.cjs.map +1 -0
  56. package/dist/index.d.cts +7 -0
  57. package/dist/index.d.ts +7 -0
  58. package/dist/index.js +12 -0
  59. package/dist/index.js.map +1 -0
  60. package/dist/internal.cjs +45 -0
  61. package/dist/internal.cjs.map +1 -0
  62. package/dist/internal.d.cts +53 -0
  63. package/dist/internal.d.ts +53 -0
  64. package/dist/internal.js +45 -0
  65. package/dist/internal.js.map +1 -0
  66. package/dist/next.cjs +30 -0
  67. package/dist/next.cjs.map +1 -0
  68. package/dist/next.d.cts +19 -0
  69. package/dist/next.d.ts +19 -0
  70. package/dist/next.js +30 -0
  71. package/dist/next.js.map +1 -0
  72. package/dist/node.cjs +14 -0
  73. package/dist/node.cjs.map +1 -0
  74. package/dist/node.d.cts +20 -0
  75. package/dist/node.d.ts +20 -0
  76. package/dist/node.js +14 -0
  77. package/dist/node.js.map +1 -0
  78. package/dist/remix.cjs +30 -0
  79. package/dist/remix.cjs.map +1 -0
  80. package/dist/remix.d.cts +16 -0
  81. package/dist/remix.d.ts +16 -0
  82. package/dist/remix.js +30 -0
  83. package/dist/remix.js.map +1 -0
  84. package/dist/types-Z1nirh-F.d.cts +149 -0
  85. package/dist/types-Z1nirh-F.d.ts +149 -0
  86. package/package.json +107 -0
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # X-ray emitter
2
+
3
+ Node and Typescript SDKs to emit request logs to Stainless X-ray.
4
+
5
+ ## Getting started
6
+
7
+ ```sh
8
+ npm add @stainlessdev/xray-emitter
9
+ ```
10
+
11
+ Then using it in Express, for example:
12
+
13
+ ```ts
14
+ import express from 'express';
15
+ import { createEmitter } from '@stainlessdev/xray-emitter/express';
16
+ import { getXrayContext } from '@stainlessdev/xray-emitter/node';
17
+
18
+ const app = express();
19
+
20
+ const xray = createEmitter({ serviceName: 'my-service' });
21
+
22
+ app.use(xray);
23
+
24
+ app.use((req, _res, next) => {
25
+ const ctx = getXrayContext(req);
26
+ ctx?.setUserId('user-123');
27
+ next();
28
+ });
29
+
30
+ app.get('/', (_req, res) => {
31
+ res.send('ok');
32
+ });
33
+ ```
34
+
35
+
36
+ ## Supported frameworks
37
+
38
+ | Framework | Import | Docs | Example |
39
+ |-----------|--------|------|---------|
40
+ | Express | `@stainlessdev/xray-emitter/express` | [README](src/express/README.md) | [example](examples/express) |
41
+ | Fastify | `@stainlessdev/xray-emitter/fastify` | [README](src/fastify/README.md) | [example](examples/fastify) |
42
+ | Hono | `@stainlessdev/xray-emitter/hono` | [README](src/hono/README.md) | [example](examples/hono) |
43
+ | Next.js | `@stainlessdev/xray-emitter/next` | [README](src/next/README.md) | [example](examples/next-app) |
44
+ | Remix | `@stainlessdev/xray-emitter/remix` | [README](src/remix/README.md) | [example](examples/remix-app) |
45
+ | Effect | `@stainlessdev/xray-emitter/effect` | [README](src/effect/README.md) | [example](examples/effect) |
46
+
47
+ Lower-level adapters:
48
+
49
+ | Adapter | Import | Docs | Example |
50
+ |---------|--------|------|---------|
51
+ | Node.js (`node:http`) | `@stainlessdev/xray-emitter/node` | [README](src/node/README.md) | [example](examples/node-http) |
52
+ | Fetch / Edge | `@stainlessdev/xray-emitter/fetch` | [README](src/fetch/README.md) | [example](examples/edge) |
53
+ | Core | `@stainlessdev/xray-emitter` | [README](src/core/README.md) | — |
54
+
55
+ ## Configuration
56
+
57
+ X-ray does not read standard OTEL environment variables. Configure an endpoint by passing
58
+ `endpointUrl` or setting `STAINLESS_XRAY_ENDPOINT_URL`. If both are set, `endpointUrl` wins. An
59
+ error is thrown if no endpoint is configured.
60
+
61
+ The core module (`@stainlessdev/xray-emitter`) is runtime-agnostic; use it only if you supply a
62
+ custom exporter instance to `createEmitter`.
63
+
64
+ ### Request IDs
65
+
66
+ X-ray resolves request IDs from **response headers** when the span is closed. Configure the header name with `requestId.header` (default: `request-id`, emitted as `Request-Id`). Resolution order is: explicit `requestId` on the normalized request → response header lookup → UUIDv7 when missing.
67
+
68
+ If the configured response header is missing when the response is finalized, X-ray will set it (using the explicit ID when provided, otherwise a generated UUIDv7). Existing response headers are not overwritten.
69
+
70
+ ### Fetch wrappers
71
+
72
+ `wrapFetch` may replace the request/response objects while capturing bodies. `wrapFetchPreserve` keeps the original request/response whenever possible, but it may replace the response if it needs to inject a missing `Request-Id` header.
73
+
74
+ ## Development
75
+
76
+ ```sh
77
+ pnpm install
78
+ pnpm build
79
+ pnpm test
80
+ ```