@stainlessdev/xray-emitter 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +1 -2
  2. package/dist/{chunk-2HW4AEKB.cjs → chunk-55YD27PV.cjs} +28 -28
  3. package/dist/chunk-55YD27PV.cjs.map +1 -0
  4. package/dist/{chunk-YVMMCTXW.js → chunk-7KT6EPVZ.js} +1 -1
  5. package/dist/{chunk-YVMMCTXW.js.map → chunk-7KT6EPVZ.js.map} +1 -1
  6. package/dist/{chunk-GNSXLLEC.cjs → chunk-CPHFCOA5.cjs} +9 -9
  7. package/dist/{chunk-GNSXLLEC.cjs.map → chunk-CPHFCOA5.cjs.map} +1 -1
  8. package/dist/{chunk-JKW6E4L3.cjs → chunk-DNBARLGB.cjs} +1 -1
  9. package/dist/{chunk-JKW6E4L3.cjs.map → chunk-DNBARLGB.cjs.map} +1 -1
  10. package/dist/{chunk-ZP5OEA4I.js → chunk-DV3MVQBB.js} +4 -4
  11. package/dist/chunk-DV3MVQBB.js.map +1 -0
  12. package/dist/{chunk-WTHVUHGI.js → chunk-FGXXKIF7.js} +4 -4
  13. package/dist/chunk-FGXXKIF7.js.map +1 -0
  14. package/dist/{chunk-TSCMZ5TV.js → chunk-GYXI3DWB.js} +35 -3
  15. package/dist/chunk-GYXI3DWB.js.map +1 -0
  16. package/dist/{chunk-6UH43LVD.js → chunk-NTIUR3OC.js} +2 -2
  17. package/dist/{chunk-DBI3HXNR.cjs → chunk-SUVCVINA.cjs} +47 -47
  18. package/dist/chunk-SUVCVINA.cjs.map +1 -0
  19. package/dist/{chunk-XO6YWDFL.cjs → chunk-UJWD5CFA.cjs} +53 -21
  20. package/dist/chunk-UJWD5CFA.cjs.map +1 -0
  21. package/dist/effect.cjs +19 -19
  22. package/dist/effect.cjs.map +1 -1
  23. package/dist/effect.d.cts +30 -3
  24. package/dist/effect.d.ts +30 -3
  25. package/dist/effect.js +4 -4
  26. package/dist/effect.js.map +1 -1
  27. package/dist/emitter-Bi_m_w5h.d.cts +10 -0
  28. package/dist/emitter-Dy7bRGTq.d.ts +10 -0
  29. package/dist/express.cjs +7 -7
  30. package/dist/express.cjs.map +1 -1
  31. package/dist/express.d.cts +9 -2
  32. package/dist/express.d.ts +9 -2
  33. package/dist/express.js +4 -4
  34. package/dist/express.js.map +1 -1
  35. package/dist/fastify.cjs +10 -10
  36. package/dist/fastify.cjs.map +1 -1
  37. package/dist/fastify.d.cts +9 -2
  38. package/dist/fastify.d.ts +9 -2
  39. package/dist/fastify.js +4 -4
  40. package/dist/fastify.js.map +1 -1
  41. package/dist/fetch.cjs +5 -5
  42. package/dist/fetch.d.cts +39 -2
  43. package/dist/fetch.d.ts +39 -2
  44. package/dist/fetch.js +4 -4
  45. package/dist/hono.cjs +9 -9
  46. package/dist/hono.cjs.map +1 -1
  47. package/dist/hono.d.cts +15 -3
  48. package/dist/hono.d.ts +15 -3
  49. package/dist/hono.js +4 -4
  50. package/dist/hono.js.map +1 -1
  51. package/dist/index.cjs +3 -3
  52. package/dist/index.d.cts +8 -2
  53. package/dist/index.d.ts +8 -2
  54. package/dist/index.js +2 -2
  55. package/dist/internal.cjs +3 -3
  56. package/dist/internal.d.cts +1 -1
  57. package/dist/internal.d.ts +1 -1
  58. package/dist/internal.js +2 -2
  59. package/dist/next.cjs +7 -7
  60. package/dist/next.cjs.map +1 -1
  61. package/dist/next.d.cts +9 -3
  62. package/dist/next.d.ts +9 -3
  63. package/dist/next.js +4 -4
  64. package/dist/next.js.map +1 -1
  65. package/dist/node.cjs +5 -5
  66. package/dist/node.d.cts +42 -1
  67. package/dist/node.d.ts +42 -1
  68. package/dist/node.js +4 -4
  69. package/dist/remix.cjs +7 -7
  70. package/dist/remix.cjs.map +1 -1
  71. package/dist/remix.d.cts +10 -3
  72. package/dist/remix.d.ts +10 -3
  73. package/dist/remix.js +4 -4
  74. package/dist/remix.js.map +1 -1
  75. package/dist/types-BrKvhHbn.d.cts +446 -0
  76. package/dist/types-BrKvhHbn.d.ts +446 -0
  77. package/package.json +1 -1
  78. package/dist/chunk-2HW4AEKB.cjs.map +0 -1
  79. package/dist/chunk-DBI3HXNR.cjs.map +0 -1
  80. package/dist/chunk-TSCMZ5TV.js.map +0 -1
  81. package/dist/chunk-WTHVUHGI.js.map +0 -1
  82. package/dist/chunk-XO6YWDFL.cjs.map +0 -1
  83. package/dist/chunk-ZP5OEA4I.js.map +0 -1
  84. package/dist/emitter-BqfrGIod.d.cts +0 -5
  85. package/dist/emitter-CScYhwGA.d.ts +0 -5
  86. package/dist/types-Z1nirh-F.d.cts +0 -149
  87. package/dist/types-Z1nirh-F.d.ts +0 -149
  88. /package/dist/{chunk-6UH43LVD.js.map → chunk-NTIUR3OC.js.map} +0 -0
