@inference-net/otel-cf-workers 2.0.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/LICENSE +28 -0
- package/README.md +426 -0
- package/dist/console-Cy5QdByD.js +38 -0
- package/dist/console-Cy5QdByD.js.map +1 -0
- package/dist/index.d.ts +555 -0
- package/dist/index.js +3664 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
import { Attributes } from '@opentelemetry/api';
|
|
2
|
+
import { AttributeValue } from '@opentelemetry/api';
|
|
3
|
+
import { Context } from '@opentelemetry/api';
|
|
4
|
+
import { DurableObject as DurableObject_2 } from 'cloudflare:workers';
|
|
5
|
+
import { Exception } from '@opentelemetry/api';
|
|
6
|
+
import { ExportResult } from '@opentelemetry/core';
|
|
7
|
+
import { HrTime } from '@opentelemetry/api';
|
|
8
|
+
import { InstrumentationScope } from '@opentelemetry/core';
|
|
9
|
+
import { Link } from '@opentelemetry/api';
|
|
10
|
+
import { OTLPExporterError } from '@opentelemetry/otlp-exporter-base';
|
|
11
|
+
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
12
|
+
import { Resource } from '@opentelemetry/resources';
|
|
13
|
+
import { Sampler } from '@opentelemetry/sdk-trace-base';
|
|
14
|
+
import { Span } from '@opentelemetry/api';
|
|
15
|
+
import { SpanContext } from '@opentelemetry/api';
|
|
16
|
+
import { SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
17
|
+
import { SpanKind } from '@opentelemetry/api';
|
|
18
|
+
import { SpanOptions } from '@opentelemetry/api';
|
|
19
|
+
import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
20
|
+
import { SpanStatus } from '@opentelemetry/api';
|
|
21
|
+
import { TextMapPropagator } from '@opentelemetry/api';
|
|
22
|
+
import { TimedEvent } from '@opentelemetry/sdk-trace-base';
|
|
23
|
+
import { TimeInput } from '@opentelemetry/api';
|
|
24
|
+
|
|
25
|
+
export declare const __unwrappedFetch: typeof fetch;
|
|
26
|
+
|
|
27
|
+
declare type AcceptTraceContextFn = (request: Request) => boolean;
|
|
28
|
+
|
|
29
|
+
export declare interface BatchConfig {
|
|
30
|
+
strategy?: 'immediate' | 'size';
|
|
31
|
+
maxQueueSize?: number;
|
|
32
|
+
maxExportBatchSize?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Batch Size Log Record Processor
|
|
37
|
+
* Batches log records up to a maximum queue size before exporting
|
|
38
|
+
*/
|
|
39
|
+
export declare class BatchSizeLogRecordProcessor implements LogRecordProcessor {
|
|
40
|
+
private transport;
|
|
41
|
+
private logRecords;
|
|
42
|
+
private exportPromises;
|
|
43
|
+
private maxQueueSize;
|
|
44
|
+
private maxExportBatchSize;
|
|
45
|
+
constructor(transport: LogTransport, config?: BatchConfig);
|
|
46
|
+
onEmit(logRecord: ReadableLogRecord, _context: Context): void;
|
|
47
|
+
forceFlush(): Promise<void>;
|
|
48
|
+
private export;
|
|
49
|
+
shutdown(): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export declare type BatchStrategy = 'trace' | 'immediate' | 'size';
|
|
53
|
+
|
|
54
|
+
export declare class BatchTraceSpanProcessor implements TraceFlushableSpanProcessor {
|
|
55
|
+
private exporter;
|
|
56
|
+
private traces;
|
|
57
|
+
constructor(exporter: SpanExporter);
|
|
58
|
+
getTraceState(traceId: string): TraceState;
|
|
59
|
+
onStart(span: Span, _parentContext: Context): void;
|
|
60
|
+
onEnd(span: ReadableSpan): void;
|
|
61
|
+
forceFlush(traceId?: traceId): Promise<void>;
|
|
62
|
+
shutdown(): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export declare type ConfigurationOption = WorkerOtelConfig | ResolveConfigFn;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Console Transport for Logs
|
|
69
|
+
* Pretty-prints logs to the console for development
|
|
70
|
+
*/
|
|
71
|
+
export declare class ConsoleTransport implements LogTransport {
|
|
72
|
+
readonly name = "console";
|
|
73
|
+
private options;
|
|
74
|
+
constructor(options?: ConsoleTransportConfig);
|
|
75
|
+
export(logs: ReadableLogRecord[], callback: ExportResultCallback): void;
|
|
76
|
+
private printLog;
|
|
77
|
+
private prettyPrint;
|
|
78
|
+
private serializeLog;
|
|
79
|
+
private getSeverityText;
|
|
80
|
+
shutdown(): Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export declare interface ConsoleTransportConfig {
|
|
84
|
+
pretty?: boolean;
|
|
85
|
+
colors?: boolean;
|
|
86
|
+
includeTimestamp?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Factory function to create a log processor based on strategy
|
|
91
|
+
*/
|
|
92
|
+
export declare function createLogProcessor(transport: LogTransport, config?: BatchConfig): LogRecordProcessor;
|
|
93
|
+
|
|
94
|
+
export declare function createSampler(conf: ParentRatioSamplingConfig): Sampler;
|
|
95
|
+
|
|
96
|
+
declare type DO = DurableObject | DurableObject_2;
|
|
97
|
+
|
|
98
|
+
declare type DOClass = {
|
|
99
|
+
new (state: DurableObjectState, env: any): DO;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export declare interface DOConstructorTrigger {
|
|
103
|
+
id: string;
|
|
104
|
+
name?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare type Env_2 = Record<string, any>;
|
|
108
|
+
|
|
109
|
+
export declare type ExporterConfig = OTLPExporterConfig | SpanExporter;
|
|
110
|
+
|
|
111
|
+
export declare type ExportResultCallback = (result: ExportResult) => void;
|
|
112
|
+
|
|
113
|
+
export declare const exportSpans: typeof exportTelemetry;
|
|
114
|
+
|
|
115
|
+
export declare function exportTelemetry(traceId: string, tracker?: PromiseTracker): Promise<void>;
|
|
116
|
+
|
|
117
|
+
declare interface FetcherConfig {
|
|
118
|
+
includeTraceContext?: boolean | IncludeTraceContextFn;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
declare interface FetchHandlerConfig {
|
|
122
|
+
/**
|
|
123
|
+
* Whether to enable context propagation for incoming requests to `fetch`.
|
|
124
|
+
* This enables or disables distributed tracing from W3C Trace Context headers.
|
|
125
|
+
* @default true
|
|
126
|
+
*/
|
|
127
|
+
acceptTraceContext?: boolean | AcceptTraceContextFn;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare function getGlobalLoggerProvider(): LoggerProvider;
|
|
131
|
+
|
|
132
|
+
export declare function getLogger(name: string, version?: string, options?: LoggerOptions): Logger;
|
|
133
|
+
|
|
134
|
+
export declare interface HandlerConfig {
|
|
135
|
+
fetch?: FetchHandlerConfig;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export declare interface HandlerInstrumentation<T extends Trigger, R extends any> {
|
|
139
|
+
getInitialSpanInfo: (trigger: T) => InitialSpanInfo;
|
|
140
|
+
getAttributesFromResult?: (result: Awaited<R>) => Attributes;
|
|
141
|
+
instrumentTrigger?: (trigger: T) => T;
|
|
142
|
+
executionSucces?: (span: Span, trigger: T, result: Awaited<R>) => void;
|
|
143
|
+
executionFailed?: (span: Span, trigger: T, error?: any) => void;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare type HeadSamplerConf = Sampler | ParentRatioSamplingConfig;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Immediate Log Record Processor
|
|
150
|
+
* Exports each log record immediately without batching
|
|
151
|
+
*/
|
|
152
|
+
export declare class ImmediateLogRecordProcessor implements LogRecordProcessor {
|
|
153
|
+
private transport;
|
|
154
|
+
private exportPromises;
|
|
155
|
+
constructor(transport: LogTransport);
|
|
156
|
+
onEmit(logRecord: ReadableLogRecord, _context: Context): void;
|
|
157
|
+
private exportLog;
|
|
158
|
+
forceFlush(): Promise<void>;
|
|
159
|
+
shutdown(): Promise<void>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
declare type IncludeTraceContextFn = (request: Request) => boolean;
|
|
163
|
+
|
|
164
|
+
export declare interface InitialSpanInfo {
|
|
165
|
+
name: string;
|
|
166
|
+
options: SpanOptions;
|
|
167
|
+
context?: Context;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export declare function instrument<E extends Env_2, Q, C>(handler: ExportedHandler<E, Q, C>, config: ConfigurationOption): ExportedHandler<E, Q, C>;
|
|
171
|
+
|
|
172
|
+
export declare interface InstrumentationOptions {
|
|
173
|
+
instrumentGlobalFetch?: boolean;
|
|
174
|
+
instrumentGlobalCache?: boolean;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export declare function instrumentDO(doClass: DOClass, config: ConfigurationOption): DOClass;
|
|
178
|
+
|
|
179
|
+
export declare function isAlarm(trigger: Trigger): trigger is 'do-alarm';
|
|
180
|
+
|
|
181
|
+
export declare const isHeadSampled: TailSampleFn;
|
|
182
|
+
|
|
183
|
+
export declare function isMessageBatch(trigger: Trigger): trigger is MessageBatch;
|
|
184
|
+
|
|
185
|
+
export declare function isRequest(trigger: Trigger): trigger is Request;
|
|
186
|
+
|
|
187
|
+
export declare const isRootErrorSpan: TailSampleFn;
|
|
188
|
+
|
|
189
|
+
export declare function isSpanProcessorConfig(config: TraceConfig): config is TraceConfigSpanProcessors;
|
|
190
|
+
|
|
191
|
+
export declare interface LocalTrace {
|
|
192
|
+
readonly traceId: string;
|
|
193
|
+
readonly localRootSpan: ReadableSpan;
|
|
194
|
+
readonly spans: ReadableSpan[];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export declare interface LogAttributes {
|
|
198
|
+
[key: string]: any;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export declare type LogBody = string | Record<string, any>;
|
|
202
|
+
|
|
203
|
+
export declare interface Logger {
|
|
204
|
+
emit(logRecord: Partial<LogRecord>): void;
|
|
205
|
+
trace(message: string, attributes?: LogAttributes): void;
|
|
206
|
+
debug(message: string, attributes?: LogAttributes): void;
|
|
207
|
+
info(message: string, attributes?: LogAttributes): void;
|
|
208
|
+
warn(message: string, attributes?: LogAttributes): void;
|
|
209
|
+
error(message: string | Error, attributes?: LogAttributes): void;
|
|
210
|
+
fatal(message: string, attributes?: LogAttributes): void;
|
|
211
|
+
forceFlush(): Promise<void>;
|
|
212
|
+
child(attributes: LogAttributes): Logger;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export declare interface LoggerOptions {
|
|
216
|
+
schemaUrl?: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export declare interface LoggerProvider {
|
|
220
|
+
getLogger(name: string, version?: string, options?: LoggerOptions): Logger;
|
|
221
|
+
register(): void;
|
|
222
|
+
shutdown(): Promise<void>;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export declare interface LogRecord {
|
|
226
|
+
readonly timeUnixNano: HrTime;
|
|
227
|
+
readonly observedTimeUnixNano: HrTime;
|
|
228
|
+
readonly severityNumber?: SeverityNumber;
|
|
229
|
+
readonly severityText?: string;
|
|
230
|
+
readonly body?: LogBody;
|
|
231
|
+
readonly attributes: LogAttributes;
|
|
232
|
+
readonly traceId?: string;
|
|
233
|
+
readonly spanId?: string;
|
|
234
|
+
readonly traceFlags?: number;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export declare interface LogRecordProcessor {
|
|
238
|
+
onEmit(logRecord: ReadableLogRecord, context: Context): void;
|
|
239
|
+
forceFlush(): Promise<void>;
|
|
240
|
+
shutdown(): Promise<void>;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export declare interface LogsConfig {
|
|
244
|
+
transports?: LogTransport[];
|
|
245
|
+
batching?: BatchConfig;
|
|
246
|
+
instrumentation?: LogsInstrumentationOptions;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export declare interface LogsInstrumentationOptions {
|
|
250
|
+
instrumentConsole?: boolean;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export declare interface LogTransport {
|
|
254
|
+
readonly name: string;
|
|
255
|
+
export(logs: ReadableLogRecord[], callback: ExportResultCallback): void;
|
|
256
|
+
shutdown(): Promise<void>;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export declare class MultiSpanExporter implements SpanExporter {
|
|
260
|
+
private exporters;
|
|
261
|
+
constructor(exporters: Array<SpanExporter>);
|
|
262
|
+
export(items: any[], resultCallback: (result: ExportResult) => void): void;
|
|
263
|
+
shutdown(): Promise<void>;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export declare class MultiSpanExporterAsync implements SpanExporter {
|
|
267
|
+
private exporters;
|
|
268
|
+
constructor(exporters: Array<SpanExporter>);
|
|
269
|
+
export(items: any[], resultCallback: (result: ExportResult) => void): void;
|
|
270
|
+
shutdown(): Promise<void>;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export declare function multiTailSampler(samplers: TailSampleFn[]): TailSampleFn;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Multi-Transport Log Record Processor
|
|
277
|
+
* Sends log records to multiple transports in parallel
|
|
278
|
+
*/
|
|
279
|
+
export declare class MultiTransportLogRecordProcessor implements LogRecordProcessor {
|
|
280
|
+
private processors;
|
|
281
|
+
constructor(transports: LogTransport[], config?: BatchConfig);
|
|
282
|
+
onEmit(logRecord: ReadableLogRecord, context: Context): void;
|
|
283
|
+
forceFlush(): Promise<void>;
|
|
284
|
+
shutdown(): Promise<void>;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
declare type OnSpanEnd = (span: Span) => void;
|
|
288
|
+
|
|
289
|
+
export declare type OrPromise<T extends any> = T | Promise<T>;
|
|
290
|
+
|
|
291
|
+
export declare class OTLPExporter implements SpanExporter {
|
|
292
|
+
private headers;
|
|
293
|
+
private url;
|
|
294
|
+
constructor(config: OTLPExporterConfig);
|
|
295
|
+
export(items: any[], resultCallback: (result: ExportResult) => void): void;
|
|
296
|
+
private _export;
|
|
297
|
+
send(items: any[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
298
|
+
shutdown(): Promise<void>;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export declare interface OTLPExporterConfig {
|
|
302
|
+
url: string;
|
|
303
|
+
headers?: Record<string, string>;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* OTLP HTTP/JSON Transport for Logs
|
|
308
|
+
* Sends logs to an OpenTelemetry-compatible backend using OTLP/HTTP protocol
|
|
309
|
+
*/
|
|
310
|
+
export declare class OTLPTransport implements LogTransport {
|
|
311
|
+
readonly name = "otlp";
|
|
312
|
+
private headers;
|
|
313
|
+
private url;
|
|
314
|
+
constructor(config: OTLPTransportConfig);
|
|
315
|
+
export(logs: ReadableLogRecord[], callback: ExportResultCallback): void;
|
|
316
|
+
private _export;
|
|
317
|
+
private send;
|
|
318
|
+
private transformToOTLP;
|
|
319
|
+
private transformLogRecord;
|
|
320
|
+
private transformBody;
|
|
321
|
+
private transformAttributes;
|
|
322
|
+
private transformAttributeValue;
|
|
323
|
+
private hrTimeToString;
|
|
324
|
+
shutdown(): Promise<void>;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export declare interface OTLPTransportConfig {
|
|
328
|
+
url: string;
|
|
329
|
+
headers?: Record<string, string>;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export declare interface ParentRatioSamplingConfig {
|
|
333
|
+
acceptRemote?: boolean;
|
|
334
|
+
ratio: number;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export declare type PostProcessorFn = (spans: ReadableSpan[]) => ReadableSpan[];
|
|
338
|
+
|
|
339
|
+
declare class PromiseTracker {
|
|
340
|
+
_outstandingPromises: Promise<unknown>[];
|
|
341
|
+
get outstandingPromiseCount(): number;
|
|
342
|
+
track(promise: Promise<unknown>): void;
|
|
343
|
+
wait(): Promise<void>;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export declare interface ReadableLogRecord extends LogRecord {
|
|
347
|
+
readonly resource: Resource;
|
|
348
|
+
readonly instrumentationScope: InstrumentationScope;
|
|
349
|
+
readonly droppedAttributesCount: number;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export declare type ResolveConfigFn<Env = any> = (env: Env, trigger: Trigger) => WorkerOtelConfig;
|
|
353
|
+
|
|
354
|
+
export declare interface ResolvedLogsConfig {
|
|
355
|
+
processors: LogRecordProcessor[];
|
|
356
|
+
instrumentation: LogsInstrumentationOptions;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export declare interface ResolvedTraceConfig extends TraceConfigBase {
|
|
360
|
+
handlers: Required<HandlerConfig>;
|
|
361
|
+
fetch: Required<FetcherConfig>;
|
|
362
|
+
postProcessor: PostProcessorFn;
|
|
363
|
+
sampling: Required<SamplingConfig<Sampler>>;
|
|
364
|
+
spanProcessors: SpanProcessor[];
|
|
365
|
+
instrumentation: InstrumentationOptions;
|
|
366
|
+
batching: TraceBatchConfig;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export declare interface SamplingConfig<HS extends HeadSamplerConf = HeadSamplerConf> {
|
|
370
|
+
headSampler?: HS;
|
|
371
|
+
tailSampler?: TailSampleFn;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export declare interface ServiceConfig {
|
|
375
|
+
name: string;
|
|
376
|
+
namespace?: string;
|
|
377
|
+
version?: string;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export declare function setGlobalLoggerProvider(provider: LoggerProvider): void;
|
|
381
|
+
|
|
382
|
+
export declare const SEVERITY_NUMBERS: {
|
|
383
|
+
readonly TRACE: 1;
|
|
384
|
+
readonly TRACE2: 2;
|
|
385
|
+
readonly TRACE3: 3;
|
|
386
|
+
readonly TRACE4: 4;
|
|
387
|
+
readonly DEBUG: 5;
|
|
388
|
+
readonly DEBUG2: 6;
|
|
389
|
+
readonly DEBUG3: 7;
|
|
390
|
+
readonly DEBUG4: 8;
|
|
391
|
+
readonly INFO: 9;
|
|
392
|
+
readonly INFO2: 10;
|
|
393
|
+
readonly INFO3: 11;
|
|
394
|
+
readonly INFO4: 12;
|
|
395
|
+
readonly WARN: 13;
|
|
396
|
+
readonly WARN2: 14;
|
|
397
|
+
readonly WARN3: 15;
|
|
398
|
+
readonly WARN4: 16;
|
|
399
|
+
readonly ERROR: 17;
|
|
400
|
+
readonly ERROR2: 18;
|
|
401
|
+
readonly ERROR3: 19;
|
|
402
|
+
readonly ERROR4: 20;
|
|
403
|
+
readonly FATAL: 21;
|
|
404
|
+
readonly FATAL2: 22;
|
|
405
|
+
readonly FATAL3: 23;
|
|
406
|
+
readonly FATAL4: 24;
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
export declare type SeverityNumber = (typeof SEVERITY_NUMBERS)[keyof typeof SEVERITY_NUMBERS];
|
|
410
|
+
|
|
411
|
+
export declare class SpanImpl implements Span, ReadableSpan {
|
|
412
|
+
name: string;
|
|
413
|
+
private readonly _spanContext;
|
|
414
|
+
private readonly onEnd;
|
|
415
|
+
readonly parentSpanId?: string;
|
|
416
|
+
readonly parentSpanContext?: SpanContext | undefined;
|
|
417
|
+
readonly kind: SpanKind;
|
|
418
|
+
readonly attributes: Attributes;
|
|
419
|
+
status: SpanStatus;
|
|
420
|
+
endTime: HrTime;
|
|
421
|
+
private _duration;
|
|
422
|
+
readonly startTime: HrTime;
|
|
423
|
+
readonly events: TimedEvent[];
|
|
424
|
+
readonly links: Link[];
|
|
425
|
+
readonly resource: Resource;
|
|
426
|
+
instrumentationScope: InstrumentationScope;
|
|
427
|
+
private _ended;
|
|
428
|
+
private _droppedAttributesCount;
|
|
429
|
+
private _droppedEventsCount;
|
|
430
|
+
private _droppedLinksCount;
|
|
431
|
+
constructor(init: SpanInit);
|
|
432
|
+
addLink(link: Link): this;
|
|
433
|
+
addLinks(links: Link[]): this;
|
|
434
|
+
spanContext(): SpanContext;
|
|
435
|
+
setAttribute(key: string, value?: AttributeValue): this;
|
|
436
|
+
setAttributes(attributes: Attributes): this;
|
|
437
|
+
addEvent(name: string, attributesOrStartTime?: Attributes | TimeInput, startTime?: TimeInput): this;
|
|
438
|
+
setStatus(status: SpanStatus): this;
|
|
439
|
+
updateName(name: string): this;
|
|
440
|
+
end(endTime?: TimeInput): void;
|
|
441
|
+
isRecording(): boolean;
|
|
442
|
+
recordException(exception: Exception, time?: TimeInput): void;
|
|
443
|
+
get duration(): HrTime;
|
|
444
|
+
get ended(): boolean;
|
|
445
|
+
get droppedAttributesCount(): number;
|
|
446
|
+
get droppedEventsCount(): number;
|
|
447
|
+
get droppedLinksCount(): number;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
declare interface SpanInit {
|
|
451
|
+
attributes: unknown;
|
|
452
|
+
name: string;
|
|
453
|
+
onEnd: OnSpanEnd;
|
|
454
|
+
resource: Resource;
|
|
455
|
+
spanContext: SpanContext;
|
|
456
|
+
parentSpanContext?: SpanContext;
|
|
457
|
+
links?: Link[];
|
|
458
|
+
parentSpanId?: string;
|
|
459
|
+
spanKind?: SpanKind;
|
|
460
|
+
startTime?: TimeInput;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export declare type TailSampleFn = (traceInfo: LocalTrace) => boolean;
|
|
464
|
+
|
|
465
|
+
export declare interface TraceBatchConfig {
|
|
466
|
+
strategy?: BatchStrategy;
|
|
467
|
+
maxQueueSize?: number;
|
|
468
|
+
maxExportBatchSize?: number;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export declare type TraceConfig = TraceConfigExporter | TraceConfigSpanProcessors;
|
|
472
|
+
|
|
473
|
+
declare interface TraceConfigBase {
|
|
474
|
+
handlers?: HandlerConfig;
|
|
475
|
+
fetch?: FetcherConfig;
|
|
476
|
+
postProcessor?: PostProcessorFn;
|
|
477
|
+
sampling?: SamplingConfig;
|
|
478
|
+
instrumentation?: InstrumentationOptions;
|
|
479
|
+
batching?: TraceBatchConfig;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
declare interface TraceConfigExporter extends TraceConfigBase {
|
|
483
|
+
exporter: ExporterConfig;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
declare interface TraceConfigSpanProcessors extends TraceConfigBase {
|
|
487
|
+
spanProcessors: SpanProcessor | SpanProcessor[];
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export declare type TraceFlushableSpanProcessor = SpanProcessor & {
|
|
491
|
+
forceFlush: (traceId?: string) => Promise<void>;
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
declare type traceId = string;
|
|
495
|
+
|
|
496
|
+
declare class TraceState {
|
|
497
|
+
private unexportedSpans;
|
|
498
|
+
private inprogressSpans;
|
|
499
|
+
private exporter;
|
|
500
|
+
private exportPromises;
|
|
501
|
+
private localRootSpan?;
|
|
502
|
+
private traceDecision?;
|
|
503
|
+
constructor(exporter: SpanExporter);
|
|
504
|
+
addSpan(span: Span): void;
|
|
505
|
+
endSpan(span: ReadableSpan): void;
|
|
506
|
+
sample(): void;
|
|
507
|
+
flush(): Promise<void>;
|
|
508
|
+
private isSpanInProgress;
|
|
509
|
+
private exportSpans;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export declare type Trigger = Request | MessageBatch | ScheduledController | DOConstructorTrigger | 'do-alarm' | ForwardableEmailMessage;
|
|
513
|
+
|
|
514
|
+
export declare function withNextSpan(attrs: Attributes): void;
|
|
515
|
+
|
|
516
|
+
export declare class WorkerLogger implements Logger {
|
|
517
|
+
private readonly processors;
|
|
518
|
+
private readonly resource;
|
|
519
|
+
private readonly name;
|
|
520
|
+
private readonly version?;
|
|
521
|
+
private readonly inheritedAttributes;
|
|
522
|
+
constructor(name: string, processors: LogRecordProcessor[], resource: Resource, version?: string, inheritedAttributes?: LogAttributes);
|
|
523
|
+
emit(logRecord: Partial<LogRecord>): void;
|
|
524
|
+
trace(message: string, attributes?: LogAttributes): void;
|
|
525
|
+
debug(message: string, attributes?: LogAttributes): void;
|
|
526
|
+
info(message: string, attributes?: LogAttributes): void;
|
|
527
|
+
warn(message: string, attributes?: LogAttributes): void;
|
|
528
|
+
error(message: string | Error, attributes?: LogAttributes): void;
|
|
529
|
+
fatal(message: string, attributes?: LogAttributes): void;
|
|
530
|
+
forceFlush(): Promise<void>;
|
|
531
|
+
/**
|
|
532
|
+
* Create a child logger that inherits attributes from this logger
|
|
533
|
+
* Child attributes are merged with parent attributes (child takes precedence)
|
|
534
|
+
*/
|
|
535
|
+
child(attributes: LogAttributes): Logger;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export declare class WorkerLoggerProvider implements LoggerProvider {
|
|
539
|
+
private loggers;
|
|
540
|
+
private processors;
|
|
541
|
+
private resource;
|
|
542
|
+
constructor(processors: LogRecordProcessor[], resource: Resource);
|
|
543
|
+
getLogger(name: string, version?: string, options?: LoggerOptions): Logger;
|
|
544
|
+
register(): void;
|
|
545
|
+
shutdown(): Promise<void>;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
export declare interface WorkerOtelConfig {
|
|
549
|
+
service: ServiceConfig;
|
|
550
|
+
trace?: TraceConfig;
|
|
551
|
+
logs?: LogsConfig;
|
|
552
|
+
propagator?: TextMapPropagator;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
export { }
|