@inference-net/otel-cf-workers 2.4.0 → 2.5.1
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 +8 -8
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { OTLPExporterError } from '@opentelemetry/otlp-exporter-base';
|
|
|
11
11
|
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
12
12
|
import { Resource } from '@opentelemetry/resources';
|
|
13
13
|
import { Sampler } from '@opentelemetry/sdk-trace-base';
|
|
14
|
-
import { Span } from '@opentelemetry/api';
|
|
14
|
+
import { Span as Span_2 } from '@opentelemetry/api';
|
|
15
15
|
import { SpanContext } from '@opentelemetry/api';
|
|
16
16
|
import { SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
17
17
|
import { SpanKind } from '@opentelemetry/api';
|
|
@@ -56,7 +56,7 @@ export declare class BatchTraceSpanProcessor implements TraceFlushableSpanProces
|
|
|
56
56
|
private traces;
|
|
57
57
|
constructor(exporter: SpanExporter);
|
|
58
58
|
getTraceState(traceId: string): TraceState;
|
|
59
|
-
onStart(span:
|
|
59
|
+
onStart(span: Span_2, _parentContext: Context): void;
|
|
60
60
|
onEnd(span: ReadableSpan): void;
|
|
61
61
|
forceFlush(traceId?: traceId): Promise<void>;
|
|
62
62
|
shutdown(): Promise<void>;
|
|
@@ -142,8 +142,8 @@ export declare interface HandlerInstrumentation<T extends Trigger, R extends any
|
|
|
142
142
|
getInitialSpanInfo: (trigger: T) => InitialSpanInfo;
|
|
143
143
|
getAttributesFromResult?: (result: Awaited<R>) => Attributes;
|
|
144
144
|
instrumentTrigger?: (trigger: T) => T;
|
|
145
|
-
executionSucces?: (span:
|
|
146
|
-
executionFailed?: (span:
|
|
145
|
+
executionSucces?: (span: Span_2, trigger: T, result: Awaited<R>) => void;
|
|
146
|
+
executionFailed?: (span: Span_2, trigger: T, error?: any) => void;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
declare type HeadSamplerConf = Sampler | ParentRatioSamplingConfig;
|
|
@@ -327,7 +327,7 @@ export declare class MultiTransportLogRecordProcessor implements LogRecordProces
|
|
|
327
327
|
shutdown(): Promise<void>;
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
declare type OnSpanEnd = (span:
|
|
330
|
+
declare type OnSpanEnd = (span: Span_2) => void;
|
|
331
331
|
|
|
332
332
|
export declare type OrPromise<T extends any> = T | Promise<T>;
|
|
333
333
|
|
|
@@ -453,7 +453,7 @@ export declare const SEVERITY_NUMBERS: {
|
|
|
453
453
|
|
|
454
454
|
export declare type SeverityNumber = (typeof SEVERITY_NUMBERS)[keyof typeof SEVERITY_NUMBERS];
|
|
455
455
|
|
|
456
|
-
export declare class SpanImpl implements
|
|
456
|
+
export declare class SpanImpl implements Span_2, ReadableSpan {
|
|
457
457
|
name: string;
|
|
458
458
|
private readonly _spanContext;
|
|
459
459
|
private readonly onEnd;
|
|
@@ -546,10 +546,10 @@ declare class TraceState {
|
|
|
546
546
|
private localRootSpan?;
|
|
547
547
|
private traceDecision?;
|
|
548
548
|
constructor(exporter: SpanExporter);
|
|
549
|
-
addSpan(span:
|
|
549
|
+
addSpan(span: Span_2): void;
|
|
550
550
|
endSpan(span: ReadableSpan): void;
|
|
551
551
|
sample(): void;
|
|
552
|
-
flush(): Promise<
|
|
552
|
+
flush(): Promise<boolean>;
|
|
553
553
|
private isSpanInProgress;
|
|
554
554
|
private exportSpans;
|
|
555
555
|
}
|
package/dist/index.js
CHANGED
|
@@ -96,7 +96,7 @@ function passthroughGet(target, prop, thisArg) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
const PACKAGE_VERSION = "2.
|
|
99
|
+
const PACKAGE_VERSION = "2.5.1";
|
|
100
100
|
const PACKAGE_NAME = "@inference-net/otel-cf-workers";
|
|
101
101
|
const ATTR_CLOUDFLARE_COLO = "cloudflare.colo";
|
|
102
102
|
const ATTR_CLOUDFLARE_RAY_ID = "cloudflare.ray_id";
|
|
@@ -298,7 +298,7 @@ class OTLPExporter {
|
|
|
298
298
|
} else {
|
|
299
299
|
onError(new OTLPExporterError(`Exporter received a statusCode: ${response.status}`));
|
|
300
300
|
}
|
|
301
|
-
|
|
301
|
+
response.body?.cancel();
|
|
302
302
|
}).catch((error) => {
|
|
303
303
|
onError(new OTLPExporterError(`Exception during export: ${error.toString()}`, error.code, error.stack));
|
|
304
304
|
});
|
|
@@ -358,9 +358,11 @@ class TraceState {
|
|
|
358
358
|
this.exportPromises.push(this.exportSpans(this.unexportedSpans));
|
|
359
359
|
this.unexportedSpans = [];
|
|
360
360
|
}
|
|
361
|
-
|
|
361
|
+
const exportCount = this.exportPromises.length;
|
|
362
|
+
if (exportCount > 0) {
|
|
362
363
|
await Promise.allSettled(this.exportPromises);
|
|
363
364
|
}
|
|
365
|
+
return this.inprogressSpans.size === 0 && this.unexportedSpans.length === 0 && this.exportPromises.length === exportCount;
|
|
364
366
|
}
|
|
365
367
|
isSpanInProgress(span) {
|
|
366
368
|
return this.inprogressSpans.has(span.spanContext().spanId);
|
|
@@ -399,11 +401,13 @@ class BatchTraceSpanProcessor {
|
|
|
399
401
|
this.getTraceState(traceId).endSpan(span);
|
|
400
402
|
}
|
|
401
403
|
async forceFlush(traceId) {
|
|
402
|
-
if (traceId) {
|
|
403
|
-
await this.
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
404
|
+
if (!traceId) {
|
|
405
|
+
await Promise.allSettled(Object.keys(this.traces).map((id) => this.forceFlush(id)));
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
const state = this.traces[traceId];
|
|
409
|
+
if (state && await state.flush() && this.traces[traceId] === state) {
|
|
410
|
+
delete this.traces[traceId];
|
|
407
411
|
}
|
|
408
412
|
}
|
|
409
413
|
async shutdown() {
|
|
@@ -3525,7 +3529,6 @@ function findVersionMeta() {
|
|
|
3525
3529
|
});
|
|
3526
3530
|
}
|
|
3527
3531
|
const createResource = (serviceConfig, versionMeta) => {
|
|
3528
|
-
console.log({ versionMeta });
|
|
3529
3532
|
const workerResourceAttrs = {
|
|
3530
3533
|
"cloud.provider": "cloudflare",
|
|
3531
3534
|
"cloud.platform": "cloudflare.workers",
|