@atrim/instrument-node 0.5.2-dev.ac2fbfe.20251221205322 → 0.6.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.
@@ -1,4 +1,5 @@
1
1
  import { Layer, Effect, FiberSet as FiberSet$1 } from 'effect';
2
+ import * as Tracer from '@effect/opentelemetry/Tracer';
2
3
  import { InstrumentationConfig } from '@atrim/instrument-core';
3
4
  import * as effect_Runtime from 'effect/Runtime';
4
5
  import * as effect_FiberId from 'effect/FiberId';
@@ -6,9 +7,10 @@ import * as effect_Scope from 'effect/Scope';
6
7
  import { RuntimeFiber } from 'effect/Fiber';
7
8
 
8
9
  /**
9
- * Node.js configuration loader using Effect Platform
10
+ * Node.js configuration loader
10
11
  *
11
- * Provides FileSystem and HttpClient layers for the core ConfigLoader service
12
+ * Provides configuration loading using native Node.js APIs (fs, fetch)
13
+ * This module doesn't require Effect Platform, making it work without Effect installed.
12
14
  */
13
15
 
14
16
  /**
@@ -46,17 +48,12 @@ interface ConfigLoaderOptions {
46
48
  */
47
49
  interface EffectInstrumentationOptions extends ConfigLoaderOptions {
48
50
  /**
49
- * OTLP endpoint URL
50
- * @default process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318'
51
- */
52
- otlpEndpoint?: string;
53
- /**
54
- * Service name
51
+ * Service name for Effect spans
55
52
  * @default process.env.OTEL_SERVICE_NAME || 'effect-service'
56
53
  */
57
54
  serviceName?: string;
58
55
  /**
59
- * Service version
56
+ * Service version for Effect spans
60
57
  * @default process.env.npm_package_version || '1.0.0'
61
58
  */
62
59
  serviceVersion?: string;
@@ -66,20 +63,17 @@ interface EffectInstrumentationOptions extends ConfigLoaderOptions {
66
63
  */
67
64
  autoExtractMetadata?: boolean;
68
65
  /**
69
- * Whether to continue existing traces from NodeSDK auto-instrumentation
70
- *
71
- * When true (default):
72
- * - Effect spans become children of existing NodeSDK spans
73
- * - Example: HTTP request span → Effect business logic span
74
- * - Uses OpenTelemetry Context API for propagation
75
- *
76
- * When false:
77
- * - Effect operations always create new root spans
78
- * - Not recommended unless you have specific requirements
79
- *
80
- * @default true
66
+ * OTLP endpoint URL (only used when exporter mode is 'standalone')
67
+ * @default process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318'
68
+ */
69
+ otlpEndpoint?: string;
70
+ /**
71
+ * Exporter mode:
72
+ * - 'unified': Use global TracerProvider from Node SDK (recommended, enables filtering)
73
+ * - 'standalone': Use Effect's own OTLP exporter (bypasses Node SDK filtering)
74
+ * @default 'unified'
81
75
  */
82
- continueExistingTraces?: boolean;
76
+ exporterMode?: 'unified' | 'standalone';
83
77
  }
84
78
  /**
85
79
  * Create Effect instrumentation layer with custom options
@@ -118,11 +112,12 @@ declare function createEffectInstrumentation(options?: EffectInstrumentationOpti
118
112
  *
119
113
  * Uses the global OpenTelemetry tracer provider that was set up by
120
114
  * initializeInstrumentation(). This ensures all traces (Express, Effect, etc.)
121
- * go to the same OTLP endpoint.
115
+ * go through the same TracerProvider and PatternSpanProcessor.
122
116
  *
123
117
  * Context Propagation:
124
118
  * - Automatically continues traces from NodeSDK auto-instrumentation
125
119
  * - Effect spans become children of HTTP request spans
120
+ * - Respects http.ignore_incoming_paths and other filtering patterns
126
121
  * - No configuration needed
127
122
  *
128
123
  * @example
@@ -138,7 +133,7 @@ declare function createEffectInstrumentation(options?: EffectInstrumentationOpti
138
133
  * )
139
134
  * ```
140
135
  */
141
- declare const EffectInstrumentationLive: Layer.Layer<never, never, never>;
136
+ declare const EffectInstrumentationLive: Layer.Layer<Tracer.OtelTracer, never, never>;
142
137
 
143
138
  /**
144
139
  * Effect-specific span annotation helpers
@@ -1,4 +1,5 @@
1
1
  import { Layer, Effect, FiberSet as FiberSet$1 } from 'effect';
2
+ import * as Tracer from '@effect/opentelemetry/Tracer';
2
3
  import { InstrumentationConfig } from '@atrim/instrument-core';
3
4
  import * as effect_Runtime from 'effect/Runtime';
4
5
  import * as effect_FiberId from 'effect/FiberId';
@@ -6,9 +7,10 @@ import * as effect_Scope from 'effect/Scope';
6
7
  import { RuntimeFiber } from 'effect/Fiber';
7
8
 
8
9
  /**
9
- * Node.js configuration loader using Effect Platform
10
+ * Node.js configuration loader
10
11
  *
11
- * Provides FileSystem and HttpClient layers for the core ConfigLoader service
12
+ * Provides configuration loading using native Node.js APIs (fs, fetch)
13
+ * This module doesn't require Effect Platform, making it work without Effect installed.
12
14
  */
13
15
 
14
16
  /**
@@ -46,17 +48,12 @@ interface ConfigLoaderOptions {
46
48
  */
47
49
  interface EffectInstrumentationOptions extends ConfigLoaderOptions {
48
50
  /**
49
- * OTLP endpoint URL
50
- * @default process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318'
51
- */
52
- otlpEndpoint?: string;
53
- /**
54
- * Service name
51
+ * Service name for Effect spans
55
52
  * @default process.env.OTEL_SERVICE_NAME || 'effect-service'
56
53
  */
57
54
  serviceName?: string;
58
55
  /**
59
- * Service version
56
+ * Service version for Effect spans
60
57
  * @default process.env.npm_package_version || '1.0.0'
61
58
  */
62
59
  serviceVersion?: string;
@@ -66,20 +63,17 @@ interface EffectInstrumentationOptions extends ConfigLoaderOptions {
66
63
  */
67
64
  autoExtractMetadata?: boolean;
68
65
  /**
69
- * Whether to continue existing traces from NodeSDK auto-instrumentation
70
- *
71
- * When true (default):
72
- * - Effect spans become children of existing NodeSDK spans
73
- * - Example: HTTP request span → Effect business logic span
74
- * - Uses OpenTelemetry Context API for propagation
75
- *
76
- * When false:
77
- * - Effect operations always create new root spans
78
- * - Not recommended unless you have specific requirements
79
- *
80
- * @default true
66
+ * OTLP endpoint URL (only used when exporter mode is 'standalone')
67
+ * @default process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318'
68
+ */
69
+ otlpEndpoint?: string;
70
+ /**
71
+ * Exporter mode:
72
+ * - 'unified': Use global TracerProvider from Node SDK (recommended, enables filtering)
73
+ * - 'standalone': Use Effect's own OTLP exporter (bypasses Node SDK filtering)
74
+ * @default 'unified'
81
75
  */
82
- continueExistingTraces?: boolean;
76
+ exporterMode?: 'unified' | 'standalone';
83
77
  }
84
78
  /**
85
79
  * Create Effect instrumentation layer with custom options
@@ -118,11 +112,12 @@ declare function createEffectInstrumentation(options?: EffectInstrumentationOpti
118
112
  *
119
113
  * Uses the global OpenTelemetry tracer provider that was set up by
120
114
  * initializeInstrumentation(). This ensures all traces (Express, Effect, etc.)
121
- * go to the same OTLP endpoint.
115
+ * go through the same TracerProvider and PatternSpanProcessor.
122
116
  *
123
117
  * Context Propagation:
124
118
  * - Automatically continues traces from NodeSDK auto-instrumentation
125
119
  * - Effect spans become children of HTTP request spans
120
+ * - Respects http.ignore_incoming_paths and other filtering patterns
126
121
  * - No configuration needed
127
122
  *
128
123
  * @example
@@ -138,7 +133,7 @@ declare function createEffectInstrumentation(options?: EffectInstrumentationOpti
138
133
  * )
139
134
  * ```
140
135
  */
141
- declare const EffectInstrumentationLive: Layer.Layer<never, never, never>;
136
+ declare const EffectInstrumentationLive: Layer.Layer<Tracer.OtelTracer, never, never>;
142
137
 
143
138
  /**
144
139
  * Effect-specific span annotation helpers
@@ -1,20 +1,17 @@
1
- import { Data, Context, Effect, Layer, FiberSet as FiberSet$1, Fiber, Option, FiberId, Tracer } from 'effect';
1
+ import { Data, Context, Effect, Layer, FiberSet as FiberSet$1, Fiber, Option, FiberId, Tracer as Tracer$1 } from 'effect';
2
+ import * as Tracer from '@effect/opentelemetry/Tracer';
3
+ import * as Resource from '@effect/opentelemetry/Resource';
2
4
  import * as Otlp from '@effect/opentelemetry/Otlp';
3
5
  import { FetchHttpClient } from '@effect/platform';
4
6
  import { TraceFlags, trace, context } from '@opentelemetry/api';
7
+ import { TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS, ATTR_TELEMETRY_SDK_NAME, ATTR_TELEMETRY_SDK_LANGUAGE } from '@opentelemetry/semantic-conventions';
5
8
  import { FileSystem } from '@effect/platform/FileSystem';
6
9
  import * as HttpClient from '@effect/platform/HttpClient';
7
10
  import * as HttpClientRequest from '@effect/platform/HttpClientRequest';
8
11
  import { parse } from 'yaml';
9
12
  import { z } from 'zod';
10
- import { NodeContext } from '@effect/platform-node';
11
13
 
12
14
  // src/integrations/effect/effect-tracer.ts
13
-
14
- // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.38.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js
15
- var ATTR_TELEMETRY_SDK_LANGUAGE = "telemetry.sdk.language";
16
- var TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS = "nodejs";
17
- var ATTR_TELEMETRY_SDK_NAME = "telemetry.sdk.name";
18
15
  var __defProp = Object.defineProperty;
19
16
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
20
17
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -76,11 +73,50 @@ var InstrumentationConfigSchema = z.object({
76
73
  ignore_patterns: z.array(PatternConfigSchema)
77
74
  }),
78
75
  effect: z.object({
76
+ // Enable/disable Effect tracing entirely
77
+ // When false, EffectInstrumentationLive returns Layer.empty
78
+ enabled: z.boolean().default(true),
79
+ // Exporter mode:
80
+ // - "unified": Use global TracerProvider from Node SDK (recommended, enables filtering)
81
+ // - "standalone": Use Effect's own OTLP exporter (bypasses Node SDK filtering)
82
+ exporter: z.enum(["unified", "standalone"]).default("unified"),
79
83
  auto_extract_metadata: z.boolean(),
80
84
  auto_isolation: AutoIsolationConfigSchema.optional()
81
85
  }).optional(),
82
86
  http: HttpFilteringConfigSchema.optional()
83
87
  });
88
+ var defaultConfig = {
89
+ version: "1.0",
90
+ instrumentation: {
91
+ enabled: true,
92
+ logging: "on",
93
+ description: "Default instrumentation configuration",
94
+ instrument_patterns: [
95
+ { pattern: "^app\\.", enabled: true, description: "Application operations" },
96
+ { pattern: "^http\\.server\\.", enabled: true, description: "HTTP server operations" },
97
+ { pattern: "^http\\.client\\.", enabled: true, description: "HTTP client operations" }
98
+ ],
99
+ ignore_patterns: [
100
+ { pattern: "^test\\.", description: "Test utilities" },
101
+ { pattern: "^internal\\.", description: "Internal operations" },
102
+ { pattern: "^health\\.", description: "Health checks" }
103
+ ]
104
+ },
105
+ effect: {
106
+ enabled: true,
107
+ exporter: "unified",
108
+ auto_extract_metadata: true
109
+ }
110
+ };
111
+ function parseAndValidateConfig(content) {
112
+ let parsed;
113
+ if (typeof content === "string") {
114
+ parsed = parse(content);
115
+ } else {
116
+ parsed = content;
117
+ }
118
+ return InstrumentationConfigSchema.parse(parsed);
119
+ }
84
120
  (class extends Data.TaggedError("ConfigError") {
85
121
  get message() {
86
122
  return this.reason;
@@ -258,7 +294,7 @@ var makeConfigLoader = Effect.gen(function* () {
258
294
  })
259
295
  });
260
296
  });
261
- var ConfigLoaderLive = Layer.effect(ConfigLoader, makeConfigLoader);
297
+ Layer.effect(ConfigLoader, makeConfigLoader);
262
298
  var PatternMatcher = class {
263
299
  constructor(config) {
264
300
  __publicField(this, "ignorePatterns", []);
@@ -406,84 +442,58 @@ var Logger = class {
406
442
  }
407
443
  };
408
444
  var logger = new Logger();
409
- var NodeConfigLoaderLive = ConfigLoaderLive.pipe(
410
- Layer.provide(Layer.mergeAll(NodeContext.layer, FetchHttpClient.layer))
411
- );
412
- var cachedLoaderPromise = null;
413
- function getCachedLoader() {
414
- if (!cachedLoaderPromise) {
415
- cachedLoaderPromise = Effect.runPromise(
416
- Effect.gen(function* () {
417
- return yield* ConfigLoader;
418
- }).pipe(Effect.provide(NodeConfigLoaderLive))
419
- );
445
+ async function loadFromFile(filePath) {
446
+ const { readFile } = await import('fs/promises');
447
+ const content = await readFile(filePath, "utf-8");
448
+ return parseAndValidateConfig(content);
449
+ }
450
+ async function loadFromUrl(url) {
451
+ const response = await fetch(url);
452
+ if (!response.ok) {
453
+ throw new Error(`Failed to fetch config from ${url}: ${response.statusText}`);
420
454
  }
421
- return cachedLoaderPromise;
455
+ const content = await response.text();
456
+ return parseAndValidateConfig(content);
422
457
  }
423
- async function loadConfig(uri, options) {
424
- if (options?.cacheTimeout === 0) {
425
- const program = Effect.gen(function* () {
426
- const loader2 = yield* ConfigLoader;
427
- return yield* loader2.loadFromUri(uri);
428
- });
429
- return Effect.runPromise(program.pipe(Effect.provide(NodeConfigLoaderLive)));
430
- }
431
- const loader = await getCachedLoader();
432
- return Effect.runPromise(loader.loadFromUri(uri));
458
+ async function loadConfig(uri, _options) {
459
+ if (uri.startsWith("http://") || uri.startsWith("https://")) {
460
+ return loadFromUrl(uri);
461
+ }
462
+ if (uri.startsWith("file://")) {
463
+ const filePath = uri.slice(7);
464
+ return loadFromFile(filePath);
465
+ }
466
+ return loadFromFile(uri);
433
467
  }
434
468
  async function loadConfigFromInline(content) {
435
- const loader = await getCachedLoader();
436
- return Effect.runPromise(loader.loadFromInline(content));
437
- }
438
- function getDefaultConfig() {
439
- return {
440
- version: "1.0",
441
- instrumentation: {
442
- enabled: true,
443
- logging: "on",
444
- description: "Default instrumentation configuration",
445
- instrument_patterns: [
446
- { pattern: "^app\\.", enabled: true, description: "Application operations" },
447
- { pattern: "^http\\.server\\.", enabled: true, description: "HTTP server operations" },
448
- { pattern: "^http\\.client\\.", enabled: true, description: "HTTP client operations" }
449
- ],
450
- ignore_patterns: [
451
- { pattern: "^test\\.", description: "Test utilities" },
452
- { pattern: "^internal\\.", description: "Internal operations" },
453
- { pattern: "^health\\.", description: "Health checks" }
454
- ]
455
- },
456
- effect: {
457
- auto_extract_metadata: true
458
- }
459
- };
469
+ return parseAndValidateConfig(content);
460
470
  }
461
471
  async function loadConfigWithOptions(options = {}) {
462
- const loadOptions = options.cacheTimeout !== void 0 ? { cacheTimeout: options.cacheTimeout } : void 0;
463
472
  if (options.config) {
464
473
  return loadConfigFromInline(options.config);
465
474
  }
466
475
  const envConfigPath = process.env.ATRIM_INSTRUMENTATION_CONFIG;
467
476
  if (envConfigPath) {
468
- return loadConfig(envConfigPath, loadOptions);
477
+ return loadConfig(envConfigPath);
469
478
  }
470
479
  if (options.configUrl) {
471
- return loadConfig(options.configUrl, loadOptions);
480
+ return loadConfig(options.configUrl);
472
481
  }
473
482
  if (options.configPath) {
474
- return loadConfig(options.configPath, loadOptions);
483
+ return loadConfig(options.configPath);
475
484
  }
476
485
  const { existsSync } = await import('fs');
477
486
  const { join } = await import('path');
478
487
  const defaultPath = join(process.cwd(), "instrumentation.yaml");
479
488
  if (existsSync(defaultPath)) {
480
- return loadConfig(defaultPath, loadOptions);
489
+ return loadConfig(defaultPath);
481
490
  }
482
- return getDefaultConfig();
491
+ return defaultConfig;
483
492
  }
484
493
 
485
494
  // src/integrations/effect/effect-tracer.ts
486
- var SDK_NAME = "@effect/opentelemetry-otlp";
495
+ var SDK_NAME = "@effect/opentelemetry";
496
+ var ATTR_TELEMETRY_EXPORTER_MODE = "telemetry.exporter.mode";
487
497
  function createEffectInstrumentation(options = {}) {
488
498
  return Layer.unwrapEffect(
489
499
  Effect.gen(function* () {
@@ -494,90 +504,89 @@ function createEffectInstrumentation(options = {}) {
494
504
  message: error instanceof Error ? error.message : String(error)
495
505
  })
496
506
  });
507
+ const effectEnabled = process.env.OTEL_EFFECT_ENABLED !== "false" && (config.effect?.enabled ?? true);
508
+ if (!effectEnabled) {
509
+ logger.log("@atrim/instrumentation/effect: Effect tracing disabled via config");
510
+ return Layer.empty;
511
+ }
497
512
  yield* Effect.sync(() => {
498
513
  const loggingLevel = config.instrumentation.logging || "on";
499
514
  logger.setLevel(loggingLevel);
500
515
  });
501
516
  yield* Effect.sync(() => initializePatternMatcher(config));
502
- const otlpEndpoint = options.otlpEndpoint || process.env.OTEL_EXPORTER_OTLP_ENDPOINT || "http://localhost:4318";
503
517
  const serviceName = options.serviceName || process.env.OTEL_SERVICE_NAME || "effect-service";
504
518
  const serviceVersion = options.serviceVersion || process.env.npm_package_version || "1.0.0";
505
- const autoExtractMetadata = options.autoExtractMetadata ?? config.effect?.auto_extract_metadata ?? true;
506
- const continueExistingTraces = options.continueExistingTraces ?? true;
507
- logger.log("\u{1F50D} Effect OpenTelemetry instrumentation");
508
- logger.log(` \u{1F4E1} Endpoint: ${otlpEndpoint}`);
509
- logger.log(` \u{1F3F7}\uFE0F Service: ${serviceName}`);
510
- logger.log(` \u2705 Auto metadata extraction: ${autoExtractMetadata}`);
511
- logger.log(` \u2705 Continue existing traces: ${continueExistingTraces}`);
512
- const otlpLayer = Otlp.layer({
513
- baseUrl: otlpEndpoint,
514
- resource: {
515
- serviceName,
516
- serviceVersion,
517
- attributes: {
518
- "platform.component": "effect",
519
- "effect.auto_metadata": autoExtractMetadata,
520
- "effect.context_propagation": continueExistingTraces,
521
- [ATTR_TELEMETRY_SDK_LANGUAGE]: TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS,
522
- [ATTR_TELEMETRY_SDK_NAME]: SDK_NAME
523
- }
524
- },
525
- // Bridge Effect context to OpenTelemetry global context
526
- // This is essential for context propagation to work properly
527
- tracerContext: (f, span) => {
528
- if (span._tag !== "Span") {
529
- return f();
519
+ const exporterMode = options.exporterMode ?? config.effect?.exporter ?? "unified";
520
+ const resourceAttributes = {
521
+ "platform.component": "effect",
522
+ [ATTR_TELEMETRY_SDK_LANGUAGE]: TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS,
523
+ [ATTR_TELEMETRY_SDK_NAME]: SDK_NAME,
524
+ [ATTR_TELEMETRY_EXPORTER_MODE]: exporterMode
525
+ };
526
+ if (exporterMode === "standalone") {
527
+ const otlpEndpoint = options.otlpEndpoint || process.env.OTEL_EXPORTER_OTLP_ENDPOINT || "http://localhost:4318";
528
+ logger.log("Effect OpenTelemetry instrumentation (standalone)");
529
+ logger.log(` Service: ${serviceName}`);
530
+ logger.log(` Endpoint: ${otlpEndpoint}`);
531
+ logger.log(" WARNING: Standalone mode bypasses Node SDK filtering");
532
+ return Otlp.layer({
533
+ baseUrl: otlpEndpoint,
534
+ resource: {
535
+ serviceName,
536
+ serviceVersion,
537
+ attributes: resourceAttributes
538
+ },
539
+ // Bridge Effect context to OpenTelemetry global context
540
+ tracerContext: (f, span) => {
541
+ if (span._tag !== "Span") {
542
+ return f();
543
+ }
544
+ const spanContext = {
545
+ traceId: span.traceId,
546
+ spanId: span.spanId,
547
+ traceFlags: span.sampled ? TraceFlags.SAMPLED : TraceFlags.NONE
548
+ };
549
+ const otelSpan = trace.wrapSpanContext(spanContext);
550
+ return context.with(trace.setSpan(context.active(), otelSpan), f);
530
551
  }
531
- const spanContext = {
532
- traceId: span.traceId,
533
- spanId: span.spanId,
534
- traceFlags: span.sampled ? TraceFlags.SAMPLED : TraceFlags.NONE
535
- };
536
- const otelSpan = trace.wrapSpanContext(spanContext);
537
- return context.with(trace.setSpan(context.active(), otelSpan), f);
538
- }
539
- }).pipe(Layer.provide(FetchHttpClient.layer));
540
- if (autoExtractMetadata) {
541
- return otlpLayer;
552
+ }).pipe(Layer.provide(FetchHttpClient.layer));
553
+ } else {
554
+ logger.log("Effect OpenTelemetry instrumentation (unified)");
555
+ logger.log(` Service: ${serviceName}`);
556
+ logger.log(" Using global TracerProvider for span export");
557
+ return Tracer.layerGlobal.pipe(
558
+ Layer.provide(
559
+ Resource.layer({
560
+ serviceName,
561
+ serviceVersion,
562
+ attributes: resourceAttributes
563
+ })
564
+ )
565
+ );
542
566
  }
543
- return otlpLayer;
544
567
  })
545
568
  ).pipe(Layer.orDie);
546
569
  }
547
570
  var EffectInstrumentationLive = Effect.sync(() => {
548
- const endpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT || "http://localhost:4318";
549
571
  const serviceName = process.env.OTEL_SERVICE_NAME || "effect-service";
550
572
  const serviceVersion = process.env.npm_package_version || "1.0.0";
551
573
  logger.minimal(`@atrim/instrumentation/effect: Effect tracing enabled (${serviceName})`);
552
- logger.log("\u{1F50D} Effect OpenTelemetry tracer");
553
- logger.log(` \u{1F4E1} Endpoint: ${endpoint}`);
554
- logger.log(` \u{1F3F7}\uFE0F Service: ${serviceName}`);
555
- return Otlp.layer({
556
- baseUrl: endpoint,
557
- resource: {
558
- serviceName,
559
- serviceVersion,
560
- attributes: {
561
- "platform.component": "effect",
562
- [ATTR_TELEMETRY_SDK_LANGUAGE]: TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS,
563
- [ATTR_TELEMETRY_SDK_NAME]: SDK_NAME
564
- }
565
- },
566
- // CRITICAL: Bridge Effect context to OpenTelemetry global context
567
- // This allows NodeSDK auto-instrumentation to see Effect spans as parent spans
568
- tracerContext: (f, span) => {
569
- if (span._tag !== "Span") {
570
- return f();
571
- }
572
- const spanContext = {
573
- traceId: span.traceId,
574
- spanId: span.spanId,
575
- traceFlags: span.sampled ? TraceFlags.SAMPLED : TraceFlags.NONE
576
- };
577
- const otelSpan = trace.wrapSpanContext(spanContext);
578
- return context.with(trace.setSpan(context.active(), otelSpan), f);
579
- }
580
- }).pipe(Layer.provide(FetchHttpClient.layer));
574
+ logger.log("Effect OpenTelemetry tracer (unified)");
575
+ logger.log(` Service: ${serviceName}`);
576
+ return Tracer.layerGlobal.pipe(
577
+ Layer.provide(
578
+ Resource.layer({
579
+ serviceName,
580
+ serviceVersion,
581
+ attributes: {
582
+ "platform.component": "effect",
583
+ [ATTR_TELEMETRY_SDK_LANGUAGE]: TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS,
584
+ [ATTR_TELEMETRY_SDK_NAME]: SDK_NAME,
585
+ [ATTR_TELEMETRY_EXPORTER_MODE]: "unified"
586
+ }
587
+ })
588
+ )
589
+ );
581
590
  }).pipe(Layer.unwrapEffect);
582
591
  function annotateUser(userId, email, username) {
583
592
  const attributes = {
@@ -766,7 +775,7 @@ var runIsolated = (set, effect, name, options) => {
766
775
  return FiberSet$1.run(set, effect, { propagateInterruption });
767
776
  }
768
777
  return Effect.gen(function* () {
769
- const maybeParent = yield* Effect.serviceOption(Tracer.ParentSpan);
778
+ const maybeParent = yield* Effect.serviceOption(Tracer$1.ParentSpan);
770
779
  if (maybeParent._tag === "None" || !captureLogicalParent) {
771
780
  const isolated2 = effect.pipe(
772
781
  Effect.withSpan(name, {