@atrim/instrument-node 0.7.0-14fdea7-20260108225522 → 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.
- package/package.json +1 -1
- package/target/dist/integrations/effect/auto/index.cjs +153 -62
- package/target/dist/integrations/effect/auto/index.cjs.map +1 -1
- package/target/dist/integrations/effect/auto/index.d.cts +48 -1
- package/target/dist/integrations/effect/auto/index.d.ts +48 -1
- package/target/dist/integrations/effect/auto/index.js +154 -65
- package/target/dist/integrations/effect/auto/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -611,67 +611,6 @@ var loadFullConfig = (options) => effect.Effect.gen(function* () {
|
|
|
611
611
|
}
|
|
612
612
|
return config;
|
|
613
613
|
});
|
|
614
|
-
|
|
615
|
-
// src/integrations/effect/auto/effect-tracing.ts
|
|
616
|
-
var createEffectTracingLayer = () => {
|
|
617
|
-
return effect.Layer.unwrapEffect(
|
|
618
|
-
effect.Effect.gen(function* () {
|
|
619
|
-
const config = yield* loadFullConfig();
|
|
620
|
-
const serviceName = process.env.OTEL_SERVICE_NAME || "effect-service";
|
|
621
|
-
const serviceVersion = process.env.npm_package_version || "1.0.0";
|
|
622
|
-
const exporterConfig = config.effect?.exporter_config ?? {
|
|
623
|
-
type: "otlp",
|
|
624
|
-
processor: "batch"
|
|
625
|
-
};
|
|
626
|
-
logger.log("@atrim/auto-trace: Effect-native tracing enabled");
|
|
627
|
-
logger.log(` Service: ${serviceName}`);
|
|
628
|
-
logger.log(` Exporter: ${exporterConfig.type}`);
|
|
629
|
-
if (exporterConfig.type === "none") {
|
|
630
|
-
logger.log('@atrim/auto-trace: Exporter type is "none", using empty layer');
|
|
631
|
-
return effect.Layer.empty;
|
|
632
|
-
}
|
|
633
|
-
const createSpanProcessor = () => {
|
|
634
|
-
if (exporterConfig.type === "console") {
|
|
635
|
-
logger.log("@atrim/auto-trace: Using ConsoleSpanExporter with SimpleSpanProcessor");
|
|
636
|
-
return new sdkTraceBase.SimpleSpanProcessor(new sdkTraceBase.ConsoleSpanExporter());
|
|
637
|
-
}
|
|
638
|
-
const endpoint = exporterConfig.endpoint || process.env.OTEL_EXPORTER_OTLP_ENDPOINT || "http://localhost:4318";
|
|
639
|
-
logger.log(`@atrim/auto-trace: Using OTLPTraceExporter (${endpoint})`);
|
|
640
|
-
const otlpConfig = {
|
|
641
|
-
url: `${endpoint}/v1/traces`
|
|
642
|
-
};
|
|
643
|
-
if (exporterConfig.headers) {
|
|
644
|
-
otlpConfig.headers = exporterConfig.headers;
|
|
645
|
-
logger.log(`@atrim/auto-trace: Using custom headers: ${Object.keys(exporterConfig.headers).join(", ")}`);
|
|
646
|
-
}
|
|
647
|
-
const exporter = new exporterTraceOtlpHttp.OTLPTraceExporter(otlpConfig);
|
|
648
|
-
if (exporterConfig.processor === "simple") {
|
|
649
|
-
logger.log("@atrim/auto-trace: Using SimpleSpanProcessor");
|
|
650
|
-
return new sdkTraceBase.SimpleSpanProcessor(exporter);
|
|
651
|
-
}
|
|
652
|
-
const batchConfig = exporterConfig.batch ?? {
|
|
653
|
-
scheduled_delay_millis: 1e3,
|
|
654
|
-
max_export_batch_size: 100
|
|
655
|
-
};
|
|
656
|
-
logger.log("@atrim/auto-trace: Using BatchSpanProcessor");
|
|
657
|
-
return new sdkTraceBase.BatchSpanProcessor(exporter, {
|
|
658
|
-
scheduledDelayMillis: batchConfig.scheduled_delay_millis,
|
|
659
|
-
maxExportBatchSize: batchConfig.max_export_batch_size
|
|
660
|
-
});
|
|
661
|
-
};
|
|
662
|
-
const sdkLayer = opentelemetry.NodeSdk.layer(() => ({
|
|
663
|
-
resource: {
|
|
664
|
-
serviceName,
|
|
665
|
-
serviceVersion
|
|
666
|
-
},
|
|
667
|
-
spanProcessor: createSpanProcessor()
|
|
668
|
-
}));
|
|
669
|
-
logger.log("@atrim/auto-trace: NodeSdk layer created - HTTP requests will be auto-traced");
|
|
670
|
-
return effect.Layer.discard(sdkLayer);
|
|
671
|
-
})
|
|
672
|
-
);
|
|
673
|
-
};
|
|
674
|
-
var EffectTracingLive = createEffectTracingLayer();
|
|
675
614
|
var compiledRulesCache = /* @__PURE__ */ new WeakMap();
|
|
676
615
|
function compileNamingRules(rules) {
|
|
677
616
|
const cached = compiledRulesCache.get(rules);
|
|
@@ -866,7 +805,18 @@ var AutoTracingSupervisor = class extends effect.Supervisor.AbstractSupervisor {
|
|
|
866
805
|
}
|
|
867
806
|
let parentContext = OtelApi__namespace.ROOT_CONTEXT;
|
|
868
807
|
let parentFiberId;
|
|
869
|
-
|
|
808
|
+
const maybeEffectParentSpan = effect.Context.getOption(_context, effect.Tracer.ParentSpan);
|
|
809
|
+
if (effect.Option.isSome(maybeEffectParentSpan)) {
|
|
810
|
+
const effectSpan = maybeEffectParentSpan.value;
|
|
811
|
+
const otelSpanContext = {
|
|
812
|
+
traceId: effectSpan.traceId,
|
|
813
|
+
spanId: effectSpan.spanId,
|
|
814
|
+
traceFlags: effectSpan.sampled ? OtelApi__namespace.TraceFlags.SAMPLED : OtelApi__namespace.TraceFlags.NONE,
|
|
815
|
+
isRemote: false
|
|
816
|
+
};
|
|
817
|
+
const wrappedSpan = OtelApi__namespace.trace.wrapSpanContext(otelSpanContext);
|
|
818
|
+
parentContext = OtelApi__namespace.trace.setSpan(OtelApi__namespace.ROOT_CONTEXT, wrappedSpan);
|
|
819
|
+
} else if (effect.Option.isSome(parent)) {
|
|
870
820
|
parentFiberId = parent.value.id().id;
|
|
871
821
|
const parentSpan = this.fiberSpans.get(parent.value);
|
|
872
822
|
if (parentSpan) {
|
|
@@ -877,6 +827,9 @@ var AutoTracingSupervisor = class extends effect.Supervisor.AbstractSupervisor {
|
|
|
877
827
|
} else if (this._rootSpan) {
|
|
878
828
|
parentContext = OtelApi__namespace.trace.setSpan(OtelApi__namespace.ROOT_CONTEXT, this._rootSpan);
|
|
879
829
|
}
|
|
830
|
+
if (effect.Option.isSome(parent)) {
|
|
831
|
+
parentFiberId = parent.value.id().id;
|
|
832
|
+
}
|
|
880
833
|
const span = this.tracer.startSpan(
|
|
881
834
|
spanName,
|
|
882
835
|
{
|
|
@@ -1156,6 +1109,142 @@ var createFullAutoTracingLayer = () => {
|
|
|
1156
1109
|
};
|
|
1157
1110
|
var FullAutoTracingLive = createFullAutoTracingLayer();
|
|
1158
1111
|
|
|
1112
|
+
// src/integrations/effect/auto/effect-tracing.ts
|
|
1113
|
+
var createEffectTracingLayer = () => {
|
|
1114
|
+
return effect.Layer.unwrapEffect(
|
|
1115
|
+
effect.Effect.gen(function* () {
|
|
1116
|
+
const config = yield* loadFullConfig();
|
|
1117
|
+
const serviceName = process.env.OTEL_SERVICE_NAME || "effect-service";
|
|
1118
|
+
const serviceVersion = process.env.npm_package_version || "1.0.0";
|
|
1119
|
+
const exporterConfig = config.effect?.exporter_config ?? {
|
|
1120
|
+
type: "otlp",
|
|
1121
|
+
processor: "batch"
|
|
1122
|
+
};
|
|
1123
|
+
logger.log("@atrim/auto-trace: Effect-native tracing enabled");
|
|
1124
|
+
logger.log(` Service: ${serviceName}`);
|
|
1125
|
+
logger.log(` Exporter: ${exporterConfig.type}`);
|
|
1126
|
+
if (exporterConfig.type === "none") {
|
|
1127
|
+
logger.log('@atrim/auto-trace: Exporter type is "none", using empty layer');
|
|
1128
|
+
return effect.Layer.empty;
|
|
1129
|
+
}
|
|
1130
|
+
const createSpanProcessor = () => {
|
|
1131
|
+
if (exporterConfig.type === "console") {
|
|
1132
|
+
logger.log("@atrim/auto-trace: Using ConsoleSpanExporter with SimpleSpanProcessor");
|
|
1133
|
+
return new sdkTraceBase.SimpleSpanProcessor(new sdkTraceBase.ConsoleSpanExporter());
|
|
1134
|
+
}
|
|
1135
|
+
const endpoint = exporterConfig.endpoint || process.env.OTEL_EXPORTER_OTLP_ENDPOINT || "http://localhost:4318";
|
|
1136
|
+
logger.log(`@atrim/auto-trace: Using OTLPTraceExporter (${endpoint})`);
|
|
1137
|
+
const otlpConfig = {
|
|
1138
|
+
url: `${endpoint}/v1/traces`
|
|
1139
|
+
};
|
|
1140
|
+
if (exporterConfig.headers) {
|
|
1141
|
+
otlpConfig.headers = exporterConfig.headers;
|
|
1142
|
+
logger.log(`@atrim/auto-trace: Using custom headers: ${Object.keys(exporterConfig.headers).join(", ")}`);
|
|
1143
|
+
}
|
|
1144
|
+
const exporter = new exporterTraceOtlpHttp.OTLPTraceExporter(otlpConfig);
|
|
1145
|
+
if (exporterConfig.processor === "simple") {
|
|
1146
|
+
logger.log("@atrim/auto-trace: Using SimpleSpanProcessor");
|
|
1147
|
+
return new sdkTraceBase.SimpleSpanProcessor(exporter);
|
|
1148
|
+
}
|
|
1149
|
+
const batchConfig = exporterConfig.batch ?? {
|
|
1150
|
+
scheduled_delay_millis: 1e3,
|
|
1151
|
+
max_export_batch_size: 100
|
|
1152
|
+
};
|
|
1153
|
+
logger.log("@atrim/auto-trace: Using BatchSpanProcessor");
|
|
1154
|
+
return new sdkTraceBase.BatchSpanProcessor(exporter, {
|
|
1155
|
+
scheduledDelayMillis: batchConfig.scheduled_delay_millis,
|
|
1156
|
+
maxExportBatchSize: batchConfig.max_export_batch_size
|
|
1157
|
+
});
|
|
1158
|
+
};
|
|
1159
|
+
const sdkLayer = opentelemetry.NodeSdk.layer(() => ({
|
|
1160
|
+
resource: {
|
|
1161
|
+
serviceName,
|
|
1162
|
+
serviceVersion
|
|
1163
|
+
},
|
|
1164
|
+
spanProcessor: createSpanProcessor()
|
|
1165
|
+
}));
|
|
1166
|
+
logger.log("@atrim/auto-trace: NodeSdk layer created - HTTP requests will be auto-traced");
|
|
1167
|
+
return effect.Layer.discard(sdkLayer);
|
|
1168
|
+
})
|
|
1169
|
+
);
|
|
1170
|
+
};
|
|
1171
|
+
var EffectTracingLive = createEffectTracingLayer();
|
|
1172
|
+
var createCombinedTracingLayer = () => {
|
|
1173
|
+
return effect.Layer.unwrapEffect(
|
|
1174
|
+
effect.Effect.gen(function* () {
|
|
1175
|
+
const config = yield* loadFullConfig();
|
|
1176
|
+
const serviceName = process.env.OTEL_SERVICE_NAME || "effect-service";
|
|
1177
|
+
const serviceVersion = process.env.npm_package_version || "1.0.0";
|
|
1178
|
+
const exporterConfig = config.effect?.exporter_config ?? {
|
|
1179
|
+
type: "otlp",
|
|
1180
|
+
processor: "batch"
|
|
1181
|
+
};
|
|
1182
|
+
const autoConfig = config.effect?.auto_instrumentation ?? {
|
|
1183
|
+
enabled: true,
|
|
1184
|
+
granularity: "fiber",
|
|
1185
|
+
span_naming: {
|
|
1186
|
+
default: "effect.{function}",
|
|
1187
|
+
infer_from_source: true,
|
|
1188
|
+
rules: []
|
|
1189
|
+
},
|
|
1190
|
+
filter: { include: [], exclude: [] },
|
|
1191
|
+
performance: { sampling_rate: 1, min_duration: "0ms", max_concurrent: 0 },
|
|
1192
|
+
metadata: { fiber_info: true, source_location: true, parent_fiber: true }
|
|
1193
|
+
};
|
|
1194
|
+
logger.log("@atrim/auto-trace: Combined tracing enabled (HTTP + Fiber)");
|
|
1195
|
+
logger.log(` Service: ${serviceName}`);
|
|
1196
|
+
logger.log(` Exporter: ${exporterConfig.type}`);
|
|
1197
|
+
if (exporterConfig.type === "none") {
|
|
1198
|
+
logger.log('@atrim/auto-trace: Exporter type is "none", using empty layer');
|
|
1199
|
+
return effect.Layer.empty;
|
|
1200
|
+
}
|
|
1201
|
+
const createSpanProcessor = () => {
|
|
1202
|
+
if (exporterConfig.type === "console") {
|
|
1203
|
+
logger.log("@atrim/auto-trace: Using ConsoleSpanExporter with SimpleSpanProcessor");
|
|
1204
|
+
return new sdkTraceBase.SimpleSpanProcessor(new sdkTraceBase.ConsoleSpanExporter());
|
|
1205
|
+
}
|
|
1206
|
+
const endpoint = exporterConfig.endpoint || process.env.OTEL_EXPORTER_OTLP_ENDPOINT || "http://localhost:4318";
|
|
1207
|
+
logger.log(`@atrim/auto-trace: Using OTLPTraceExporter (${endpoint})`);
|
|
1208
|
+
const otlpConfig = {
|
|
1209
|
+
url: `${endpoint}/v1/traces`
|
|
1210
|
+
};
|
|
1211
|
+
if (exporterConfig.headers) {
|
|
1212
|
+
otlpConfig.headers = exporterConfig.headers;
|
|
1213
|
+
logger.log(`@atrim/auto-trace: Using custom headers: ${Object.keys(exporterConfig.headers).join(", ")}`);
|
|
1214
|
+
}
|
|
1215
|
+
const exporter = new exporterTraceOtlpHttp.OTLPTraceExporter(otlpConfig);
|
|
1216
|
+
if (exporterConfig.processor === "simple") {
|
|
1217
|
+
logger.log("@atrim/auto-trace: Using SimpleSpanProcessor");
|
|
1218
|
+
return new sdkTraceBase.SimpleSpanProcessor(exporter);
|
|
1219
|
+
}
|
|
1220
|
+
const batchConfig = exporterConfig.batch ?? {
|
|
1221
|
+
scheduled_delay_millis: 1e3,
|
|
1222
|
+
max_export_batch_size: 100
|
|
1223
|
+
};
|
|
1224
|
+
logger.log("@atrim/auto-trace: Using BatchSpanProcessor");
|
|
1225
|
+
return new sdkTraceBase.BatchSpanProcessor(exporter, {
|
|
1226
|
+
scheduledDelayMillis: batchConfig.scheduled_delay_millis,
|
|
1227
|
+
maxExportBatchSize: batchConfig.max_export_batch_size
|
|
1228
|
+
});
|
|
1229
|
+
};
|
|
1230
|
+
const sdkLayer = opentelemetry.NodeSdk.layer(() => ({
|
|
1231
|
+
resource: {
|
|
1232
|
+
serviceName,
|
|
1233
|
+
serviceVersion
|
|
1234
|
+
},
|
|
1235
|
+
spanProcessor: createSpanProcessor()
|
|
1236
|
+
}));
|
|
1237
|
+
const supervisor = createAutoTracingSupervisor(autoConfig);
|
|
1238
|
+
const supervisorLayer = effect.Supervisor.addSupervisor(supervisor);
|
|
1239
|
+
logger.log("@atrim/auto-trace: Combined layer created");
|
|
1240
|
+
logger.log(" - HTTP requests: auto-traced via Effect platform");
|
|
1241
|
+
logger.log(" - Forked fibers: auto-traced via Supervisor");
|
|
1242
|
+
return supervisorLayer.pipe(effect.Layer.provideMerge(effect.Layer.discard(sdkLayer)));
|
|
1243
|
+
})
|
|
1244
|
+
);
|
|
1245
|
+
};
|
|
1246
|
+
var CombinedTracingLive = createCombinedTracingLayer();
|
|
1247
|
+
|
|
1159
1248
|
exports.AutoTracingConfig = AutoTracingConfig;
|
|
1160
1249
|
exports.AutoTracingConfigLayer = AutoTracingConfigLayer;
|
|
1161
1250
|
exports.AutoTracingConfigLive = AutoTracingConfigLive;
|
|
@@ -1163,10 +1252,12 @@ exports.AutoTracingEnabled = AutoTracingEnabled;
|
|
|
1163
1252
|
exports.AutoTracingLive = AutoTracingLive;
|
|
1164
1253
|
exports.AutoTracingSpanName = AutoTracingSpanName;
|
|
1165
1254
|
exports.AutoTracingSupervisor = AutoTracingSupervisor;
|
|
1255
|
+
exports.CombinedTracingLive = CombinedTracingLive;
|
|
1166
1256
|
exports.EffectTracingLive = EffectTracingLive;
|
|
1167
1257
|
exports.FullAutoTracingLive = FullAutoTracingLive;
|
|
1168
1258
|
exports.createAutoTracingLayer = createAutoTracingLayer;
|
|
1169
1259
|
exports.createAutoTracingSupervisor = createAutoTracingSupervisor;
|
|
1260
|
+
exports.createCombinedTracingLayer = createCombinedTracingLayer;
|
|
1170
1261
|
exports.createEffectTracingLayer = createEffectTracingLayer;
|
|
1171
1262
|
exports.createFullAutoTracingLayer = createFullAutoTracingLayer;
|
|
1172
1263
|
exports.defaultAutoTracingConfig = defaultAutoTracingConfig;
|