@atrim/instrument-node 0.5.0-c05e3a1-20251119131235 → 0.5.1-1451fcf-20260105212505
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/README.md +97 -269
- package/package.json +18 -17
- package/target/dist/index.cjs +209 -117
- package/target/dist/index.cjs.map +1 -1
- package/target/dist/index.d.cts +168 -120
- package/target/dist/index.d.ts +168 -120
- package/target/dist/index.js +202 -116
- package/target/dist/index.js.map +1 -1
- package/target/dist/integrations/effect/index.cjs +287 -129
- package/target/dist/integrations/effect/index.cjs.map +1 -1
- package/target/dist/integrations/effect/index.d.cts +205 -36
- package/target/dist/integrations/effect/index.d.ts +205 -36
- package/target/dist/integrations/effect/index.js +284 -131
- package/target/dist/integrations/effect/index.js.map +1 -1
package/target/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Data, Context, Effect, Layer
|
|
1
|
+
import { Data, Context, Effect, Layer } from 'effect';
|
|
2
2
|
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
3
3
|
import { SimpleSpanProcessor, BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
4
4
|
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
@@ -11,8 +11,7 @@ import { z } from 'zod';
|
|
|
11
11
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
12
12
|
import { readFile } from 'fs/promises';
|
|
13
13
|
import { join } from 'path';
|
|
14
|
-
import {
|
|
15
|
-
import { FetchHttpClient } from '@effect/platform';
|
|
14
|
+
import { createRequire } from 'module';
|
|
16
15
|
|
|
17
16
|
var __defProp = Object.defineProperty;
|
|
18
17
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -84,11 +83,50 @@ var InstrumentationConfigSchema = z.object({
|
|
|
84
83
|
ignore_patterns: z.array(PatternConfigSchema)
|
|
85
84
|
}),
|
|
86
85
|
effect: z.object({
|
|
86
|
+
// Enable/disable Effect tracing entirely
|
|
87
|
+
// When false, EffectInstrumentationLive returns Layer.empty
|
|
88
|
+
enabled: z.boolean().default(true),
|
|
89
|
+
// Exporter mode:
|
|
90
|
+
// - "unified": Use global TracerProvider from Node SDK (recommended, enables filtering)
|
|
91
|
+
// - "standalone": Use Effect's own OTLP exporter (bypasses Node SDK filtering)
|
|
92
|
+
exporter: z.enum(["unified", "standalone"]).default("unified"),
|
|
87
93
|
auto_extract_metadata: z.boolean(),
|
|
88
94
|
auto_isolation: AutoIsolationConfigSchema.optional()
|
|
89
95
|
}).optional(),
|
|
90
96
|
http: HttpFilteringConfigSchema.optional()
|
|
91
97
|
});
|
|
98
|
+
var defaultConfig = {
|
|
99
|
+
version: "1.0",
|
|
100
|
+
instrumentation: {
|
|
101
|
+
enabled: true,
|
|
102
|
+
logging: "on",
|
|
103
|
+
description: "Default instrumentation configuration",
|
|
104
|
+
instrument_patterns: [
|
|
105
|
+
{ pattern: "^app\\.", enabled: true, description: "Application operations" },
|
|
106
|
+
{ pattern: "^http\\.server\\.", enabled: true, description: "HTTP server operations" },
|
|
107
|
+
{ pattern: "^http\\.client\\.", enabled: true, description: "HTTP client operations" }
|
|
108
|
+
],
|
|
109
|
+
ignore_patterns: [
|
|
110
|
+
{ pattern: "^test\\.", description: "Test utilities" },
|
|
111
|
+
{ pattern: "^internal\\.", description: "Internal operations" },
|
|
112
|
+
{ pattern: "^health\\.", description: "Health checks" }
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
effect: {
|
|
116
|
+
enabled: true,
|
|
117
|
+
exporter: "unified",
|
|
118
|
+
auto_extract_metadata: true
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
function parseAndValidateConfig(content) {
|
|
122
|
+
let parsed;
|
|
123
|
+
if (typeof content === "string") {
|
|
124
|
+
parsed = parse(content);
|
|
125
|
+
} else {
|
|
126
|
+
parsed = content;
|
|
127
|
+
}
|
|
128
|
+
return InstrumentationConfigSchema.parse(parsed);
|
|
129
|
+
}
|
|
92
130
|
(class extends Data.TaggedError("ConfigError") {
|
|
93
131
|
get message() {
|
|
94
132
|
return this.reason;
|
|
@@ -266,7 +304,7 @@ var makeConfigLoader = Effect.gen(function* () {
|
|
|
266
304
|
})
|
|
267
305
|
});
|
|
268
306
|
});
|
|
269
|
-
|
|
307
|
+
Layer.effect(ConfigLoader, makeConfigLoader);
|
|
270
308
|
var PatternMatcher = class {
|
|
271
309
|
constructor(config) {
|
|
272
310
|
__publicField2(this, "ignorePatterns", []);
|
|
@@ -430,8 +468,14 @@ var PatternSpanProcessor = class {
|
|
|
430
468
|
constructor(config, wrappedProcessor) {
|
|
431
469
|
__publicField(this, "matcher");
|
|
432
470
|
__publicField(this, "wrappedProcessor");
|
|
471
|
+
__publicField(this, "httpIgnorePatterns", []);
|
|
433
472
|
this.matcher = new PatternMatcher(config);
|
|
434
473
|
this.wrappedProcessor = wrappedProcessor;
|
|
474
|
+
if (config.http?.ignore_incoming_paths) {
|
|
475
|
+
this.httpIgnorePatterns = config.http.ignore_incoming_paths.map(
|
|
476
|
+
(pattern) => new RegExp(pattern)
|
|
477
|
+
);
|
|
478
|
+
}
|
|
435
479
|
}
|
|
436
480
|
/**
|
|
437
481
|
* Called when a span is started
|
|
@@ -449,12 +493,40 @@ var PatternSpanProcessor = class {
|
|
|
449
493
|
* Called when a span is ended
|
|
450
494
|
*
|
|
451
495
|
* This is where we make the final decision on whether to export the span.
|
|
496
|
+
* We check both span name patterns and HTTP path patterns.
|
|
452
497
|
*/
|
|
453
498
|
onEnd(span) {
|
|
454
499
|
const spanName = span.name;
|
|
455
|
-
if (this.matcher.shouldInstrument(spanName)) {
|
|
456
|
-
|
|
500
|
+
if (!this.matcher.shouldInstrument(spanName)) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if (this.shouldIgnoreHttpSpan(span)) {
|
|
504
|
+
return;
|
|
457
505
|
}
|
|
506
|
+
this.wrappedProcessor.onEnd(span);
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Check if span should be ignored based on HTTP path attributes
|
|
510
|
+
*
|
|
511
|
+
* This checks the span's url.path, http.route, or http.target attributes
|
|
512
|
+
* against the configured http.ignore_incoming_paths patterns.
|
|
513
|
+
*
|
|
514
|
+
* This enables filtering of Effect HTTP spans (and any other HTTP spans)
|
|
515
|
+
* based on path patterns, which is essential for filtering out OTLP
|
|
516
|
+
* endpoint requests like /v1/traces, /v1/logs, /v1/metrics.
|
|
517
|
+
*/
|
|
518
|
+
shouldIgnoreHttpSpan(span) {
|
|
519
|
+
if (this.httpIgnorePatterns.length === 0) {
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
const urlPath = span.attributes["url.path"];
|
|
523
|
+
const httpRoute = span.attributes["http.route"];
|
|
524
|
+
const httpTarget = span.attributes["http.target"];
|
|
525
|
+
const pathToCheck = urlPath || httpRoute || httpTarget;
|
|
526
|
+
if (!pathToCheck) {
|
|
527
|
+
return false;
|
|
528
|
+
}
|
|
529
|
+
return this.httpIgnorePatterns.some((pattern) => pattern.test(pathToCheck));
|
|
458
530
|
}
|
|
459
531
|
/**
|
|
460
532
|
* Shutdown the processor
|
|
@@ -683,88 +755,69 @@ var getServiceInfoWithFallback = detectServiceInfo.pipe(
|
|
|
683
755
|
})
|
|
684
756
|
)
|
|
685
757
|
);
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
);
|
|
689
|
-
var cachedLoaderPromise = null;
|
|
690
|
-
function getCachedLoader() {
|
|
691
|
-
if (!cachedLoaderPromise) {
|
|
692
|
-
cachedLoaderPromise = Effect.runPromise(
|
|
693
|
-
Effect.gen(function* () {
|
|
694
|
-
return yield* ConfigLoader;
|
|
695
|
-
}).pipe(Effect.provide(NodeConfigLoaderLive))
|
|
696
|
-
);
|
|
697
|
-
}
|
|
698
|
-
return cachedLoaderPromise;
|
|
758
|
+
async function detectServiceInfoAsync() {
|
|
759
|
+
return Effect.runPromise(getServiceInfoWithFallback);
|
|
699
760
|
}
|
|
700
|
-
function
|
|
701
|
-
|
|
761
|
+
async function getServiceNameAsync() {
|
|
762
|
+
return Effect.runPromise(getServiceName);
|
|
702
763
|
}
|
|
703
|
-
async function
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
764
|
+
async function getServiceVersionAsync() {
|
|
765
|
+
return Effect.runPromise(getServiceVersion);
|
|
766
|
+
}
|
|
767
|
+
async function loadFromFile(filePath) {
|
|
768
|
+
const { readFile: readFile2 } = await import('fs/promises');
|
|
769
|
+
const content = await readFile2(filePath, "utf-8");
|
|
770
|
+
return parseAndValidateConfig(content);
|
|
771
|
+
}
|
|
772
|
+
async function loadFromUrl(url) {
|
|
773
|
+
const response = await fetch(url);
|
|
774
|
+
if (!response.ok) {
|
|
775
|
+
throw new Error(`Failed to fetch config from ${url}: ${response.statusText}`);
|
|
710
776
|
}
|
|
711
|
-
const
|
|
712
|
-
return
|
|
777
|
+
const content = await response.text();
|
|
778
|
+
return parseAndValidateConfig(content);
|
|
779
|
+
}
|
|
780
|
+
async function loadConfig(uri, _options) {
|
|
781
|
+
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
782
|
+
return loadFromUrl(uri);
|
|
783
|
+
}
|
|
784
|
+
if (uri.startsWith("file://")) {
|
|
785
|
+
const filePath = uri.slice(7);
|
|
786
|
+
return loadFromFile(filePath);
|
|
787
|
+
}
|
|
788
|
+
return loadFromFile(uri);
|
|
713
789
|
}
|
|
714
790
|
async function loadConfigFromInline(content) {
|
|
715
|
-
|
|
716
|
-
return Effect.runPromise(loader.loadFromInline(content));
|
|
791
|
+
return parseAndValidateConfig(content);
|
|
717
792
|
}
|
|
718
|
-
function
|
|
719
|
-
return {
|
|
720
|
-
version: "1.0",
|
|
721
|
-
instrumentation: {
|
|
722
|
-
enabled: true,
|
|
723
|
-
logging: "on",
|
|
724
|
-
description: "Default instrumentation configuration",
|
|
725
|
-
instrument_patterns: [
|
|
726
|
-
{ pattern: "^app\\.", enabled: true, description: "Application operations" },
|
|
727
|
-
{ pattern: "^http\\.server\\.", enabled: true, description: "HTTP server operations" },
|
|
728
|
-
{ pattern: "^http\\.client\\.", enabled: true, description: "HTTP client operations" }
|
|
729
|
-
],
|
|
730
|
-
ignore_patterns: [
|
|
731
|
-
{ pattern: "^test\\.", description: "Test utilities" },
|
|
732
|
-
{ pattern: "^internal\\.", description: "Internal operations" },
|
|
733
|
-
{ pattern: "^health\\.", description: "Health checks" }
|
|
734
|
-
]
|
|
735
|
-
},
|
|
736
|
-
effect: {
|
|
737
|
-
auto_extract_metadata: true
|
|
738
|
-
}
|
|
739
|
-
};
|
|
793
|
+
function _resetConfigLoaderCache() {
|
|
740
794
|
}
|
|
741
795
|
async function loadConfigWithOptions(options = {}) {
|
|
742
|
-
const loadOptions = options.cacheTimeout !== void 0 ? { cacheTimeout: options.cacheTimeout } : void 0;
|
|
743
796
|
if (options.config) {
|
|
744
797
|
return loadConfigFromInline(options.config);
|
|
745
798
|
}
|
|
746
799
|
const envConfigPath = process.env.ATRIM_INSTRUMENTATION_CONFIG;
|
|
747
800
|
if (envConfigPath) {
|
|
748
|
-
return loadConfig(envConfigPath
|
|
801
|
+
return loadConfig(envConfigPath);
|
|
749
802
|
}
|
|
750
803
|
if (options.configUrl) {
|
|
751
|
-
return loadConfig(options.configUrl
|
|
804
|
+
return loadConfig(options.configUrl);
|
|
752
805
|
}
|
|
753
806
|
if (options.configPath) {
|
|
754
|
-
return loadConfig(options.configPath
|
|
807
|
+
return loadConfig(options.configPath);
|
|
755
808
|
}
|
|
756
809
|
const { existsSync } = await import('fs');
|
|
757
810
|
const { join: join2 } = await import('path');
|
|
758
811
|
const defaultPath = join2(process.cwd(), "instrumentation.yaml");
|
|
759
812
|
if (existsSync(defaultPath)) {
|
|
760
|
-
return loadConfig(defaultPath
|
|
813
|
+
return loadConfig(defaultPath);
|
|
761
814
|
}
|
|
762
|
-
return
|
|
815
|
+
return defaultConfig;
|
|
763
816
|
}
|
|
764
817
|
|
|
765
818
|
// src/core/sdk-initializer.ts
|
|
766
819
|
var sdkInstance = null;
|
|
767
|
-
var
|
|
820
|
+
var initializationPromise = null;
|
|
768
821
|
function buildHttpInstrumentationConfig(options, config, _otlpEndpoint) {
|
|
769
822
|
const httpConfig = { enabled: true };
|
|
770
823
|
const programmaticPatterns = options.http?.ignoreOutgoingUrls || [];
|
|
@@ -880,38 +933,27 @@ function isTracingAlreadyInitialized() {
|
|
|
880
933
|
return false;
|
|
881
934
|
}
|
|
882
935
|
}
|
|
883
|
-
|
|
936
|
+
async function initializeSdk(options = {}) {
|
|
884
937
|
if (sdkInstance) {
|
|
885
938
|
logger.warn("@atrim/instrumentation: SDK already initialized. Returning existing instance.");
|
|
886
939
|
return sdkInstance;
|
|
887
940
|
}
|
|
888
|
-
if (
|
|
941
|
+
if (initializationPromise) {
|
|
889
942
|
logger.log(
|
|
890
|
-
"@atrim/instrumentation: SDK
|
|
943
|
+
"@atrim/instrumentation: SDK already initialized, waiting for initialization to complete..."
|
|
891
944
|
);
|
|
892
|
-
return
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
);
|
|
905
|
-
return result;
|
|
906
|
-
});
|
|
907
|
-
var performInitializationEffect = (options) => Effect.gen(function* () {
|
|
908
|
-
const config = yield* Effect.tryPromise({
|
|
909
|
-
try: () => loadConfigWithOptions(options),
|
|
910
|
-
catch: (error) => new InitializationError2({
|
|
911
|
-
reason: "Failed to load configuration",
|
|
912
|
-
cause: error
|
|
913
|
-
})
|
|
914
|
-
});
|
|
945
|
+
return initializationPromise;
|
|
946
|
+
}
|
|
947
|
+
initializationPromise = performInitialization(options);
|
|
948
|
+
try {
|
|
949
|
+
const result = await initializationPromise;
|
|
950
|
+
return result;
|
|
951
|
+
} finally {
|
|
952
|
+
initializationPromise = null;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
async function performInitialization(options) {
|
|
956
|
+
const config = await loadConfigWithOptions(options);
|
|
915
957
|
const loggingLevel = config.instrumentation.logging || "on";
|
|
916
958
|
logger.setLevel(loggingLevel);
|
|
917
959
|
const alreadyInitialized = isTracingAlreadyInitialized();
|
|
@@ -927,25 +969,14 @@ var performInitializationEffect = (options) => Effect.gen(function* () {
|
|
|
927
969
|
logger.log("");
|
|
928
970
|
return null;
|
|
929
971
|
}
|
|
930
|
-
const serviceInfo =
|
|
931
|
-
Effect.catchAll(
|
|
932
|
-
() => Effect.succeed({
|
|
933
|
-
name: "unknown-service",
|
|
934
|
-
version: void 0
|
|
935
|
-
})
|
|
936
|
-
)
|
|
937
|
-
);
|
|
972
|
+
const serviceInfo = await detectServiceInfoAsync();
|
|
938
973
|
const serviceName = options.serviceName || serviceInfo.name;
|
|
939
974
|
const serviceVersion = options.serviceVersion || serviceInfo.version;
|
|
940
|
-
const rawExporter =
|
|
941
|
-
const exporter =
|
|
975
|
+
const rawExporter = createOtlpExporter(options.otlp);
|
|
976
|
+
const exporter = new SafeSpanExporter(rawExporter);
|
|
942
977
|
const useSimpleProcessor = process.env.NODE_ENV === "test" || process.env.OTEL_USE_SIMPLE_PROCESSOR === "true";
|
|
943
|
-
const baseProcessor =
|
|
944
|
-
|
|
945
|
-
);
|
|
946
|
-
const patternProcessor = yield* Effect.sync(
|
|
947
|
-
() => new PatternSpanProcessor(config, baseProcessor)
|
|
948
|
-
);
|
|
978
|
+
const baseProcessor = useSimpleProcessor ? new SimpleSpanProcessor(exporter) : new BatchSpanProcessor(exporter);
|
|
979
|
+
const patternProcessor = new PatternSpanProcessor(config, baseProcessor);
|
|
949
980
|
const instrumentations = [];
|
|
950
981
|
const hasWebFramework = hasWebFrameworkInstalled();
|
|
951
982
|
const enableAutoInstrumentation = shouldEnableAutoInstrumentation(
|
|
@@ -958,11 +989,15 @@ var performInitializationEffect = (options) => Effect.gen(function* () {
|
|
|
958
989
|
const undiciConfig = buildUndiciInstrumentationConfig(options, config);
|
|
959
990
|
instrumentations.push(
|
|
960
991
|
...getNodeAutoInstrumentations({
|
|
992
|
+
// Enable HTTP instrumentation with filtering (for http/https modules)
|
|
961
993
|
"@opentelemetry/instrumentation-http": httpConfig,
|
|
994
|
+
// Enable undici instrumentation with filtering (for fetch API)
|
|
962
995
|
"@opentelemetry/instrumentation-undici": undiciConfig,
|
|
996
|
+
// Enable web framework instrumentations
|
|
963
997
|
"@opentelemetry/instrumentation-express": { enabled: true },
|
|
964
998
|
"@opentelemetry/instrumentation-fastify": { enabled: true },
|
|
965
999
|
"@opentelemetry/instrumentation-koa": { enabled: true },
|
|
1000
|
+
// Disable noisy instrumentations by default
|
|
966
1001
|
"@opentelemetry/instrumentation-fs": { enabled: false },
|
|
967
1002
|
"@opentelemetry/instrumentation-dns": { enabled: false }
|
|
968
1003
|
})
|
|
@@ -990,20 +1025,18 @@ var performInitializationEffect = (options) => Effect.gen(function* () {
|
|
|
990
1025
|
serviceName,
|
|
991
1026
|
...serviceVersion && { serviceVersion },
|
|
992
1027
|
instrumentations,
|
|
1028
|
+
// Allow advanced overrides
|
|
993
1029
|
...options.sdk
|
|
994
1030
|
};
|
|
995
|
-
const sdk =
|
|
996
|
-
|
|
997
|
-
s.start();
|
|
998
|
-
return s;
|
|
999
|
-
});
|
|
1031
|
+
const sdk = new NodeSDK(sdkConfig);
|
|
1032
|
+
sdk.start();
|
|
1000
1033
|
sdkInstance = sdk;
|
|
1001
1034
|
if (!options.disableAutoShutdown) {
|
|
1002
|
-
|
|
1035
|
+
registerShutdownHandlers(sdk);
|
|
1003
1036
|
}
|
|
1004
1037
|
logInitialization(config, serviceName, serviceVersion, options, enableAutoInstrumentation);
|
|
1005
1038
|
return sdk;
|
|
1006
|
-
}
|
|
1039
|
+
}
|
|
1007
1040
|
function getSdkInstance() {
|
|
1008
1041
|
return sdkInstance;
|
|
1009
1042
|
}
|
|
@@ -1016,7 +1049,7 @@ async function shutdownSdk() {
|
|
|
1016
1049
|
}
|
|
1017
1050
|
function resetSdk() {
|
|
1018
1051
|
sdkInstance = null;
|
|
1019
|
-
|
|
1052
|
+
initializationPromise = null;
|
|
1020
1053
|
}
|
|
1021
1054
|
function registerShutdownHandlers(sdk) {
|
|
1022
1055
|
const shutdown = async (signal) => {
|
|
@@ -1071,10 +1104,63 @@ function logInitialization(config, serviceName, serviceVersion, options, autoIns
|
|
|
1071
1104
|
logger.log(` - OTLP endpoint: ${endpoint}`);
|
|
1072
1105
|
logger.log("");
|
|
1073
1106
|
}
|
|
1107
|
+
var require2 = createRequire(import.meta.url);
|
|
1108
|
+
function validateOpenTelemetryApi() {
|
|
1109
|
+
try {
|
|
1110
|
+
require2.resolve("@opentelemetry/api");
|
|
1111
|
+
} catch {
|
|
1112
|
+
throw new Error(
|
|
1113
|
+
"@atrim/instrument-node requires @opentelemetry/api as a peer dependency.\n\nInstall it with:\n npm install @opentelemetry/api\n\nOr with your preferred package manager:\n pnpm add @opentelemetry/api\n yarn add @opentelemetry/api\n bun add @opentelemetry/api"
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
function validateEffectDependencies() {
|
|
1118
|
+
const packages = ["effect", "@effect/opentelemetry", "@effect/platform"];
|
|
1119
|
+
for (const pkg of packages) {
|
|
1120
|
+
try {
|
|
1121
|
+
require2.resolve(pkg);
|
|
1122
|
+
} catch {
|
|
1123
|
+
return false;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
return true;
|
|
1127
|
+
}
|
|
1128
|
+
var validateDependencies = Effect.try({
|
|
1129
|
+
try: () => validateOpenTelemetryApi(),
|
|
1130
|
+
catch: (error) => new InitializationError2({
|
|
1131
|
+
reason: error instanceof Error ? error.message : "Dependency validation failed",
|
|
1132
|
+
cause: error
|
|
1133
|
+
})
|
|
1134
|
+
});
|
|
1135
|
+
Effect.sync(() => validateEffectDependencies());
|
|
1074
1136
|
|
|
1075
1137
|
// src/api.ts
|
|
1076
|
-
|
|
1077
|
-
|
|
1138
|
+
async function initializeInstrumentation(options = {}) {
|
|
1139
|
+
validateOpenTelemetryApi();
|
|
1140
|
+
const sdk = await initializeSdk(options);
|
|
1141
|
+
if (sdk) {
|
|
1142
|
+
const config = await loadConfigWithOptions(options);
|
|
1143
|
+
initializePatternMatcher(config);
|
|
1144
|
+
}
|
|
1145
|
+
return sdk;
|
|
1146
|
+
}
|
|
1147
|
+
async function initializePatternMatchingOnly(options = {}) {
|
|
1148
|
+
const config = await loadConfigWithOptions(options);
|
|
1149
|
+
initializePatternMatcher(config);
|
|
1150
|
+
logger.log("@atrim/instrumentation: Pattern matching initialized (legacy mode)");
|
|
1151
|
+
logger.log(
|
|
1152
|
+
" Note: NodeSDK is not initialized. Use initializeInstrumentation() for complete setup."
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
var initializeInstrumentationEffect = (options = {}) => Effect.gen(function* () {
|
|
1156
|
+
yield* validateDependencies;
|
|
1157
|
+
const sdk = yield* Effect.tryPromise({
|
|
1158
|
+
try: () => initializeSdk(options),
|
|
1159
|
+
catch: (error) => new InitializationError2({
|
|
1160
|
+
reason: "SDK initialization failed",
|
|
1161
|
+
cause: error
|
|
1162
|
+
})
|
|
1163
|
+
});
|
|
1078
1164
|
if (sdk) {
|
|
1079
1165
|
yield* Effect.tryPromise({
|
|
1080
1166
|
try: () => loadConfigWithOptions(options),
|
|
@@ -1092,7 +1178,7 @@ var initializeInstrumentation = (options = {}) => Effect.gen(function* () {
|
|
|
1092
1178
|
}
|
|
1093
1179
|
return sdk;
|
|
1094
1180
|
});
|
|
1095
|
-
var
|
|
1181
|
+
var initializePatternMatchingOnlyEffect = (options = {}) => Effect.gen(function* () {
|
|
1096
1182
|
const config = yield* Effect.tryPromise({
|
|
1097
1183
|
try: () => loadConfigWithOptions(options),
|
|
1098
1184
|
catch: (error) => new ConfigError2({
|
|
@@ -1102,7 +1188,7 @@ var initializePatternMatchingOnly = (options = {}) => Effect.gen(function* () {
|
|
|
1102
1188
|
});
|
|
1103
1189
|
yield* Effect.sync(() => {
|
|
1104
1190
|
initializePatternMatcher(config);
|
|
1105
|
-
logger.log("@atrim/instrumentation: Pattern matching initialized (
|
|
1191
|
+
logger.log("@atrim/instrumentation: Pattern matching initialized (legacy mode)");
|
|
1106
1192
|
logger.log(
|
|
1107
1193
|
" Note: NodeSDK is not initialized. Use initializeInstrumentation() for complete setup."
|
|
1108
1194
|
);
|
|
@@ -1203,6 +1289,6 @@ function suppressShutdownErrors() {
|
|
|
1203
1289
|
});
|
|
1204
1290
|
}
|
|
1205
1291
|
|
|
1206
|
-
export { ConfigError2 as ConfigError, ConfigFileError2 as ConfigFileError, ConfigUrlError2 as ConfigUrlError, ConfigValidationError2 as ConfigValidationError, ExportError2 as ExportError, InitializationError2 as InitializationError, PatternMatcher, PatternSpanProcessor, ServiceDetectionError2 as ServiceDetectionError, ShutdownError2 as ShutdownError, annotateCacheOperation, annotateDbQuery, annotateHttpRequest, _resetConfigLoaderCache as clearConfigCache, createOtlpExporter, detectServiceInfo, getOtlpEndpoint, getPatternMatcher, getSdkInstance, getServiceInfoWithFallback, getServiceName, getServiceVersion, initializeInstrumentation, initializePatternMatchingOnly, loadConfig, loadConfigFromInline, loadConfigWithOptions, markSpanError, markSpanSuccess, recordException, resetSdk, setSpanAttributes, shouldInstrumentSpan, shutdownSdk, suppressShutdownErrors };
|
|
1292
|
+
export { ConfigError2 as ConfigError, ConfigFileError2 as ConfigFileError, ConfigUrlError2 as ConfigUrlError, ConfigValidationError2 as ConfigValidationError, ExportError2 as ExportError, InitializationError2 as InitializationError, PatternMatcher, PatternSpanProcessor, ServiceDetectionError2 as ServiceDetectionError, ShutdownError2 as ShutdownError, annotateCacheOperation, annotateDbQuery, annotateHttpRequest, _resetConfigLoaderCache as clearConfigCache, createOtlpExporter, detectServiceInfoAsync as detectServiceInfo, detectServiceInfo as detectServiceInfoEffect, getOtlpEndpoint, getPatternMatcher, getSdkInstance, getServiceInfoWithFallback, getServiceNameAsync as getServiceName, getServiceName as getServiceNameEffect, getServiceVersionAsync as getServiceVersion, getServiceVersion as getServiceVersionEffect, initializeInstrumentation, initializeInstrumentationEffect, initializePatternMatchingOnly, initializePatternMatchingOnlyEffect, loadConfig, loadConfigFromInline, loadConfigWithOptions, markSpanError, markSpanSuccess, recordException, resetSdk, setSpanAttributes, shouldInstrumentSpan, shutdownSdk, suppressShutdownErrors };
|
|
1207
1293
|
//# sourceMappingURL=index.js.map
|
|
1208
1294
|
//# sourceMappingURL=index.js.map
|