@atrim/instrument-node 0.9.0 → 0.9.1-dev.6bfb5ec.20260120022327

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