@@ -1,149 +0,0 @@
1
- import * as _opentelemetry_sdk_trace_base from '@opentelemetry/sdk-trace-base';
2
-
3
- interface ExporterConfig {
4
- endpointUrl: string;
5
- headers?: Record<string, string>;
6
- timeoutMs: number;
7
- spanProcessor: 'simple' | 'batch';
8
- }
9
- interface CaptureConfig {
10
- requestHeaders: boolean;
11
- responseHeaders: boolean;
12
- requestBody: 'none' | 'text' | 'base64';
13
- responseBody: 'none' | 'text' | 'base64';
14
- maxBodyBytes: number;
15
- }
16
- interface RedactionConfig {
17
- headers: string[];
18
- queryParams: string[];
19
- bodyJsonPaths: string[];
20
- replacement: string;
21
- }
22
- interface RequestIdConfig {
23
- /**
24
- * Response header name to read request IDs from. This is normalized to
25
- * lowercase during configuration.
26
- */
27
- header: string;
28
- }
29
- interface RouteConfig {
30
- normalize: boolean;
31
- normalizer?: (path: string) => string;
32
- }
33
- interface XrayConfig {
34
- serviceName: string;
35
- environment?: string;
36
- version?: string;
37
- logger?: Logger;
38
- logLevel?: LogLevel;
39
- endpointUrl?: string;
40
- exporter?: Partial<ExporterConfig>;
41
- capture?: Partial<CaptureConfig>;
42
- redaction?: Partial<RedactionConfig>;
43
- /**
44
- * Request ID resolution settings. The header is read from response headers at
45
- * the end of the request.
46
- */
47
- requestId?: Partial<RequestIdConfig>;
48
- route?: Partial<RouteConfig>;
49
- }
50
- type XrayRuntimeConfig = Omit<XrayConfig, 'exporter'> & {
51
- exporter?: Partial<ExporterConfig> & {
52
- instance?: _opentelemetry_sdk_trace_base.SpanExporter;
53
- };
54
- };
55
- interface ResolvedXrayConfig {
56
- serviceName: string;
57
- environment?: string;
58
- version?: string;
59
- logger: Logger;
60
- logLevel: LogLevel;
61
- exporter: ExporterConfig;
62
- capture: CaptureConfig;
63
- redaction: RedactionConfig;
64
- requestId: RequestIdConfig;
65
- route: RouteConfig;
66
- }
67
- declare class XrayConfigError extends Error {
68
- code: 'INVALID_CONFIG' | 'INVALID_REDACTION';
69
- constructor(code: XrayConfigError['code'], message: string);
70
- }
71
- declare function normalizeConfig(config: XrayConfig): ResolvedXrayConfig;
72
-
73
- type AttributeValue = string | number | boolean | string[] | number[] | boolean[];
74
- type LogLevel = 'debug' | 'info' | 'warn' | 'error';
75
- interface Logger {
76
- debug(msg: string, fields?: Record<string, unknown>): void;
77
- info(msg: string, fields?: Record<string, unknown>): void;
78
- warn(msg: string, fields?: Record<string, unknown>): void;
79
- error(msg: string, fields?: Record<string, unknown>): void;
80
- }
81
- interface CapturedBody {
82
- bytes: number;
83
- encoding: 'utf8' | 'base64';
84
- truncated: boolean;
85
- value?: string;
86
- }
87
- interface RequestLog {
88
- requestId: string;
89
- traceId?: string;
90
- spanId?: string;
91
- serviceName: string;
92
- method: string;
93
- url: string;
94
- route?: string;
95
- statusCode?: number;
96
- durationMs: number;
97
- requestHeaders?: Record<string, string | string[]>;
98
- responseHeaders?: Record<string, string | string[]>;
99
- requestBody?: CapturedBody;
100
- responseBody?: CapturedBody;
101
- userId?: string;
102
- sessionId?: string;
103
- error?: {
104
- message: string;
105
- type?: string;
106
- stack?: string;
107
- };
108
- attributes?: Record<string, AttributeValue>;
109
- timestamp: string;
110
- }
111
- interface XrayContext {
112
- requestId: string;
113
- traceId?: string;
114
- spanId?: string;
115
- setUserId(id: string): void;
116
- setSessionId(id: string): void;
117
- setAttribute(key: string, value: AttributeValue): void;
118
- addEvent(name: string, attributes?: Record<string, AttributeValue>): void;
119
- setError(err: unknown): void;
120
- }
121
- interface NormalizedRequest {
122
- method: string;
123
- url: string;
124
- route?: string;
125
- headers: Record<string, string | string[]>;
126
- body?: CapturedBody;
127
- /**
128
- * Optional explicit request ID. If omitted, X-ray reads from response headers
129
- * when the span is closed (and generates a UUIDv7 if none is present).
130
- */
131
- requestId?: string;
132
- remoteAddress?: string;
133
- startTimeMs: number;
134
- }
135
- interface NormalizedResponse {
136
- statusCode?: number;
137
- headers?: Record<string, string | string[]>;
138
- body?: CapturedBody;
139
- endTimeMs: number;
140
- }
141
- interface XrayEmitter {
142
- config: ResolvedXrayConfig;
143
- startRequest(req: NormalizedRequest): XrayContext;
144
- endRequest(ctx: XrayContext, res: NormalizedResponse, err?: unknown): RequestLog;
145
- flush(): Promise<void>;
146
- shutdown(): Promise<void>;
147
- }
148
-
149
- export { type AttributeValue as A, type CapturedBody as C, type ExporterConfig as E, type LogLevel as L, type NormalizedRequest as N, type RequestLog as R, type XrayConfig as X, type XrayEmitter as a, type Logger as b, type NormalizedResponse as c, type XrayContext as d, type CaptureConfig as e, type RedactionConfig as f, type RequestIdConfig as g, type ResolvedXrayConfig as h, type RouteConfig as i, type XrayRuntimeConfig as j, XrayConfigError as k, normalizeConfig as n };
@@ -1,149 +0,0 @@
1
- import * as _opentelemetry_sdk_trace_base from '@opentelemetry/sdk-trace-base';
2
-
3
- interface ExporterConfig {
4
- endpointUrl: string;
5
- headers?: Record<string, string>;
6
- timeoutMs: number;
7
- spanProcessor: 'simple' | 'batch';
8
- }
9
- interface CaptureConfig {
10
- requestHeaders: boolean;
11
- responseHeaders: boolean;
12
- requestBody: 'none' | 'text' | 'base64';
13
- responseBody: 'none' | 'text' | 'base64';
14
- maxBodyBytes: number;
15
- }
16
- interface RedactionConfig {
17
- headers: string[];
18
- queryParams: string[];
19
- bodyJsonPaths: string[];
20
- replacement: string;
21
- }
22
- interface RequestIdConfig {
23
- /**
24
- * Response header name to read request IDs from. This is normalized to
25
- * lowercase during configuration.
26
- */
27
- header: string;
28
- }
29
- interface RouteConfig {
30
- normalize: boolean;
31
- normalizer?: (path: string) => string;
32
- }
33
- interface XrayConfig {
34
- serviceName: string;
35
- environment?: string;
36
- version?: string;
37
- logger?: Logger;
38
- logLevel?: LogLevel;
39
- endpointUrl?: string;
40
- exporter?: Partial<ExporterConfig>;
41
- capture?: Partial<CaptureConfig>;
42
- redaction?: Partial<RedactionConfig>;
43
- /**
44
- * Request ID resolution settings. The header is read from response headers at
45
- * the end of the request.
46
- */
47
- requestId?: Partial<RequestIdConfig>;
48
- route?: Partial<RouteConfig>;
49
- }
50
- type XrayRuntimeConfig = Omit<XrayConfig, 'exporter'> & {
51
- exporter?: Partial<ExporterConfig> & {
52
- instance?: _opentelemetry_sdk_trace_base.SpanExporter;
53
- };
54
- };
55
- interface ResolvedXrayConfig {
56
- serviceName: string;
57
- environment?: string;
58
- version?: string;
59
- logger: Logger;
60
- logLevel: LogLevel;
61
- exporter: ExporterConfig;
62
- capture: CaptureConfig;
63
- redaction: RedactionConfig;
64
- requestId: RequestIdConfig;
65
- route: RouteConfig;
66
- }
67
- declare class XrayConfigError extends Error {
68
- code: 'INVALID_CONFIG' | 'INVALID_REDACTION';
69
- constructor(code: XrayConfigError['code'], message: string);
70
- }
71
- declare function normalizeConfig(config: XrayConfig): ResolvedXrayConfig;
72
-
73
- type AttributeValue = string | number | boolean | string[] | number[] | boolean[];
74
- type LogLevel = 'debug' | 'info' | 'warn' | 'error';
75
- interface Logger {
76
- debug(msg: string, fields?: Record<string, unknown>): void;
77
- info(msg: string, fields?: Record<string, unknown>): void;
78
- warn(msg: string, fields?: Record<string, unknown>): void;
79
- error(msg: string, fields?: Record<string, unknown>): void;
80
- }
81
- interface CapturedBody {
82
- bytes: number;
83
- encoding: 'utf8' | 'base64';
84
- truncated: boolean;
85
- value?: string;
86
- }
87
- interface RequestLog {
88
- requestId: string;
89
- traceId?: string;
90
- spanId?: string;
91
- serviceName: string;
92
- method: string;
93
- url: string;
94
- route?: string;
95
- statusCode?: number;
96
- durationMs: number;
97
- requestHeaders?: Record<string, string | string[]>;
98
- responseHeaders?: Record<string, string | string[]>;
99
- requestBody?: CapturedBody;
100
- responseBody?: CapturedBody;
101
- userId?: string;
102
- sessionId?: string;
103
- error?: {
104
- message: string;
105
- type?: string;
106
- stack?: string;
107
- };
108
- attributes?: Record<string, AttributeValue>;
109
- timestamp: string;
110
- }
111
- interface XrayContext {
112
- requestId: string;
113
- traceId?: string;
114
- spanId?: string;
115
- setUserId(id: string): void;
116
- setSessionId(id: string): void;
117
- setAttribute(key: string, value: AttributeValue): void;
118
- addEvent(name: string, attributes?: Record<string, AttributeValue>): void;
119
- setError(err: unknown): void;
120
- }
121
- interface NormalizedRequest {
122
- method: string;
123
- url: string;
124
- route?: string;
125
- headers: Record<string, string | string[]>;
126
- body?: CapturedBody;
127
- /**
128
- * Optional explicit request ID. If omitted, X-ray reads from response headers
129
- * when the span is closed (and generates a UUIDv7 if none is present).
130
- */
131
- requestId?: string;
132
- remoteAddress?: string;
133
- startTimeMs: number;
134
- }
135
- interface NormalizedResponse {
136
- statusCode?: number;
137
- headers?: Record<string, string | string[]>;
138
- body?: CapturedBody;
139
- endTimeMs: number;
140
- }
141
- interface XrayEmitter {
142
- config: ResolvedXrayConfig;
143
- startRequest(req: NormalizedRequest): XrayContext;
144
- endRequest(ctx: XrayContext, res: NormalizedResponse, err?: unknown): RequestLog;
145
- flush(): Promise<void>;
146
- shutdown(): Promise<void>;
147
- }
148
-
149
- export { type AttributeValue as A, type CapturedBody as C, type ExporterConfig as E, type LogLevel as L, type NormalizedRequest as N, type RequestLog as R, type XrayConfig as X, type XrayEmitter as a, type Logger as b, type NormalizedResponse as c, type XrayContext as d, type CaptureConfig as e, type RedactionConfig as f, type RequestIdConfig as g, type ResolvedXrayConfig as h, type RouteConfig as i, type XrayRuntimeConfig as j, XrayConfigError as k, normalizeConfig as n };