@stainlessdev/xray-remix 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +62 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # @stainlessdev/xray-remix
2
+
3
+ Remix integration for Stainless X-ray request logging. Wraps Remix/React Router request handlers in fetch-based runtimes.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ pnpm add @stainlessdev/xray-remix
9
+ ```
10
+
11
+ ## Basic usage
12
+
13
+ ```ts
14
+ import type { RequestHandler } from 'react-router';
15
+ import { createEmitter, getXrayContext } from '@stainlessdev/xray-remix';
16
+
17
+ const xray = createEmitter({
18
+ serviceName: 'my-service',
19
+ endpointUrl: 'http://localhost:4318',
20
+ });
21
+
22
+ const handler: RequestHandler = async (request) => {
23
+ getXrayContext(request)?.setUserId('user-123');
24
+ const body = await request.text();
25
+ return new Response(`remix:${body}`, { status: 200 });
26
+ };
27
+
28
+ export default xray(handler);
29
+ ```
30
+
31
+ ## Request IDs and response headers
32
+
33
+ X-ray will **auto-generate a request ID and inject it into your response headers** under the configured name (`requestId.header`, default `request-id`, emitted as `Request-Id`) if the header is missing. If you set your own request ID first (via `options.requestId` or by setting the response header yourself), X-ray preserves it and does not overwrite the header.
34
+
35
+ ## Configuration
36
+
37
+ `createEmitter(config, options?)` accepts `XrayRuntimeConfig` (config) and `WrapOptions` (per-request defaults):
38
+
39
+ - `serviceName` (required)
40
+ - `endpointUrl` (required; falls back to `STAINLESS_XRAY_ENDPOINT_URL` when omitted; explicit `endpointUrl` wins)
41
+ - `environment`, `version`, `logger`, `logLevel`
42
+ - `exporter`: `endpointUrl`, `headers`, `timeoutMs`, `spanProcessor`, `instance` (custom SpanExporter)
43
+ - `capture`: request/response headers and bodies
44
+ - `redaction`: headers/query/body JSON-path redaction
45
+ - `requestId`: header name to read/write
46
+ - `route`: normalization options
47
+
48
+ ## Adapter options (WrapOptions)
49
+
50
+ - `route`: override the route name for the request
51
+ - `requestId`: explicit request ID to use (prevents auto-generation)
52
+ - `capture`: per-request capture overrides
53
+ - `redaction`: per-request redaction overrides
54
+ - `onRequest(ctx)`, `onResponse(ctx, log)`, `onError(ctx, err)` hooks
55
+
56
+ ## Advanced usage
57
+
58
+ If you already have an `XrayEmitter` instance, use `wrapRemixRequestHandler(handler, xray, options)`.
59
+
60
+ ## Notes
61
+
62
+ - This package depends on OpenTelemetry packages as peer dependencies.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stainlessdev/xray-remix",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Remix integration for Stainless X-ray request logging",
5
5
  "files": [
6
6
  "dist"
@@ -20,8 +20,8 @@
20
20
  "access": "public"
21
21
  },
22
22
  "dependencies": {
23
- "@stainlessdev/xray-core": "0.6.0",
24
- "@stainlessdev/xray-fetch": "0.6.0"
23
+ "@stainlessdev/xray-core": "0.7.0",
24
+ "@stainlessdev/xray-fetch": "0.7.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@opentelemetry/api": "^1.9.0",