vestig 0.15.0 → 0.16.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.
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/otlp/exporter.d.ts +183 -0
- package/dist/otlp/exporter.d.ts.map +1 -0
- package/dist/otlp/exporter.js +308 -0
- package/dist/otlp/exporter.js.map +1 -0
- package/dist/otlp/index.d.ts +47 -0
- package/dist/otlp/index.d.ts.map +1 -0
- package/dist/otlp/index.js +51 -0
- package/dist/otlp/index.js.map +1 -0
- package/dist/otlp/processor.d.ts +110 -0
- package/dist/otlp/processor.d.ts.map +1 -0
- package/dist/otlp/processor.js +131 -0
- package/dist/otlp/processor.js.map +1 -0
- package/dist/otlp/types.d.ts +237 -0
- package/dist/otlp/types.d.ts.map +1 -0
- package/dist/otlp/types.js +190 -0
- package/dist/otlp/types.js.map +1 -0
- package/dist/tracing/span.d.ts.map +1 -1
- package/dist/tracing/span.js +5 -0
- package/dist/tracing/span.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +12 -2
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export { FileTransport } from './transports/file';
|
|
|
21
21
|
export { DatadogTransport, DatadogTransportError } from './transports/datadog';
|
|
22
22
|
export { SentryTransport, SentryTransportError } from './transports/sentry';
|
|
23
23
|
export { span, spanSync, startSpan, endSpan, getActiveSpan, withActiveSpan, SpanImpl, clearActiveSpans, getActiveSpanStackDepth, withSpanContext, withSpanContextAsync, } from './tracing';
|
|
24
|
+
export { registerSpanProcessor, unregisterSpanProcessor, getSpanProcessors, flushSpanProcessors, shutdownSpanProcessors, } from './otlp';
|
|
25
|
+
export type { SpanProcessor } from './otlp';
|
|
24
26
|
export { createSampler, createSamplerFromConfig, createProbabilitySampler, createRateLimitSampler, createNamespaceSampler, createCompositeSampler, } from './sampling';
|
|
25
27
|
export { createWideEvent, WideEventBuilderImpl, getActiveWideEvent, withWideEvent, withWideEventAsync, } from './wide-events';
|
|
26
28
|
export type { WideEvent, WideEventBuilder, WideEventConfig, WideEventContext, WideEventEndOptions, WideEventFields, WideEventStatus, TailSamplingConfig, } from './wide-events';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAClF,YAAY,EACX,MAAM,EACN,YAAY,EACZ,oBAAoB,EACpB,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,OAAO,EAEP,YAAY,EACZ,eAAe,EACf,cAAc,EACd,cAAc,EAEd,YAAY,EAEZ,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,UAAU,EACV,gBAAgB,EAEhB,OAAO,EACP,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,SAAS,CAAA;AAGhB,OAAO,EACN,OAAO,EACP,YAAY,EACZ,OAAO,EACP,MAAM,EACN,OAAO,EACP,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,GACT,MAAM,WAAW,CAAA;AAClB,YAAY,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAGpD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAG/D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;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AAW,CAAA;AAGlB,OAAO,EACN,aAAa,EACb,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,YAAY,CAAA;AAGnB,OAAO,EACN,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,GAClB,MAAM,eAAe,CAAA;AACtB,YAAY,EACX,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,kBAAkB,GAClB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AACnF,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAK9C;;GAEG;AACH,eAAO,MAAM,GAAG,0BAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAClF,YAAY,EACX,MAAM,EACN,YAAY,EACZ,oBAAoB,EACpB,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,OAAO,EAEP,YAAY,EACZ,eAAe,EACf,cAAc,EACd,cAAc,EAEd,YAAY,EAEZ,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,UAAU,EACV,gBAAgB,EAEhB,OAAO,EACP,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,SAAS,CAAA;AAGhB,OAAO,EACN,OAA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,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAG3E,OAAO,EACN,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,aAAa,EACb,cAAc,EACd,QAAQ,EAER,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,GACpB,MAAM,WAAW,CAAA;AAGlB,OAAO,EAEN,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,QAAQ,CAAA;AACf,YAAY,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAG3C,OAAO,EACN,aAAa,EACb,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,GACtB,MAAM,YAAY,CAAA;AAGnB,OAAO,EACN,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,GAClB,MAAM,eAAe,CAAA;AACtB,YAAY,EACX,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,kBAAkB,GAClB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AACnF,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAK9C;;GAEG;AACH,eAAO,MAAM,GAAG,0BAAiB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,10 @@ export { SentryTransport, SentryTransportError } from './transports/sentry';
|
|
|
28
28
|
export { span, spanSync, startSpan, endSpan, getActiveSpan, withActiveSpan, SpanImpl,
|
|
29
29
|
// Context utilities (for advanced use cases)
|
|
30
30
|
clearActiveSpans, getActiveSpanStackDepth, withSpanContext, withSpanContextAsync, } from './tracing';
|
|
31
|
+
// OTLP - OpenTelemetry Protocol support
|
|
32
|
+
export {
|
|
33
|
+
// Span processor registration
|
|
34
|
+
registerSpanProcessor, unregisterSpanProcessor, getSpanProcessors, flushSpanProcessors, shutdownSpanProcessors, } from './otlp';
|
|
31
35
|
// Sampling - factory functions for creating samplers
|
|
32
36
|
export { createSampler, createSamplerFromConfig, createProbabilitySampler, createRateLimitSampler, createNamespaceSampler, createCompositeSampler, } from './sampling';
|
|
33
37
|
// Wide Events - canonical log lines for comprehensive request context
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,eAAe;AACf,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AA0ClF,oBAAoB;AACpB,OAAO,EACN,OAAO,EACP,YAAY,EACZ,OAAO,EACP,MAAM,EACN,OAAO,EACP,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,GACT,MAAM,WAAW,CAAA;AAGlB,aAAa;AACb,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE/D,gBAAgB;AAChB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAElE,qBAAqB;AACrB,OAAO,EACN,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB;AACjB,uCAAuC;AACvC,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,WAAW,CAAA;AAGlB,YAAY;AACZ,OAAO,EAAE,cAAc,EAA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-compatible backends (Jaeger, Honeycomb, Grafana, Vercel, etc.)
|
|
5
|
+
* using the OTLP/JSON protocol.
|
|
6
|
+
*/
|
|
7
|
+
import type { SpanProcessor } from './processor';
|
|
8
|
+
import type { Span } from '../tracing/types';
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for OTLPExporter
|
|
11
|
+
*/
|
|
12
|
+
export interface OTLPExporterConfig {
|
|
13
|
+
/**
|
|
14
|
+
* OTLP endpoint URL for traces
|
|
15
|
+
* @example 'https://otel.example.com/v1/traces'
|
|
16
|
+
* @example 'https://api.honeycomb.io/v1/traces'
|
|
17
|
+
*/
|
|
18
|
+
endpoint: string;
|
|
19
|
+
/**
|
|
20
|
+
* Service name (required) - identifies your application
|
|
21
|
+
* Maps to OTLP resource attribute 'service.name'
|
|
22
|
+
*/
|
|
23
|
+
serviceName: string;
|
|
24
|
+
/**
|
|
25
|
+
* Service version (optional)
|
|
26
|
+
* Maps to OTLP resource attribute 'service.version'
|
|
27
|
+
*/
|
|
28
|
+
serviceVersion?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Deployment environment (optional)
|
|
31
|
+
* Maps to OTLP resource attribute 'deployment.environment'
|
|
32
|
+
* @example 'production', 'staging', 'development'
|
|
33
|
+
*/
|
|
34
|
+
environment?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Custom HTTP headers for authentication
|
|
37
|
+
* @example { 'Authorization': 'Bearer token' }
|
|
38
|
+
* @example { 'x-honeycomb-team': 'api-key' }
|
|
39
|
+
*/
|
|
40
|
+
headers?: Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* Additional resource attributes
|
|
43
|
+
* @example { 'host.name': 'server-1', 'cloud.region': 'us-east-1' }
|
|
44
|
+
*/
|
|
45
|
+
resourceAttributes?: Record<string, unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* Maximum number of spans to batch before sending
|
|
48
|
+
* @default 100
|
|
49
|
+
*/
|
|
50
|
+
batchSize?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Interval in ms between automatic flushes
|
|
53
|
+
* @default 5000
|
|
54
|
+
*/
|
|
55
|
+
flushInterval?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Request timeout in ms
|
|
58
|
+
* @default 30000
|
|
59
|
+
*/
|
|
60
|
+
timeout?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Maximum retry attempts on failure
|
|
63
|
+
* @default 3
|
|
64
|
+
*/
|
|
65
|
+
maxRetries?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Delay between retries in ms (doubles each attempt)
|
|
68
|
+
* @default 1000
|
|
69
|
+
*/
|
|
70
|
+
retryDelay?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Enable/disable the exporter
|
|
73
|
+
* @default true
|
|
74
|
+
*/
|
|
75
|
+
enabled?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* OTLP Exporter for sending spans to OTLP-compatible backends
|
|
79
|
+
*
|
|
80
|
+
* Implements the SpanProcessor interface to receive spans from vestig
|
|
81
|
+
* and batches them for efficient export.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { registerSpanProcessor } from 'vestig'
|
|
86
|
+
* import { OTLPExporter } from 'vestig/otlp'
|
|
87
|
+
*
|
|
88
|
+
* const exporter = new OTLPExporter({
|
|
89
|
+
* endpoint: 'https://otel.vercel.com/v1/traces',
|
|
90
|
+
* serviceName: 'my-app',
|
|
91
|
+
* serviceVersion: '1.0.0',
|
|
92
|
+
* environment: 'production',
|
|
93
|
+
* headers: {
|
|
94
|
+
* 'Authorization': `Bearer ${process.env.OTEL_TOKEN}`,
|
|
95
|
+
* },
|
|
96
|
+
* })
|
|
97
|
+
*
|
|
98
|
+
* registerSpanProcessor(exporter)
|
|
99
|
+
*
|
|
100
|
+
* // Your spans will now be exported to the OTLP endpoint
|
|
101
|
+
* await span('db:query', async (s) => {
|
|
102
|
+
* s.setAttribute('db.table', 'users')
|
|
103
|
+
* return await db.select().from(users)
|
|
104
|
+
* })
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare class OTLPExporter implements SpanProcessor {
|
|
108
|
+
private readonly config;
|
|
109
|
+
private readonly resourceAttributes;
|
|
110
|
+
private buffer;
|
|
111
|
+
private flushTimer;
|
|
112
|
+
private isFlushing;
|
|
113
|
+
private isShutdown;
|
|
114
|
+
/**
|
|
115
|
+
* Epoch time when the exporter was created
|
|
116
|
+
* Used to convert performance.now() offsets to absolute timestamps
|
|
117
|
+
*/
|
|
118
|
+
private readonly epochStartMs;
|
|
119
|
+
constructor(config: OTLPExporterConfig);
|
|
120
|
+
/**
|
|
121
|
+
* Start the periodic flush timer
|
|
122
|
+
*/
|
|
123
|
+
private startFlushTimer;
|
|
124
|
+
/**
|
|
125
|
+
* Stop the flush timer
|
|
126
|
+
*/
|
|
127
|
+
private stopFlushTimer;
|
|
128
|
+
/**
|
|
129
|
+
* Called when a span starts (optional for batching exporters)
|
|
130
|
+
*/
|
|
131
|
+
onStart(_span: Span): void;
|
|
132
|
+
/**
|
|
133
|
+
* Called when a span ends - adds the span to the buffer
|
|
134
|
+
*/
|
|
135
|
+
onEnd(span: Span): void;
|
|
136
|
+
/**
|
|
137
|
+
* Force flush all buffered spans
|
|
138
|
+
*/
|
|
139
|
+
forceFlush(): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Shutdown the exporter
|
|
142
|
+
*/
|
|
143
|
+
shutdown(): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Send spans with retry logic
|
|
146
|
+
*/
|
|
147
|
+
private sendWithRetry;
|
|
148
|
+
/**
|
|
149
|
+
* Send spans to the OTLP endpoint
|
|
150
|
+
*/
|
|
151
|
+
private send;
|
|
152
|
+
/**
|
|
153
|
+
* Safely read response body
|
|
154
|
+
*/
|
|
155
|
+
private safeReadBody;
|
|
156
|
+
/**
|
|
157
|
+
* Sleep utility
|
|
158
|
+
*/
|
|
159
|
+
private sleep;
|
|
160
|
+
/**
|
|
161
|
+
* Get export statistics
|
|
162
|
+
*/
|
|
163
|
+
getStats(): {
|
|
164
|
+
buffered: number;
|
|
165
|
+
isFlushing: boolean;
|
|
166
|
+
isShutdown: boolean;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Error class for OTLP export failures
|
|
171
|
+
*/
|
|
172
|
+
export declare class OTLPExportError extends Error {
|
|
173
|
+
readonly statusCode: number;
|
|
174
|
+
readonly responseBody?: string | undefined;
|
|
175
|
+
readonly cause?: Error | undefined;
|
|
176
|
+
constructor(message: string, statusCode: number, responseBody?: string | undefined, cause?: Error | undefined);
|
|
177
|
+
get isNetworkError(): boolean;
|
|
178
|
+
get isTimeout(): boolean;
|
|
179
|
+
get isClientError(): boolean;
|
|
180
|
+
get isServerError(): boolean;
|
|
181
|
+
get isRetryable(): boolean;
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=exporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../../src/otlp/exporter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAS5C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEhC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAE5C;;;OAG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AOD;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;aAGxB,UAAU,EAAE,MAAM;aAClB,YAAY,CAAC,EAAE,MAAM;aACnB,KAAK,CAAC,EAAE,KAAK;gBAH/B,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM,YAAA,EACnB,KAAK,CAAC,EAAE,KAAK,YAAA;IAMhC,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,IAAI,WAAW,IAAI,OAAO,CAEzB;CACD"}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OTLP Exporter for vestig
|
|
3
|
+
*
|
|
4
|
+
* Exports spans to OTLP-compatible backends (Jaeger, Honeycomb, Grafana, Vercel, etc.)
|
|
5
|
+
* using the OTLP/JSON protocol.
|
|
6
|
+
*/
|
|
7
|
+
import { VERSION } from '../version';
|
|
8
|
+
import { toOTLPAttributes, toOTLPSpan, } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Default configuration values
|
|
11
|
+
*/
|
|
12
|
+
const DEFAULTS = {
|
|
13
|
+
batchSize: 100,
|
|
14
|
+
flushInterval: 5000,
|
|
15
|
+
timeout: 30000,
|
|
16
|
+
maxRetries: 3,
|
|
17
|
+
retryDelay: 1000,
|
|
18
|
+
enabled: true,
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* OTLP Exporter for sending spans to OTLP-compatible backends
|
|
22
|
+
*
|
|
23
|
+
* Implements the SpanProcessor interface to receive spans from vestig
|
|
24
|
+
* and batches them for efficient export.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { registerSpanProcessor } from 'vestig'
|
|
29
|
+
* import { OTLPExporter } from 'vestig/otlp'
|
|
30
|
+
*
|
|
31
|
+
* const exporter = new OTLPExporter({
|
|
32
|
+
* endpoint: 'https://otel.vercel.com/v1/traces',
|
|
33
|
+
* serviceName: 'my-app',
|
|
34
|
+
* serviceVersion: '1.0.0',
|
|
35
|
+
* environment: 'production',
|
|
36
|
+
* headers: {
|
|
37
|
+
* 'Authorization': `Bearer ${process.env.OTEL_TOKEN}`,
|
|
38
|
+
* },
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* registerSpanProcessor(exporter)
|
|
42
|
+
*
|
|
43
|
+
* // Your spans will now be exported to the OTLP endpoint
|
|
44
|
+
* await span('db:query', async (s) => {
|
|
45
|
+
* s.setAttribute('db.table', 'users')
|
|
46
|
+
* return await db.select().from(users)
|
|
47
|
+
* })
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export class OTLPExporter {
|
|
51
|
+
config;
|
|
52
|
+
resourceAttributes;
|
|
53
|
+
buffer = [];
|
|
54
|
+
flushTimer = null;
|
|
55
|
+
isFlushing = false;
|
|
56
|
+
isShutdown = false;
|
|
57
|
+
/**
|
|
58
|
+
* Epoch time when the exporter was created
|
|
59
|
+
* Used to convert performance.now() offsets to absolute timestamps
|
|
60
|
+
*/
|
|
61
|
+
epochStartMs;
|
|
62
|
+
constructor(config) {
|
|
63
|
+
this.config = {
|
|
64
|
+
...config,
|
|
65
|
+
batchSize: config.batchSize ?? DEFAULTS.batchSize,
|
|
66
|
+
flushInterval: config.flushInterval ?? DEFAULTS.flushInterval,
|
|
67
|
+
timeout: config.timeout ?? DEFAULTS.timeout,
|
|
68
|
+
maxRetries: config.maxRetries ?? DEFAULTS.maxRetries,
|
|
69
|
+
retryDelay: config.retryDelay ?? DEFAULTS.retryDelay,
|
|
70
|
+
enabled: config.enabled ?? DEFAULTS.enabled,
|
|
71
|
+
};
|
|
72
|
+
// Calculate epoch offset for timestamp conversion
|
|
73
|
+
// performance.now() gives time since page load/process start
|
|
74
|
+
// We need to convert to Unix epoch milliseconds
|
|
75
|
+
this.epochStartMs = Date.now() - performance.now();
|
|
76
|
+
// Build resource attributes
|
|
77
|
+
const resourceAttrs = {
|
|
78
|
+
'service.name': config.serviceName,
|
|
79
|
+
...(config.serviceVersion && { 'service.version': config.serviceVersion }),
|
|
80
|
+
...(config.environment && { 'deployment.environment': config.environment }),
|
|
81
|
+
'telemetry.sdk.name': 'vestig',
|
|
82
|
+
'telemetry.sdk.version': VERSION,
|
|
83
|
+
'telemetry.sdk.language': 'javascript',
|
|
84
|
+
...config.resourceAttributes,
|
|
85
|
+
};
|
|
86
|
+
this.resourceAttributes = toOTLPAttributes(resourceAttrs);
|
|
87
|
+
// Start flush timer
|
|
88
|
+
this.startFlushTimer();
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Start the periodic flush timer
|
|
92
|
+
*/
|
|
93
|
+
startFlushTimer() {
|
|
94
|
+
if (this.flushTimer)
|
|
95
|
+
return;
|
|
96
|
+
this.flushTimer = setInterval(() => {
|
|
97
|
+
this.forceFlush().catch((err) => {
|
|
98
|
+
console.error('[vestig/otlp] Flush error:', err);
|
|
99
|
+
});
|
|
100
|
+
}, this.config.flushInterval);
|
|
101
|
+
// Don't block process exit
|
|
102
|
+
if (typeof this.flushTimer.unref === 'function') {
|
|
103
|
+
this.flushTimer.unref();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Stop the flush timer
|
|
108
|
+
*/
|
|
109
|
+
stopFlushTimer() {
|
|
110
|
+
if (this.flushTimer) {
|
|
111
|
+
clearInterval(this.flushTimer);
|
|
112
|
+
this.flushTimer = null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Called when a span starts (optional for batching exporters)
|
|
117
|
+
*/
|
|
118
|
+
onStart(_span) {
|
|
119
|
+
// We don't need to do anything on start for a batching exporter
|
|
120
|
+
// The span will be captured in onEnd when it's complete
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Called when a span ends - adds the span to the buffer
|
|
124
|
+
*/
|
|
125
|
+
onEnd(span) {
|
|
126
|
+
if (!this.config.enabled || this.isShutdown)
|
|
127
|
+
return;
|
|
128
|
+
// Convert to OTLP format and buffer
|
|
129
|
+
const otlpSpan = toOTLPSpan(span, this.epochStartMs);
|
|
130
|
+
this.buffer.push(otlpSpan);
|
|
131
|
+
// Auto-flush when batch size reached
|
|
132
|
+
if (this.buffer.length >= this.config.batchSize && !this.isFlushing) {
|
|
133
|
+
this.forceFlush().catch((err) => {
|
|
134
|
+
console.error('[vestig/otlp] Auto-flush error:', err);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Force flush all buffered spans
|
|
140
|
+
*/
|
|
141
|
+
async forceFlush() {
|
|
142
|
+
if (this.isFlushing || this.buffer.length === 0)
|
|
143
|
+
return;
|
|
144
|
+
this.isFlushing = true;
|
|
145
|
+
try {
|
|
146
|
+
const spans = this.buffer;
|
|
147
|
+
this.buffer = [];
|
|
148
|
+
await this.sendWithRetry(spans);
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
this.isFlushing = false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Shutdown the exporter
|
|
156
|
+
*/
|
|
157
|
+
async shutdown() {
|
|
158
|
+
if (this.isShutdown)
|
|
159
|
+
return;
|
|
160
|
+
this.isShutdown = true;
|
|
161
|
+
this.stopFlushTimer();
|
|
162
|
+
// Final flush
|
|
163
|
+
if (this.buffer.length > 0) {
|
|
164
|
+
await this.forceFlush();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Send spans with retry logic
|
|
169
|
+
*/
|
|
170
|
+
async sendWithRetry(spans) {
|
|
171
|
+
let lastError = new Error('Unknown error');
|
|
172
|
+
for (let attempt = 0; attempt < this.config.maxRetries; attempt++) {
|
|
173
|
+
try {
|
|
174
|
+
await this.send(spans);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
179
|
+
// Don't retry on client errors (4xx) - log and exit
|
|
180
|
+
if (err instanceof OTLPExportError && err.isClientError) {
|
|
181
|
+
console.error(`[vestig/otlp] Client error exporting ${spans.length} spans (not retrying):`, lastError.message);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (attempt < this.config.maxRetries - 1) {
|
|
185
|
+
// Exponential backoff
|
|
186
|
+
const delay = this.config.retryDelay * 2 ** attempt;
|
|
187
|
+
await this.sleep(delay);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// All retries failed
|
|
192
|
+
console.error(`[vestig/otlp] Failed to export ${spans.length} spans after ${this.config.maxRetries} retries:`, lastError.message);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Send spans to the OTLP endpoint
|
|
196
|
+
*/
|
|
197
|
+
async send(spans) {
|
|
198
|
+
const payload = {
|
|
199
|
+
resourceSpans: [
|
|
200
|
+
{
|
|
201
|
+
resource: {
|
|
202
|
+
attributes: this.resourceAttributes,
|
|
203
|
+
},
|
|
204
|
+
scopeSpans: [
|
|
205
|
+
{
|
|
206
|
+
scope: {
|
|
207
|
+
name: 'vestig',
|
|
208
|
+
version: VERSION,
|
|
209
|
+
},
|
|
210
|
+
spans,
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
};
|
|
216
|
+
const controller = new AbortController();
|
|
217
|
+
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
218
|
+
try {
|
|
219
|
+
const response = await fetch(this.config.endpoint, {
|
|
220
|
+
method: 'POST',
|
|
221
|
+
headers: {
|
|
222
|
+
'Content-Type': 'application/json',
|
|
223
|
+
...this.config.headers,
|
|
224
|
+
},
|
|
225
|
+
body: JSON.stringify(payload),
|
|
226
|
+
signal: controller.signal,
|
|
227
|
+
keepalive: true,
|
|
228
|
+
});
|
|
229
|
+
if (!response.ok) {
|
|
230
|
+
const body = await this.safeReadBody(response);
|
|
231
|
+
throw new OTLPExportError(`OTLP export failed: HTTP ${response.status} ${response.statusText}`, response.status, body);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
if (err instanceof OTLPExportError) {
|
|
236
|
+
throw err;
|
|
237
|
+
}
|
|
238
|
+
if (err instanceof Error) {
|
|
239
|
+
if (err.name === 'AbortError') {
|
|
240
|
+
throw new OTLPExportError(`OTLP export timeout after ${this.config.timeout}ms`, 408);
|
|
241
|
+
}
|
|
242
|
+
throw new OTLPExportError(err.message, 0, undefined, err);
|
|
243
|
+
}
|
|
244
|
+
throw new OTLPExportError(String(err), 0);
|
|
245
|
+
}
|
|
246
|
+
finally {
|
|
247
|
+
clearTimeout(timeoutId);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Safely read response body
|
|
252
|
+
*/
|
|
253
|
+
async safeReadBody(response) {
|
|
254
|
+
try {
|
|
255
|
+
return await response.text();
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
return undefined;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Sleep utility
|
|
263
|
+
*/
|
|
264
|
+
sleep(ms) {
|
|
265
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Get export statistics
|
|
269
|
+
*/
|
|
270
|
+
getStats() {
|
|
271
|
+
return {
|
|
272
|
+
buffered: this.buffer.length,
|
|
273
|
+
isFlushing: this.isFlushing,
|
|
274
|
+
isShutdown: this.isShutdown,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Error class for OTLP export failures
|
|
280
|
+
*/
|
|
281
|
+
export class OTLPExportError extends Error {
|
|
282
|
+
statusCode;
|
|
283
|
+
responseBody;
|
|
284
|
+
cause;
|
|
285
|
+
constructor(message, statusCode, responseBody, cause) {
|
|
286
|
+
super(message, cause ? { cause } : undefined);
|
|
287
|
+
this.statusCode = statusCode;
|
|
288
|
+
this.responseBody = responseBody;
|
|
289
|
+
this.cause = cause;
|
|
290
|
+
this.name = 'OTLPExportError';
|
|
291
|
+
}
|
|
292
|
+
get isNetworkError() {
|
|
293
|
+
return this.statusCode === 0;
|
|
294
|
+
}
|
|
295
|
+
get isTimeout() {
|
|
296
|
+
return this.statusCode === 408;
|
|
297
|
+
}
|
|
298
|
+
get isClientError() {
|
|
299
|
+
return this.statusCode >= 400 && this.statusCode < 500;
|
|
300
|
+
}
|
|
301
|
+
get isServerError() {
|
|
302
|
+
return this.statusCode >= 500 && this.statusCode < 600;
|
|
303
|
+
}
|
|
304
|
+
get isRetryable() {
|
|
305
|
+
return this.isNetworkError || this.isTimeout || this.isServerError;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=exporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exporter.js","sourceRoot":"","sources":["../../src/otlp/exporter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAGpC,OAAO,EAIN,gBAAgB,EAChB,UAAU,GACV,MAAM,SAAS,CAAA;AAkFhB;;GAEG;AACH,MAAM,QAAQ,GAAG;IAChB,SAAS,EAAE,GAAG;IACd,aAAa,EAAE,IAAI;IACnB,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,IAAI;CACJ,CAAA;AAEV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,YAAY;IACP,MAAM,CAMJ;IAEF,kBAAkB,CAAgB;IAC3C,MAAM,GAAe,EAAE,CAAA;IACvB,UAAU,GAA0C,IAAI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AAG,GAAG,CAAA;IACvD,CAAC;IAED,IAAI,WAAW;QACd,OAAO,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,aAAa,CAAA;IACnE,CAAC;CACD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OTLP (OpenTelemetry Protocol) support for vestig
|
|
3
|
+
*
|
|
4
|
+
* This module provides OTLP-compatible export of spans to any
|
|
5
|
+
* OpenTelemetry backend (Jaeger, Honeycomb, Grafana, Vercel, etc.)
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { span, registerSpanProcessor } from 'vestig'
|
|
10
|
+
* import { OTLPExporter } from 'vestig/otlp'
|
|
11
|
+
*
|
|
12
|
+
* // Create and register the exporter
|
|
13
|
+
* const exporter = new OTLPExporter({
|
|
14
|
+
* endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
|
|
15
|
+
* serviceName: 'my-service',
|
|
16
|
+
* serviceVersion: '1.0.0',
|
|
17
|
+
* environment: process.env.NODE_ENV,
|
|
18
|
+
* headers: {
|
|
19
|
+
* 'Authorization': `Bearer ${process.env.OTEL_TOKEN}`,
|
|
20
|
+
* },
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* registerSpanProcessor(exporter)
|
|
24
|
+
*
|
|
25
|
+
* // Now your spans are exported to the OTLP endpoint
|
|
26
|
+
* await span('http:request', async (s) => {
|
|
27
|
+
* s.setAttribute('http.method', 'GET')
|
|
28
|
+
* s.setAttribute('http.url', '/api/users')
|
|
29
|
+
* const response = await fetch('/api/users')
|
|
30
|
+
* s.setAttribute('http.status_code', response.status)
|
|
31
|
+
* return response.json()
|
|
32
|
+
* })
|
|
33
|
+
*
|
|
34
|
+
* // Graceful shutdown
|
|
35
|
+
* process.on('SIGTERM', async () => {
|
|
36
|
+
* await shutdownSpanProcessors()
|
|
37
|
+
* process.exit(0)
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export { OTLPExporter, OTLPExportError } from './exporter';
|
|
42
|
+
export type { OTLPExporterConfig } from './exporter';
|
|
43
|
+
export { spanProcessors, registerSpanProcessor, unregisterSpanProcessor, getSpanProcessors, flushSpanProcessors, shutdownSpanProcessors, } from './processor';
|
|
44
|
+
export type { SpanProcessor } from './processor';
|
|
45
|
+
export { toOTLPSpan, toOTLPAttributes, toOTLPAttributeValue, toOTLPStatusCode, msToNano, isoToNano, OTLPStatusCode, OTLPSpanKind, OTLPSeverityNumber, } from './types';
|
|
46
|
+
export type { OTLPSpan, OTLPSpanEvent, OTLPSpanLink, OTLPSpanStatus, OTLPResource, OTLPInstrumentationScope, OTLPAttributeValue, OTLPKeyValue, OTLPExportTraceServiceRequest, OTLPResourceSpans, OTLPScopeSpans, OTLPLogRecord, OTLPExportLogsServiceRequest, OTLPResourceLogs, OTLPScopeLogs, } from './types';
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/otlp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC1D,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAGpD,OAAO,EACN,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGhD,OAAO,EAEN,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,QAAQ,EACR,SAAS,EAET,cAAc,EACd,YAAY,EACZ,kBAAkB,GAClB,MAAM,SAAS,CAAA;AAEhB,YAAY,EAEX,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,cAAc,EAEd,YAAY,EACZ,wBAAwB,EAExB,kBAAkB,EAClB,YAAY,EAEZ,6BAA6B,EAC7B,iBAAiB,EACjB,cAAc,EAEd,aAAa,EACb,4BAA4B,EAC5B,gBAAgB,EAChB,aAAa,GACb,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OTLP (OpenTelemetry Protocol) support for vestig
|
|
3
|
+
*
|
|
4
|
+
* This module provides OTLP-compatible export of spans to any
|
|
5
|
+
* OpenTelemetry backend (Jaeger, Honeycomb, Grafana, Vercel, etc.)
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { span, registerSpanProcessor } from 'vestig'
|
|
10
|
+
* import { OTLPExporter } from 'vestig/otlp'
|
|
11
|
+
*
|
|
12
|
+
* // Create and register the exporter
|
|
13
|
+
* const exporter = new OTLPExporter({
|
|
14
|
+
* endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
|
|
15
|
+
* serviceName: 'my-service',
|
|
16
|
+
* serviceVersion: '1.0.0',
|
|
17
|
+
* environment: process.env.NODE_ENV,
|
|
18
|
+
* headers: {
|
|
19
|
+
* 'Authorization': `Bearer ${process.env.OTEL_TOKEN}`,
|
|
20
|
+
* },
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* registerSpanProcessor(exporter)
|
|
24
|
+
*
|
|
25
|
+
* // Now your spans are exported to the OTLP endpoint
|
|
26
|
+
* await span('http:request', async (s) => {
|
|
27
|
+
* s.setAttribute('http.method', 'GET')
|
|
28
|
+
* s.setAttribute('http.url', '/api/users')
|
|
29
|
+
* const response = await fetch('/api/users')
|
|
30
|
+
* s.setAttribute('http.status_code', response.status)
|
|
31
|
+
* return response.json()
|
|
32
|
+
* })
|
|
33
|
+
*
|
|
34
|
+
* // Graceful shutdown
|
|
35
|
+
* process.on('SIGTERM', async () => {
|
|
36
|
+
* await shutdownSpanProcessors()
|
|
37
|
+
* process.exit(0)
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
// Exporter
|
|
42
|
+
export { OTLPExporter, OTLPExportError } from './exporter';
|
|
43
|
+
// Span Processor
|
|
44
|
+
export { spanProcessors, registerSpanProcessor, unregisterSpanProcessor, getSpanProcessors, flushSpanProcessors, shutdownSpanProcessors, } from './processor';
|
|
45
|
+
// Types (for advanced use cases)
|
|
46
|
+
export {
|
|
47
|
+
// Conversion utilities
|
|
48
|
+
toOTLPSpan, toOTLPAttributes, toOTLPAttributeValue, toOTLPStatusCode, msToNano, isoToNano,
|
|
49
|
+
// Enums
|
|
50
|
+
OTLPStatusCode, OTLPSpanKind, OTLPSeverityNumber, } from './types';
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/otlp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,WAAW;AACX,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAG1D,iBAAiB;AACjB,OAAO,EACN,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,aAAa,CAAA;AAGpB,iCAAiC;AACjC,OAAO;AACN,uBAAuB;AACvB,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,QAAQ,EACR,SAAS;AACT,QAAQ;AACR,cAAc,EACd,YAAY,EACZ,kBAAkB,GAClB,MAAM,SAAS,CAAA"}
|