@atrim/instrument-node 0.9.1-dev.6bfb5ec.20260120022327 → 0.10.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/package.json +15 -15
- package/target/dist/index.cjs +2 -1
- package/target/dist/index.cjs.map +1 -1
- package/target/dist/index.js +2 -1
- package/target/dist/index.js.map +1 -1
- package/target/dist/integrations/effect/auto/index.cjs +39 -17
- package/target/dist/integrations/effect/auto/index.cjs.map +1 -1
- package/target/dist/integrations/effect/auto/index.js +38 -17
- package/target/dist/integrations/effect/auto/index.js.map +1 -1
|
@@ -7,6 +7,7 @@ import { parse } from 'yaml';
|
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import * as fs from 'fs';
|
|
9
9
|
import * as path2 from 'path';
|
|
10
|
+
import * as TracerModule from 'effect/Tracer';
|
|
10
11
|
import { Resource, Tracer as Tracer$1 } from '@effect/opentelemetry';
|
|
11
12
|
import * as OtelApi from '@opentelemetry/api';
|
|
12
13
|
import { ConsoleSpanExporter, SimpleSpanProcessor, BatchSpanProcessor, BasicTracerProvider } from '@opentelemetry/sdk-trace-base';
|
|
@@ -728,9 +729,9 @@ function parseSourceLocation(stack) {
|
|
|
728
729
|
const match = line.match(/at\s+(?:.*?\s+\()?(.+):(\d+):(\d+)\)?/);
|
|
729
730
|
if (match && match[1] && match[2]) {
|
|
730
731
|
return {
|
|
731
|
-
|
|
732
|
+
file: match[1],
|
|
732
733
|
line: parseInt(match[2], 10),
|
|
733
|
-
|
|
734
|
+
...match[3] ? { column: parseInt(match[3], 10) } : {}
|
|
734
735
|
};
|
|
735
736
|
}
|
|
736
737
|
}
|
|
@@ -738,12 +739,12 @@ function parseSourceLocation(stack) {
|
|
|
738
739
|
}
|
|
739
740
|
function makeSourceKey(source) {
|
|
740
741
|
if (!source) return "unknown";
|
|
741
|
-
return `${source.
|
|
742
|
+
return `${source.file}:${source.line}`;
|
|
742
743
|
}
|
|
743
744
|
function formatLocation(source) {
|
|
744
745
|
if (!source) return "unknown";
|
|
745
|
-
const filename = source.
|
|
746
|
-
return
|
|
746
|
+
const filename = source.file.split("/").pop() ?? source.file;
|
|
747
|
+
return `${filename}:${source.line}`;
|
|
747
748
|
}
|
|
748
749
|
function getGlobalProviderSetup() {
|
|
749
750
|
if (_globalProviderSetup === void 0) {
|
|
@@ -751,15 +752,15 @@ function getGlobalProviderSetup() {
|
|
|
751
752
|
}
|
|
752
753
|
return _globalProviderSetup;
|
|
753
754
|
}
|
|
754
|
-
var
|
|
755
|
+
var currentSourceLocation, UnifiedTracingSupervisor, setupGlobalTracerProvider, _globalProviderSetup, createUnifiedTracingLayer, UnifiedTracingLive, enableOpSupervision, withUnifiedTracing, withAutoTracing, flushAndShutdown, forceFlush;
|
|
755
756
|
var init_unified_tracing_supervisor = __esm({
|
|
756
757
|
"src/integrations/effect/auto/unified-tracing-supervisor.ts"() {
|
|
757
758
|
init_dist();
|
|
758
759
|
init_config();
|
|
759
760
|
init_span_control();
|
|
760
761
|
init_span_control();
|
|
761
|
-
|
|
762
|
-
/* @__PURE__ */ Symbol.for("effect/FiberRef/
|
|
762
|
+
currentSourceLocation = GlobalValue.globalValue(
|
|
763
|
+
/* @__PURE__ */ Symbol.for("effect/FiberRef/currentSourceLocation"),
|
|
763
764
|
() => FiberRef.unsafeMake(void 0)
|
|
764
765
|
);
|
|
765
766
|
UnifiedTracingSupervisor = class extends Supervisor.AbstractSupervisor {
|
|
@@ -825,9 +826,11 @@ var init_unified_tracing_supervisor = __esm({
|
|
|
825
826
|
span.setAttribute("effect.item_count", meta.count);
|
|
826
827
|
}
|
|
827
828
|
if (opConfig.includeStack && location) {
|
|
828
|
-
span.setAttribute("code.filepath", location.
|
|
829
|
+
span.setAttribute("code.filepath", location.file);
|
|
829
830
|
span.setAttribute("code.lineno", location.line);
|
|
830
|
-
|
|
831
|
+
if (location.column !== void 0) {
|
|
832
|
+
span.setAttribute("code.column", location.column);
|
|
833
|
+
}
|
|
831
834
|
}
|
|
832
835
|
logger.log(
|
|
833
836
|
`@atrim/unified-tracing: Created operation span "${spanName}" spanId=${span.spanContext().spanId}`
|
|
@@ -862,7 +865,7 @@ var init_unified_tracing_supervisor = __esm({
|
|
|
862
865
|
return;
|
|
863
866
|
}
|
|
864
867
|
const nameOverride = FiberRefs.getOrDefault(fiberRefs, AutoTracingSpanName);
|
|
865
|
-
const sourceLocation = FiberRefs.getOrDefault(fiberRefs,
|
|
868
|
+
const sourceLocation = FiberRefs.getOrDefault(fiberRefs, currentSourceLocation);
|
|
866
869
|
const sourceKey = makeSourceKey(sourceLocation);
|
|
867
870
|
logger.log(`@atrim/unified-tracing: onStart fiber ${fiberId} at ${sourceKey}`);
|
|
868
871
|
let parentContext;
|
|
@@ -897,11 +900,10 @@ var init_unified_tracing_supervisor = __esm({
|
|
|
897
900
|
span.setAttribute("effect.auto_traced", true);
|
|
898
901
|
span.setAttribute("effect.fiber.id", fiberId);
|
|
899
902
|
if (sourceLocation) {
|
|
900
|
-
span.setAttribute("code.filepath", sourceLocation.
|
|
903
|
+
span.setAttribute("code.filepath", sourceLocation.file);
|
|
901
904
|
span.setAttribute("code.lineno", sourceLocation.line);
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
span.setAttribute("code.function", sourceLocation.label);
|
|
905
|
+
if (sourceLocation.column !== void 0) {
|
|
906
|
+
span.setAttribute("code.column", sourceLocation.column);
|
|
905
907
|
}
|
|
906
908
|
}
|
|
907
909
|
if (Option.isSome(parent)) {
|
|
@@ -970,6 +972,16 @@ var init_unified_tracing_supervisor = __esm({
|
|
|
970
972
|
return OtelApi.ROOT_CONTEXT;
|
|
971
973
|
}
|
|
972
974
|
resolveParentContextFromFiberRefs(fiberRefs, context2, parent) {
|
|
975
|
+
const inheritedCtx = FiberRefs.getOrDefault(fiberRefs, TracerModule.currentOtelSpanContext);
|
|
976
|
+
if (inheritedCtx) {
|
|
977
|
+
const span = OtelApi.trace.getSpan(inheritedCtx);
|
|
978
|
+
if (span) {
|
|
979
|
+
logger.log(
|
|
980
|
+
`@atrim/unified-tracing: Using inherited OTel context from FiberRef - spanId=${span.spanContext().spanId}`
|
|
981
|
+
);
|
|
982
|
+
}
|
|
983
|
+
return inheritedCtx;
|
|
984
|
+
}
|
|
973
985
|
const maybeParentSpan = Context.getOption(context2, Tracer.ParentSpan);
|
|
974
986
|
if (Option.isSome(maybeParentSpan)) {
|
|
975
987
|
const effectSpan = maybeParentSpan.value;
|
|
@@ -1101,7 +1113,12 @@ var init_unified_tracing_supervisor = __esm({
|
|
|
1101
1113
|
const opSupervisionLayer = Layer.effectDiscard(
|
|
1102
1114
|
Effect.patchRuntimeFlags(RuntimeFlagsPatch.enable(RuntimeFlags.OpSupervision))
|
|
1103
1115
|
);
|
|
1104
|
-
return Layer.mergeAll(
|
|
1116
|
+
return Layer.mergeAll(
|
|
1117
|
+
Layer.discard(tracerWithResource),
|
|
1118
|
+
Layer.enableSourceCapture,
|
|
1119
|
+
supervisorLayer,
|
|
1120
|
+
opSupervisionLayer
|
|
1121
|
+
);
|
|
1105
1122
|
};
|
|
1106
1123
|
UnifiedTracingLive = Layer.suspend(
|
|
1107
1124
|
() => createUnifiedTracingLayer()
|
|
@@ -1123,7 +1140,11 @@ var init_unified_tracing_supervisor = __esm({
|
|
|
1123
1140
|
const opSupervisionLayer = Layer.effectDiscard(
|
|
1124
1141
|
Effect.patchRuntimeFlags(RuntimeFlagsPatch.enable(RuntimeFlags.OpSupervision))
|
|
1125
1142
|
);
|
|
1126
|
-
const combinedLayer = Layer.mergeAll(
|
|
1143
|
+
const combinedLayer = Layer.mergeAll(
|
|
1144
|
+
supervisorLayer,
|
|
1145
|
+
Layer.enableSourceCapture,
|
|
1146
|
+
opSupervisionLayer
|
|
1147
|
+
);
|
|
1127
1148
|
const wrappedEffect = rootSpanName ? effect.pipe(Effect.withSpan(rootSpanName)) : effect;
|
|
1128
1149
|
return wrappedEffect.pipe(Effect.provide(combinedLayer));
|
|
1129
1150
|
};
|