@atrim/instrument-node 0.7.0-14fdea7-20260108231930 → 0.7.0-14fdea7-20260108235538
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Data, Context, Effect, Layer, FiberRef, Option, Supervisor, FiberRefs, Exit } from 'effect';
|
|
1
|
+
import { Data, Context, Effect, Layer, FiberRef, Option, Supervisor, FiberRefs, Tracer, Exit } from 'effect';
|
|
2
2
|
import { NodeSdk } from '@effect/opentelemetry';
|
|
3
3
|
import { BasicTracerProvider, SimpleSpanProcessor, ConsoleSpanExporter, BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
4
4
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
@@ -780,7 +780,18 @@ var AutoTracingSupervisor = class extends Supervisor.AbstractSupervisor {
|
|
|
780
780
|
}
|
|
781
781
|
let parentContext = OtelApi.ROOT_CONTEXT;
|
|
782
782
|
let parentFiberId;
|
|
783
|
-
|
|
783
|
+
const maybeEffectParentSpan = Context.getOption(_context, Tracer.ParentSpan);
|
|
784
|
+
if (Option.isSome(maybeEffectParentSpan)) {
|
|
785
|
+
const effectSpan = maybeEffectParentSpan.value;
|
|
786
|
+
const otelSpanContext = {
|
|
787
|
+
traceId: effectSpan.traceId,
|
|
788
|
+
spanId: effectSpan.spanId,
|
|
789
|
+
traceFlags: effectSpan.sampled ? OtelApi.TraceFlags.SAMPLED : OtelApi.TraceFlags.NONE,
|
|
790
|
+
isRemote: false
|
|
791
|
+
};
|
|
792
|
+
const wrappedSpan = OtelApi.trace.wrapSpanContext(otelSpanContext);
|
|
793
|
+
parentContext = OtelApi.trace.setSpan(OtelApi.ROOT_CONTEXT, wrappedSpan);
|
|
794
|
+
} else if (Option.isSome(parent)) {
|
|
784
795
|
parentFiberId = parent.value.id().id;
|
|
785
796
|
const parentSpan = this.fiberSpans.get(parent.value);
|
|
786
797
|
if (parentSpan) {
|
|
@@ -791,6 +802,9 @@ var AutoTracingSupervisor = class extends Supervisor.AbstractSupervisor {
|
|
|
791
802
|
} else if (this._rootSpan) {
|
|
792
803
|
parentContext = OtelApi.trace.setSpan(OtelApi.ROOT_CONTEXT, this._rootSpan);
|
|
793
804
|
}
|
|
805
|
+
if (Option.isSome(parent)) {
|
|
806
|
+
parentFiberId = parent.value.id().id;
|
|
807
|
+
}
|
|
794
808
|
const span = this.tracer.startSpan(
|
|
795
809
|
spanName,
|
|
796
810
|
{
|
|
@@ -1200,7 +1214,7 @@ var createCombinedTracingLayer = () => {
|
|
|
1200
1214
|
logger.log("@atrim/auto-trace: Combined layer created");
|
|
1201
1215
|
logger.log(" - HTTP requests: auto-traced via Effect platform");
|
|
1202
1216
|
logger.log(" - Forked fibers: auto-traced via Supervisor");
|
|
1203
|
-
return Layer.
|
|
1217
|
+
return supervisorLayer.pipe(Layer.provideMerge(Layer.discard(sdkLayer)));
|
|
1204
1218
|
})
|
|
1205
1219
|
);
|
|
1206
1220
|
};
|