@atrim/instrument-node 0.9.1-dev.2a45310.20260120032104 → 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
|
@@ -8,6 +8,7 @@ var yaml = require('yaml');
|
|
|
8
8
|
var zod = require('zod');
|
|
9
9
|
var fs = require('fs');
|
|
10
10
|
var path2 = require('path');
|
|
11
|
+
var TracerModule = require('effect/Tracer');
|
|
11
12
|
var opentelemetry = require('@effect/opentelemetry');
|
|
12
13
|
var OtelApi = require('@opentelemetry/api');
|
|
13
14
|
var sdkTraceBase = require('@opentelemetry/sdk-trace-base');
|
|
@@ -38,6 +39,7 @@ var HttpClientRequest__namespace = /*#__PURE__*/_interopNamespace(HttpClientRequ
|
|
|
38
39
|
var yaml__namespace = /*#__PURE__*/_interopNamespace(yaml);
|
|
39
40
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
40
41
|
var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
|
|
42
|
+
var TracerModule__namespace = /*#__PURE__*/_interopNamespace(TracerModule);
|
|
41
43
|
var OtelApi__namespace = /*#__PURE__*/_interopNamespace(OtelApi);
|
|
42
44
|
|
|
43
45
|
var __defProp = Object.defineProperty;
|
|
@@ -754,9 +756,9 @@ function parseSourceLocation(stack) {
|
|
|
754
756
|
const match = line.match(/at\s+(?:.*?\s+\()?(.+):(\d+):(\d+)\)?/);
|
|
755
757
|
if (match && match[1] && match[2]) {
|
|
756
758
|
return {
|
|
757
|
-
|
|
759
|
+
file: match[1],
|
|
758
760
|
line: parseInt(match[2], 10),
|
|
759
|
-
|
|
761
|
+
...match[3] ? { column: parseInt(match[3], 10) } : {}
|
|
760
762
|
};
|
|
761
763
|
}
|
|
762
764
|
}
|
|
@@ -764,12 +766,12 @@ function parseSourceLocation(stack) {
|
|
|
764
766
|
}
|
|
765
767
|
function makeSourceKey(source) {
|
|
766
768
|
if (!source) return "unknown";
|
|
767
|
-
return `${source.
|
|
769
|
+
return `${source.file}:${source.line}`;
|
|
768
770
|
}
|
|
769
771
|
function formatLocation(source) {
|
|
770
772
|
if (!source) return "unknown";
|
|
771
|
-
const filename = source.
|
|
772
|
-
return
|
|
773
|
+
const filename = source.file.split("/").pop() ?? source.file;
|
|
774
|
+
return `${filename}:${source.line}`;
|
|
773
775
|
}
|
|
774
776
|
function getGlobalProviderSetup() {
|
|
775
777
|
if (_globalProviderSetup === void 0) {
|
|
@@ -777,15 +779,15 @@ function getGlobalProviderSetup() {
|
|
|
777
779
|
}
|
|
778
780
|
return _globalProviderSetup;
|
|
779
781
|
}
|
|
780
|
-
var
|
|
782
|
+
var currentSourceLocation; exports.UnifiedTracingSupervisor = void 0; var setupGlobalTracerProvider, _globalProviderSetup; exports.createUnifiedTracingLayer = void 0; exports.UnifiedTracingLive = void 0; exports.enableOpSupervision = void 0; exports.withUnifiedTracing = void 0; exports.withAutoTracing = void 0; exports.flushAndShutdown = void 0; exports.forceFlush = void 0;
|
|
781
783
|
var init_unified_tracing_supervisor = __esm({
|
|
782
784
|
"src/integrations/effect/auto/unified-tracing-supervisor.ts"() {
|
|
783
785
|
init_dist();
|
|
784
786
|
init_config();
|
|
785
787
|
init_span_control();
|
|
786
788
|
init_span_control();
|
|
787
|
-
|
|
788
|
-
/* @__PURE__ */ Symbol.for("effect/FiberRef/
|
|
789
|
+
currentSourceLocation = effect.GlobalValue.globalValue(
|
|
790
|
+
/* @__PURE__ */ Symbol.for("effect/FiberRef/currentSourceLocation"),
|
|
789
791
|
() => effect.FiberRef.unsafeMake(void 0)
|
|
790
792
|
);
|
|
791
793
|
exports.UnifiedTracingSupervisor = class extends effect.Supervisor.AbstractSupervisor {
|
|
@@ -851,9 +853,11 @@ var init_unified_tracing_supervisor = __esm({
|
|
|
851
853
|
span.setAttribute("effect.item_count", meta.count);
|
|
852
854
|
}
|
|
853
855
|
if (opConfig.includeStack && location) {
|
|
854
|
-
span.setAttribute("code.filepath", location.
|
|
856
|
+
span.setAttribute("code.filepath", location.file);
|
|
855
857
|
span.setAttribute("code.lineno", location.line);
|
|
856
|
-
|
|
858
|
+
if (location.column !== void 0) {
|
|
859
|
+
span.setAttribute("code.column", location.column);
|
|
860
|
+
}
|
|
857
861
|
}
|
|
858
862
|
logger.log(
|
|
859
863
|
`@atrim/unified-tracing: Created operation span "${spanName}" spanId=${span.spanContext().spanId}`
|
|
@@ -888,7 +892,7 @@ var init_unified_tracing_supervisor = __esm({
|
|
|
888
892
|
return;
|
|
889
893
|
}
|
|
890
894
|
const nameOverride = effect.FiberRefs.getOrDefault(fiberRefs, exports.AutoTracingSpanName);
|
|
891
|
-
const sourceLocation = effect.FiberRefs.getOrDefault(fiberRefs,
|
|
895
|
+
const sourceLocation = effect.FiberRefs.getOrDefault(fiberRefs, currentSourceLocation);
|
|
892
896
|
const sourceKey = makeSourceKey(sourceLocation);
|
|
893
897
|
logger.log(`@atrim/unified-tracing: onStart fiber ${fiberId} at ${sourceKey}`);
|
|
894
898
|
let parentContext;
|
|
@@ -923,11 +927,10 @@ var init_unified_tracing_supervisor = __esm({
|
|
|
923
927
|
span.setAttribute("effect.auto_traced", true);
|
|
924
928
|
span.setAttribute("effect.fiber.id", fiberId);
|
|
925
929
|
if (sourceLocation) {
|
|
926
|
-
span.setAttribute("code.filepath", sourceLocation.
|
|
930
|
+
span.setAttribute("code.filepath", sourceLocation.file);
|
|
927
931
|
span.setAttribute("code.lineno", sourceLocation.line);
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
span.setAttribute("code.function", sourceLocation.label);
|
|
932
|
+
if (sourceLocation.column !== void 0) {
|
|
933
|
+
span.setAttribute("code.column", sourceLocation.column);
|
|
931
934
|
}
|
|
932
935
|
}
|
|
933
936
|
if (effect.Option.isSome(parent)) {
|
|
@@ -996,6 +999,16 @@ var init_unified_tracing_supervisor = __esm({
|
|
|
996
999
|
return OtelApi__namespace.ROOT_CONTEXT;
|
|
997
1000
|
}
|
|
998
1001
|
resolveParentContextFromFiberRefs(fiberRefs, context2, parent) {
|
|
1002
|
+
const inheritedCtx = effect.FiberRefs.getOrDefault(fiberRefs, TracerModule__namespace.currentOtelSpanContext);
|
|
1003
|
+
if (inheritedCtx) {
|
|
1004
|
+
const span = OtelApi__namespace.trace.getSpan(inheritedCtx);
|
|
1005
|
+
if (span) {
|
|
1006
|
+
logger.log(
|
|
1007
|
+
`@atrim/unified-tracing: Using inherited OTel context from FiberRef - spanId=${span.spanContext().spanId}`
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
return inheritedCtx;
|
|
1011
|
+
}
|
|
999
1012
|
const maybeParentSpan = effect.Context.getOption(context2, effect.Tracer.ParentSpan);
|
|
1000
1013
|
if (effect.Option.isSome(maybeParentSpan)) {
|
|
1001
1014
|
const effectSpan = maybeParentSpan.value;
|
|
@@ -1127,7 +1140,12 @@ var init_unified_tracing_supervisor = __esm({
|
|
|
1127
1140
|
const opSupervisionLayer = effect.Layer.effectDiscard(
|
|
1128
1141
|
effect.Effect.patchRuntimeFlags(effect.RuntimeFlagsPatch.enable(effect.RuntimeFlags.OpSupervision))
|
|
1129
1142
|
);
|
|
1130
|
-
return effect.Layer.mergeAll(
|
|
1143
|
+
return effect.Layer.mergeAll(
|
|
1144
|
+
effect.Layer.discard(tracerWithResource),
|
|
1145
|
+
effect.Layer.enableSourceCapture,
|
|
1146
|
+
supervisorLayer,
|
|
1147
|
+
opSupervisionLayer
|
|
1148
|
+
);
|
|
1131
1149
|
};
|
|
1132
1150
|
exports.UnifiedTracingLive = effect.Layer.suspend(
|
|
1133
1151
|
() => exports.createUnifiedTracingLayer()
|
|
@@ -1149,7 +1167,11 @@ var init_unified_tracing_supervisor = __esm({
|
|
|
1149
1167
|
const opSupervisionLayer = effect.Layer.effectDiscard(
|
|
1150
1168
|
effect.Effect.patchRuntimeFlags(effect.RuntimeFlagsPatch.enable(effect.RuntimeFlags.OpSupervision))
|
|
1151
1169
|
);
|
|
1152
|
-
const combinedLayer = effect.Layer.mergeAll(
|
|
1170
|
+
const combinedLayer = effect.Layer.mergeAll(
|
|
1171
|
+
supervisorLayer,
|
|
1172
|
+
effect.Layer.enableSourceCapture,
|
|
1173
|
+
opSupervisionLayer
|
|
1174
|
+
);
|
|
1153
1175
|
const wrappedEffect = rootSpanName ? effect$1.pipe(effect.Effect.withSpan(rootSpanName)) : effect$1;
|
|
1154
1176
|
return wrappedEffect.pipe(effect.Effect.provide(combinedLayer));
|
|
1155
1177
|
};
|