@atrim/instrument-node 0.7.0 → 0.7.1-dev.14fdea7.20260108224013
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 +6 -1
- package/target/dist/index.cjs +93 -2
- package/target/dist/index.cjs.map +1 -1
- package/target/dist/index.js +93 -2
- package/target/dist/index.js.map +1 -1
- package/target/dist/integrations/effect/auto/index.cjs +1117 -0
- package/target/dist/integrations/effect/auto/index.cjs.map +1 -0
- package/target/dist/integrations/effect/auto/index.d.cts +359 -0
- package/target/dist/integrations/effect/auto/index.d.ts +359 -0
- package/target/dist/integrations/effect/auto/index.js +1074 -0
- package/target/dist/integrations/effect/auto/index.js.map +1 -0
- package/target/dist/integrations/effect/index.cjs +93 -2
- package/target/dist/integrations/effect/index.cjs.map +1 -1
- package/target/dist/integrations/effect/index.js +93 -2
- package/target/dist/integrations/effect/index.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../core/src/instrumentation-schema.ts","../../../../../../core/src/errors.ts","../../../../../../core/src/services/config-loader.ts","../../../../../../core/src/logger.ts","../../../../../src/integrations/effect/auto/naming.ts","../../../../../src/core/config-loader.ts","../../../../../src/integrations/effect/auto/config.ts","../../../../../src/integrations/effect/auto/supervisor.ts"],"names":["z","parseYaml","Data","Context","Effect","parseYAML","path","HttpClientRequest","FileSystem","HttpClient","Layer","__publicField","basename","FiberRef","Option","Supervisor","OtelApi","FiberRefs","Exit","effect","ConsoleSpanExporter","exporterConfig","OTLPTraceExporter","SimpleSpanProcessor","BatchSpanProcessor","BasicTracerProvider","resourceFromAttributes","ATTR_SERVICE_NAME","ATTR_SERVICE_VERSION"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMO,IAAM,mBAAA,GAAsBA,MAAE,MAAA,CAAO;AAC1C,EAAA,OAAA,EAASA,MAAE,MAAA,EAAA;EACX,OAAA,EAASA,KAAA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gB,IAAA,IAAQ,MAAM,CAAA,CAAE,CAAA;AAG1D,MAAA,MAAM,aAAA,GAAgB,mBAAA,CAAoB,cAAA,EAAgB,WAAA,EAAa,cAAc,CAAA;AAGrF,MAAA,MAAM,UAAA,GAAa,4BAA4B,UAAU,CAAA;AACzD,MAAA,MAAM,eAAA,GAAkBK,iBAAA,CAAW,aAAA,CAAc,UAAU,CAAA;AAG3D,MAAA,OAAOL,YAAAA,CAAM,QAAA,CAAS,aAAA,EAAe,eAAe,CAAA;AAAA,IACtD,CAAC;AAAA,GACH;AACF;AAoCO,IAAM,sBAA0C,0BAAA","file":"index.cjs","sourcesContent":["/**\n * Configuration schema using Zod\n */\nimport { z } from 'zod'\nimport { parse as parseYaml } from 'yaml'\n\nexport const PatternConfigSchema = z.object({\n pattern: z.string(),\n enabled: z.boolean().optional(),\n description: z.string().optional()\n})\n\n/**\n * Configuration for automatic span isolation in Effect operations\n *\n * This prevents context leakage when using FiberSet.run, Effect.fork, etc.\n * while maintaining logical parent relationships via span links.\n */\nexport const AutoIsolationConfigSchema = z.object({\n // Global enable/disable for auto-isolation\n enabled: z.boolean().default(false),\n\n // Which operators to auto-isolate\n operators: z\n .object({\n fiberset_run: z.boolean().default(true),\n effect_fork: z.boolean().default(true),\n effect_fork_daemon: z.boolean().default(true),\n effect_fork_in: z.boolean().default(false)\n })\n .default({}),\n\n // Virtual parent tracking configuration\n tracking: z\n .object({\n use_span_links: z.boolean().default(true),\n use_attributes: z.boolean().default(true),\n capture_logical_parent: z.boolean().default(true)\n })\n .default({}),\n\n // Span categorization\n attributes: z\n .object({\n category: z.string().default('background_task'),\n add_metadata: z.boolean().default(true)\n })\n .default({})\n})\n\n/**\n * HTTP instrumentation filtering configuration\n *\n * Allows filtering of HTTP requests to prevent noisy traces\n * (e.g., health checks, OTLP exports, internal endpoints)\n */\n/**\n * Span naming rule for auto-instrumentation\n *\n * Allows matching fibers based on file path, function name, etc.\n * and applying custom span names with template variables.\n */\nexport const SpanNamingRuleSchema = z.object({\n // Match criteria (all specified criteria must match)\n match: z.object({\n // Regex pattern to match file path\n file: z.string().optional(),\n // Regex pattern to match function name\n function: z.string().optional(),\n // Regex pattern to match module name\n module: z.string().optional()\n }),\n // Span name template with variables:\n // {fiber_id} - Fiber ID\n // {function} - Function name\n // {module} - Module name\n // {file} - File path\n // {line} - Line number\n // {operator} - Effect operator (gen, all, forEach, etc.)\n // {match:field:N} - Captured regex group from match\n name: z.string()\n})\n\n/**\n * Auto-instrumentation configuration for Effect operations\n *\n * Enables automatic tracing of all Effect fibers without manual\n * Effect.withSpan() calls. Configuration-driven via instrumentation.yaml.\n */\nexport const AutoInstrumentationConfigSchema = z.object({\n // Enable/disable auto-instrumentation\n enabled: z.boolean().default(false),\n\n // Tracing granularity\n // - 'fiber': Trace at fiber creation (recommended, lower overhead)\n // - 'operator': Trace each Effect operator (higher granularity, more overhead)\n granularity: z.enum(['fiber', 'operator']).default('fiber'),\n\n // Smart span naming configuration\n span_naming: z\n .object({\n // Default span name template when no rules match\n default: z.string().default('effect.fiber.{fiber_id}'),\n\n // Infer span names from source code (requires stack trace parsing)\n // Adds ~50-100μs overhead per fiber\n infer_from_source: z.boolean().default(true),\n\n // Naming rules (first match wins)\n rules: z.array(SpanNamingRuleSchema).default([])\n })\n .default({}),\n\n // Pattern-based filtering\n filter: z\n .object({\n // Only trace spans matching these patterns (empty = trace all)\n include: z.array(z.string()).default([]),\n\n // Never trace spans matching these patterns\n exclude: z.array(z.string()).default([])\n })\n .default({}),\n\n // Performance controls\n performance: z\n .object({\n // Sample rate (0.0 - 1.0)\n sampling_rate: z.number().min(0).max(1).default(1.0),\n\n // Skip fibers shorter than this duration (e.g., \"10ms\", \"100 millis\")\n min_duration: z.string().default('0ms'),\n\n // Maximum concurrent traced fibers (0 = unlimited)\n max_concurrent: z.number().default(0)\n })\n .default({}),\n\n // Automatic metadata extraction\n metadata: z\n .object({\n // Extract Effect fiber information\n fiber_info: z.boolean().default(true),\n\n // Extract source location (file:line)\n source_location: z.boolean().default(true),\n\n // Extract parent fiber information\n parent_fiber: z.boolean().default(true)\n })\n .default({})\n})\n\nexport type AutoInstrumentationConfig = z.infer<typeof AutoInstrumentationConfigSchema>\nexport type SpanNamingRule = z.infer<typeof SpanNamingRuleSchema>\n\n/**\n * HTTP instrumentation filtering configuration\n *\n * Allows filtering of HTTP requests to prevent noisy traces\n * (e.g., health checks, OTLP exports, internal endpoints)\n */\nexport const HttpFilteringConfigSchema = z.object({\n // Patterns to ignore for outgoing HTTP requests (string patterns only in YAML)\n ignore_outgoing_urls: z.array(z.string()).optional(),\n\n // Patterns to ignore for incoming HTTP requests (string patterns only in YAML)\n ignore_incoming_paths: z.array(z.string()).optional(),\n\n // Require parent span for outgoing requests (prevents root spans for HTTP calls)\n require_parent_for_outgoing_spans: z.boolean().optional(),\n\n // Trace context propagation configuration\n // Controls which cross-origin requests receive W3C Trace Context headers (traceparent, tracestate)\n propagate_trace_context: z\n .object({\n // Strategy for trace propagation\n // - \"all\": Propagate to all cross-origin requests (may cause CORS errors)\n // - \"none\": Never propagate trace headers\n // - \"same-origin\": Only propagate to same-origin requests (default, safe)\n // - \"patterns\": Propagate based on include_urls patterns\n strategy: z.enum(['all', 'none', 'same-origin', 'patterns']).default('same-origin'),\n\n // URL patterns to include when strategy is \"patterns\"\n // Supports regex patterns (e.g., \"^https://api\\\\.myapp\\\\.com\")\n include_urls: z.array(z.string()).optional()\n })\n .optional()\n})\n\n/**\n * Exporter configuration for OpenTelemetry tracing\n *\n * Allows configuring how traces are exported via instrumentation.yaml\n */\nexport const ExporterConfigSchema = z.object({\n // Exporter type: 'otlp' | 'console' | 'none'\n // - 'otlp': Export to OTLP endpoint (production)\n // - 'console': Log spans to console (development)\n // - 'none': No export (disable tracing)\n type: z.enum(['otlp', 'console', 'none']).default('otlp'),\n\n // OTLP endpoint URL (for type: otlp)\n // Defaults to OTEL_EXPORTER_OTLP_ENDPOINT env var or http://localhost:4318\n endpoint: z.string().optional(),\n\n // Custom headers to send with OTLP requests (for type: otlp)\n // Useful for authentication (x-api-key, Authorization, etc.)\n headers: z.record(z.string()).optional(),\n\n // Span processor type\n // - 'batch': Batch spans for export (production, lower overhead)\n // - 'simple': Export immediately (development, no batching delay)\n processor: z.enum(['batch', 'simple']).default('batch'),\n\n // Batch processor settings (for processor: batch)\n batch: z\n .object({\n // Max time to wait before exporting (milliseconds)\n scheduled_delay_millis: z.number().default(1000),\n // Max batch size\n max_export_batch_size: z.number().default(100)\n })\n .optional()\n})\n\nexport type ExporterConfig = z.infer<typeof ExporterConfigSchema>\n\nexport const InstrumentationConfigSchema = z.object({\n version: z.string(),\n instrumentation: z.object({\n enabled: z.boolean(),\n description: z.string().optional(),\n logging: z.enum(['on', 'off', 'minimal']).optional().default('on'),\n instrument_patterns: z.array(PatternConfigSchema),\n ignore_patterns: z.array(PatternConfigSchema)\n }),\n effect: z\n .object({\n // Enable/disable Effect tracing entirely\n // When false, EffectInstrumentationLive returns Layer.empty\n enabled: z.boolean().default(true),\n // Exporter mode (legacy - use exporter.type instead):\n // - \"unified\": Use global TracerProvider from Node SDK (recommended, enables filtering)\n // - \"standalone\": Use Effect's own OTLP exporter (bypasses Node SDK filtering)\n exporter: z.enum(['unified', 'standalone']).default('unified'),\n // Exporter configuration (for auto-instrumentation)\n exporter_config: ExporterConfigSchema.optional(),\n auto_extract_metadata: z.boolean(),\n auto_isolation: AutoIsolationConfigSchema.optional(),\n // Auto-instrumentation: automatic tracing of all Effect fibers\n auto_instrumentation: AutoInstrumentationConfigSchema.optional()\n })\n .optional(),\n http: HttpFilteringConfigSchema.optional()\n})\n\nexport type InstrumentationConfig = z.infer<typeof InstrumentationConfigSchema>\nexport type PatternConfig = z.infer<typeof PatternConfigSchema>\nexport type AutoIsolationConfig = z.infer<typeof AutoIsolationConfigSchema>\nexport type HttpFilteringConfig = z.infer<typeof HttpFilteringConfigSchema>\n\n/**\n * Default configuration when no config file is found\n */\nexport const defaultConfig: InstrumentationConfig = {\n version: '1.0',\n instrumentation: {\n enabled: true,\n logging: 'on',\n description: 'Default instrumentation configuration',\n instrument_patterns: [\n { pattern: '^app\\\\.', enabled: true, description: 'Application operations' },\n { pattern: '^http\\\\.server\\\\.', enabled: true, description: 'HTTP server operations' },\n { pattern: '^http\\\\.client\\\\.', enabled: true, description: 'HTTP client operations' }\n ],\n ignore_patterns: [\n { pattern: '^test\\\\.', description: 'Test utilities' },\n { pattern: '^internal\\\\.', description: 'Internal operations' },\n { pattern: '^health\\\\.', description: 'Health checks' }\n ]\n },\n effect: {\n enabled: true,\n exporter: 'unified' as const,\n auto_extract_metadata: true\n }\n}\n\n/**\n * Parse and validate configuration content (YAML string, JSON string, or object)\n *\n * @param content - YAML string, JSON string, or plain object\n * @returns Validated InstrumentationConfig\n * @throws Error if parsing or validation fails\n */\nexport function parseAndValidateConfig(content: string | unknown): InstrumentationConfig {\n let parsed: unknown\n\n // If string, parse as YAML (YAML is a superset of JSON)\n if (typeof content === 'string') {\n parsed = parseYaml(content)\n } else {\n parsed = content\n }\n\n // Validate with schema\n return InstrumentationConfigSchema.parse(parsed)\n}\n","/**\n * Typed error hierarchy for @atrim/instrumentation\n *\n * These errors use Effect's Data.TaggedError for typed error handling\n * with proper discriminated unions.\n */\n\nimport { Data } from 'effect'\n\n/**\n * Base error for configuration-related failures\n */\nexport class ConfigError extends Data.TaggedError('ConfigError')<{\n reason: string\n cause?: unknown\n}> {\n override get message() {\n return this.reason\n }\n}\n\n/**\n * Error when fetching configuration from a URL fails\n */\nexport class ConfigUrlError extends Data.TaggedError('ConfigUrlError')<{\n reason: string\n cause?: unknown\n}> {\n override get message() {\n return this.reason\n }\n}\n\n/**\n * Error when configuration validation fails (invalid YAML, schema mismatch)\n */\nexport class ConfigValidationError extends Data.TaggedError('ConfigValidationError')<{\n reason: string\n cause?: unknown\n}> {\n override get message() {\n return this.reason\n }\n}\n\n/**\n * Error when reading configuration from a file fails\n */\nexport class ConfigFileError extends Data.TaggedError('ConfigFileError')<{\n reason: string\n cause?: unknown\n}> {\n override get message() {\n return this.reason\n }\n}\n\n/**\n * Error when service detection fails (package.json not found, invalid format)\n */\nexport class ServiceDetectionError extends Data.TaggedError('ServiceDetectionError')<{\n reason: string\n cause?: unknown\n}> {\n override get message() {\n return this.reason\n }\n}\n\n/**\n * Error when OpenTelemetry SDK initialization fails\n */\nexport class InitializationError extends Data.TaggedError('InitializationError')<{\n reason: string\n cause?: unknown\n}> {\n override get message() {\n return this.reason\n }\n}\n\n/**\n * Error when span export fails (e.g., ECONNREFUSED to collector)\n */\nexport class ExportError extends Data.TaggedError('ExportError')<{\n reason: string\n cause?: unknown\n}> {\n override get message() {\n return this.reason\n }\n}\n\n/**\n * Error when shutting down the SDK fails\n */\nexport class ShutdownError extends Data.TaggedError('ShutdownError')<{\n reason: string\n cause?: unknown\n}> {\n override get message() {\n return this.reason\n }\n}\n","/**\n * ConfigLoader service using Effect Platform\n *\n * Provides URI-based configuration loading with pluggable platform services:\n * - FileSystem for file:// URIs (Node.js/Bun/Deno)\n * - HttpClient for http:// and https:// URIs (universal)\n *\n * This service has NO Node.js-specific dependencies - it depends only on\n * abstract Effect Platform services that are provided by environment-specific layers.\n */\n\nimport { Effect, Context, Layer } from 'effect'\nimport { FileSystem } from '@effect/platform/FileSystem'\nimport * as HttpClient from '@effect/platform/HttpClient'\nimport * as HttpClientRequest from '@effect/platform/HttpClientRequest'\nimport { parse as parseYAML } from 'yaml'\nimport {\n InstrumentationConfigSchema,\n type InstrumentationConfig\n} from '../instrumentation-schema.js'\nimport { ConfigError, ConfigFileError, ConfigUrlError, ConfigValidationError } from '../errors.js'\n\n// Security constraints\nconst SECURITY_DEFAULTS = {\n maxConfigSize: 1_000_000, // 1MB\n requestTimeout: 5_000 // 5 seconds\n} as const\n\n/**\n * ConfigLoader service interface\n */\nexport interface ConfigLoaderService {\n /**\n * Load configuration from a URI\n *\n * Supports:\n * - file:// URIs (uses FileSystem if available)\n * - http:// and https:// URIs (uses HttpClient)\n * - Relative paths (treated as file:// in Node, http:// in browser)\n *\n * @param uri - Configuration URI\n * @returns Effect that resolves to validated configuration (NO requirements)\n */\n readonly loadFromUri: (\n uri: string\n ) => Effect.Effect<\n InstrumentationConfig,\n ConfigError | ConfigFileError | ConfigUrlError | ConfigValidationError\n >\n\n /**\n * Load configuration from inline content (YAML, JSON, or object)\n *\n * @param content - YAML string, JSON string, or plain object\n * @returns Effect that resolves to validated configuration\n */\n readonly loadFromInline: (\n content: string | unknown\n ) => Effect.Effect<InstrumentationConfig, ConfigError | ConfigValidationError>\n}\n\n/**\n * ConfigLoader service tag\n */\nexport class ConfigLoader extends Context.Tag('ConfigLoader')<\n ConfigLoader,\n ConfigLoaderService\n>() {}\n\n/**\n * Parse and validate YAML content\n */\nconst parseYamlContent = (\n content: string,\n uri?: string\n): Effect.Effect<InstrumentationConfig, ConfigValidationError> =>\n Effect.gen(function* () {\n // Parse YAML\n const parsed = yield* Effect.try({\n try: () => parseYAML(content),\n catch: (error) =>\n new ConfigValidationError({\n reason: uri ? `Failed to parse YAML from ${uri}` : 'Failed to parse YAML',\n cause: error\n })\n })\n\n // Validate schema\n return yield* Effect.try({\n try: () => InstrumentationConfigSchema.parse(parsed),\n catch: (error) =>\n new ConfigValidationError({\n reason: uri ? `Invalid configuration schema from ${uri}` : 'Invalid configuration schema',\n cause: error\n })\n })\n })\n\n/**\n * Load configuration from file using captured FileSystem service\n */\nconst loadFromFileWithFs = (\n fs: FileSystem,\n path: string,\n uri: string\n): Effect.Effect<InstrumentationConfig, ConfigFileError | ConfigValidationError> =>\n Effect.gen(function* () {\n // Read file\n const content = yield* fs.readFileString(path).pipe(\n Effect.mapError(\n (error) =>\n new ConfigFileError({\n reason: `Failed to read config file at ${uri}`,\n cause: error\n })\n )\n )\n\n // Security: Check file size\n if (content.length > SECURITY_DEFAULTS.maxConfigSize) {\n return yield* Effect.fail(\n new ConfigFileError({\n reason: `Config file exceeds maximum size of ${SECURITY_DEFAULTS.maxConfigSize} bytes`\n })\n )\n }\n\n // Parse and validate\n return yield* parseYamlContent(content, uri)\n })\n\n/**\n * Load configuration from http using captured HttpClient service\n */\nconst loadFromHttpWithClient = (\n client: HttpClient.HttpClient,\n url: string\n): Effect.Effect<InstrumentationConfig, ConfigUrlError | ConfigValidationError> =>\n Effect.scoped(\n Effect.gen(function* () {\n // Security: Reject non-HTTPS URLs\n if (url.startsWith('http://')) {\n return yield* Effect.fail(\n new ConfigUrlError({\n reason: 'Insecure protocol: only HTTPS URLs are allowed'\n })\n )\n }\n\n // Create request\n const request = HttpClientRequest.get(url).pipe(\n HttpClientRequest.setHeaders({\n Accept: 'application/yaml, text/yaml, application/x-yaml'\n })\n )\n\n // Execute request with timeout\n const response = yield* client.execute(request).pipe(\n Effect.timeout(`${SECURITY_DEFAULTS.requestTimeout} millis`),\n Effect.mapError((error) => {\n if (error._tag === 'TimeoutException') {\n return new ConfigUrlError({\n reason: `Config fetch timeout after ${SECURITY_DEFAULTS.requestTimeout}ms from ${url}`\n })\n }\n return new ConfigUrlError({\n reason: `Failed to load config from URL: ${url}`,\n cause: error\n })\n })\n )\n\n // Check HTTP status\n if (response.status >= 400) {\n return yield* Effect.fail(\n new ConfigUrlError({\n reason: `HTTP ${response.status} from ${url}`\n })\n )\n }\n\n // Get response text\n const text = yield* response.text.pipe(\n Effect.mapError(\n (error) =>\n new ConfigUrlError({\n reason: `Failed to read response body from ${url}`,\n cause: error\n })\n )\n )\n\n // Security: Check size\n if (text.length > SECURITY_DEFAULTS.maxConfigSize) {\n return yield* Effect.fail(\n new ConfigUrlError({\n reason: `Config exceeds maximum size of ${SECURITY_DEFAULTS.maxConfigSize} bytes`\n })\n )\n }\n\n // Parse and validate\n return yield* parseYamlContent(text, url)\n })\n )\n\n/**\n * ConfigLoader service implementation\n *\n * Captures FileSystem and HttpClient dependencies at construction time\n */\nconst makeConfigLoader = Effect.gen(function* () {\n // Capture dependencies at construction time\n const fs = yield* Effect.serviceOption(FileSystem)\n const http = yield* HttpClient.HttpClient\n\n // Create the loadFromUri function\n const loadFromUriUncached = (uri: string) =>\n Effect.gen(function* () {\n // file:// protocol\n if (uri.startsWith('file://')) {\n const path = uri.slice(7) // Remove \"file://\"\n\n if (fs._tag === 'None') {\n return yield* Effect.fail(\n new ConfigFileError({\n reason: 'FileSystem not available (browser environment?)',\n cause: { uri }\n })\n )\n }\n\n return yield* loadFromFileWithFs(fs.value, path, uri)\n }\n\n // http:// or https:// protocol\n if (uri.startsWith('http://') || uri.startsWith('https://')) {\n return yield* loadFromHttpWithClient(http, uri)\n }\n\n // Relative path - try FileSystem first, fallback to HTTP\n if (fs._tag === 'Some') {\n // FileSystem available (Node.js environment)\n return yield* loadFromFileWithFs(fs.value, uri, uri)\n } else {\n // No FileSystem (browser environment) - treat as HTTP\n // Relative URLs will be resolved by browser fetch to current origin\n return yield* loadFromHttpWithClient(http, uri)\n }\n })\n\n // Cache the loadFromUri function with 5 minute TTL (default cache timeout)\n const loadFromUriCached = yield* Effect.cachedFunction(loadFromUriUncached)\n\n return ConfigLoader.of({\n loadFromUri: loadFromUriCached,\n\n loadFromInline: (content: string | unknown) =>\n Effect.gen(function* () {\n // If string, parse as YAML\n if (typeof content === 'string') {\n return yield* parseYamlContent(content)\n }\n\n // Already an object - just validate schema\n return yield* Effect.try({\n try: () => InstrumentationConfigSchema.parse(content),\n catch: (error) =>\n new ConfigValidationError({\n reason: 'Invalid configuration schema',\n cause: error\n })\n })\n })\n })\n})\n\n/**\n * ConfigLoader Live layer\n *\n * Provides ConfigLoader service implementation.\n * Requires HttpClient to be provided by platform-specific layers.\n * FileSystem is optional (for browser compatibility).\n */\nexport const ConfigLoaderLive = Layer.effect(ConfigLoader, makeConfigLoader)\n","/**\n * Centralized logging utility for @atrim/instrumentation\n *\n * Supports three levels:\n * - 'on' (default): All logging enabled\n * - 'minimal': Only a single initialization message + errors/warnings\n * - 'off': No logging at all\n */\n\nexport type LogLevel = 'on' | 'off' | 'minimal'\n\nclass Logger {\n private level: LogLevel = 'on'\n private hasLoggedMinimal = false\n\n /**\n * Set the logging level\n */\n setLevel(level: LogLevel): void {\n this.level = level\n this.hasLoggedMinimal = false\n }\n\n /**\n * Get the current logging level\n */\n getLevel(): LogLevel {\n return this.level\n }\n\n /**\n * Log a minimal initialization message (only shown once in minimal mode)\n */\n minimal(message: string): void {\n if (this.level === 'off') {\n return\n }\n\n if (this.level === 'minimal' && !this.hasLoggedMinimal) {\n console.log(message)\n this.hasLoggedMinimal = true\n return\n }\n\n if (this.level === 'on') {\n console.log(message)\n }\n }\n\n /**\n * Log an informational message\n */\n log(...args: unknown[]): void {\n if (this.level === 'on') {\n console.log(...args)\n }\n }\n\n /**\n * Log a warning message (shown in minimal mode)\n */\n warn(...args: unknown[]): void {\n if (this.level !== 'off') {\n console.warn(...args)\n }\n }\n\n /**\n * Log an error message (shown in minimal mode)\n */\n error(...args: unknown[]): void {\n if (this.level !== 'off') {\n console.error(...args)\n }\n }\n\n /**\n * Check if full logging is enabled\n */\n isEnabled(): boolean {\n return this.level === 'on'\n }\n\n /**\n * Check if minimal logging is enabled\n */\n isMinimal(): boolean {\n return this.level === 'minimal'\n }\n\n /**\n * Check if logging is completely disabled\n */\n isDisabled(): boolean {\n return this.level === 'off'\n }\n}\n\n// Singleton instance\nexport const logger = new Logger()\n","/**\n * Span Name Inference for Auto-Tracing\n *\n * Provides intelligent span naming based on source code information\n * and configuration rules from instrumentation.yaml.\n */\n\nimport type { AutoInstrumentationConfig, SpanNamingRule } from '@atrim/instrument-core'\nimport * as path from 'path'\n\n/**\n * Source code information extracted from stack traces\n */\nexport interface SourceInfo {\n /** Function name (or 'anonymous') */\n function: string\n /** Full file path */\n file: string\n /** Line number */\n line: number\n /** Column number */\n column: number\n}\n\n/**\n * Template variables available for span naming\n */\nexport interface TemplateVariables {\n fiber_id: string\n function: string\n module: string\n file: string\n line: string\n operator: string\n [key: string]: string\n}\n\n/**\n * Compiled naming rule with pre-compiled regex patterns\n */\ninterface CompiledNamingRule {\n original: SpanNamingRule\n filePattern: RegExp | undefined\n functionPattern: RegExp | undefined\n modulePattern: RegExp | undefined\n}\n\n// Cache for compiled naming rules\nconst compiledRulesCache = new WeakMap<SpanNamingRule[], CompiledNamingRule[]>()\n\n/**\n * Compile naming rules for efficient matching\n */\nfunction compileNamingRules(rules: SpanNamingRule[]): CompiledNamingRule[] {\n const cached = compiledRulesCache.get(rules)\n if (cached) return cached\n\n const compiled: CompiledNamingRule[] = rules.map((rule) => ({\n original: rule,\n filePattern: rule.match.file ? new RegExp(rule.match.file) : undefined,\n functionPattern: rule.match.function ? new RegExp(rule.match.function) : undefined,\n modulePattern: rule.match.module ? new RegExp(rule.match.module) : undefined\n }))\n\n compiledRulesCache.set(rules, compiled)\n return compiled\n}\n\n/**\n * Extract module name from file path\n */\nfunction extractModuleName(filePath: string): string {\n const basename = path.basename(filePath, path.extname(filePath))\n // Remove common suffixes (both dot-separated and PascalCase)\n // e.g., \"user.service\" -> \"user\", \"UserService\" -> \"User\"\n return basename\n .replace(/\\.(service|controller|handler|util|helper|model|repo|repository)$/i, '')\n .replace(/(Service|Controller|Handler|Util|Helper|Model|Repo|Repository)$/i, '')\n}\n\n/**\n * Apply template variables to a span name pattern\n *\n * Supports:\n * - {fiber_id} - Fiber ID\n * - {function} - Function name\n * - {module} - Module name (filename without extension)\n * - {file} - Full file path\n * - {line} - Line number\n * - {operator} - Effect operator (if known)\n * - {match:field:N} - Captured regex group from match\n */\nfunction applyTemplate(\n template: string,\n variables: TemplateVariables,\n matchGroups?: Map<string, string[]>\n): string {\n let result = template\n\n // Replace simple variables\n for (const [key, value] of Object.entries(variables)) {\n result = result.replace(new RegExp(`\\\\{${key}\\\\}`, 'g'), value)\n }\n\n // Replace match groups: {match:field:N} where field is 'file', 'function', 'module'\n // and N is the capture group index\n if (matchGroups) {\n result = result.replace(\n /\\{match:(\\w+):(\\d+)\\}/g,\n (_fullMatch, field: string, index: string): string => {\n const groups = matchGroups.get(field)\n const idx = parseInt(index, 10)\n if (groups && groups[idx]) {\n return groups[idx]\n }\n return ''\n }\n )\n }\n\n return result\n}\n\n/**\n * Find matching naming rule for the given source info\n */\nfunction findMatchingRule(\n sourceInfo: SourceInfo | undefined,\n config: AutoInstrumentationConfig\n): { rule: CompiledNamingRule; matchGroups: Map<string, string[]> } | undefined {\n const rules = config.span_naming?.rules\n if (!rules || rules.length === 0) return undefined\n\n const compiledRules = compileNamingRules(rules)\n\n for (const rule of compiledRules) {\n const matchGroups = new Map<string, string[]>()\n let allMatched = true\n\n // Check file pattern\n if (rule.filePattern) {\n if (sourceInfo?.file) {\n const match = sourceInfo.file.match(rule.filePattern)\n if (match) {\n matchGroups.set('file', match.slice(1))\n } else {\n allMatched = false\n }\n } else {\n allMatched = false\n }\n }\n\n // Check function pattern\n if (rule.functionPattern && allMatched) {\n if (sourceInfo?.function) {\n const match = sourceInfo.function.match(rule.functionPattern)\n if (match) {\n matchGroups.set('function', match.slice(1))\n } else {\n allMatched = false\n }\n } else {\n allMatched = false\n }\n }\n\n // Check module pattern\n if (rule.modulePattern && allMatched) {\n const moduleName = sourceInfo?.file ? extractModuleName(sourceInfo.file) : ''\n if (moduleName) {\n const match = moduleName.match(rule.modulePattern)\n if (match) {\n matchGroups.set('module', match.slice(1))\n } else {\n allMatched = false\n }\n } else {\n allMatched = false\n }\n }\n\n if (allMatched) {\n return { rule, matchGroups }\n }\n }\n\n return undefined\n}\n\n/**\n * Infer a span name based on fiber ID, source info, and configuration\n *\n * Priority:\n * 1. Match against naming rules (first match wins)\n * 2. Use default template with source info if available\n * 3. Fallback to default template with fiber ID only\n *\n * @param fiberId - The fiber's numeric ID\n * @param sourceInfo - Optional source code information from stack trace\n * @param config - Auto-instrumentation configuration\n * @returns The inferred span name\n */\nexport function inferSpanName(\n fiberId: number,\n sourceInfo: SourceInfo | undefined,\n config: AutoInstrumentationConfig\n): string {\n // Build template variables\n const variables: TemplateVariables = {\n fiber_id: String(fiberId),\n function: sourceInfo?.function || 'anonymous',\n module: sourceInfo?.file ? extractModuleName(sourceInfo.file) : 'unknown',\n file: sourceInfo?.file || 'unknown',\n line: sourceInfo?.line ? String(sourceInfo.line) : '0',\n operator: 'gen' // Default operator, could be enhanced with more context\n }\n\n // Try to match a naming rule\n const match = findMatchingRule(sourceInfo, config)\n if (match) {\n return applyTemplate(match.rule.original.name, variables, match.matchGroups)\n }\n\n // Use default template\n const defaultTemplate = config.span_naming?.default || 'effect.fiber.{fiber_id}'\n return applyTemplate(defaultTemplate, variables)\n}\n\n/**\n * Sanitize a span name to be OpenTelemetry compliant\n *\n * - Replaces invalid characters with underscores\n * - Ensures name is not empty\n * - Truncates to reasonable length\n */\nexport function sanitizeSpanName(name: string): string {\n if (!name) return 'effect.fiber.unknown'\n\n // Replace invalid characters (keep alphanumeric, dot, underscore, dash)\n let sanitized = name.replace(/[^a-zA-Z0-9._-]/g, '_')\n\n // Collapse multiple underscores\n sanitized = sanitized.replace(/_+/g, '_')\n\n // Remove leading/trailing underscores\n sanitized = sanitized.replace(/^_+|_+$/g, '')\n\n // Ensure not empty\n if (!sanitized) return 'effect.fiber.unknown'\n\n // Truncate to reasonable length (OTel has no strict limit, but 256 is reasonable)\n if (sanitized.length > 256) {\n sanitized = sanitized.substring(0, 256)\n }\n\n return sanitized\n}\n","/**\n * Node.js configuration loader\n *\n * Provides configuration loading using native Node.js APIs (fs, fetch)\n * This module doesn't require Effect Platform, making it work without Effect installed.\n */\n\nimport { Effect } from 'effect'\nimport {\n type InstrumentationConfig,\n parseAndValidateConfig,\n defaultConfig\n} from '@atrim/instrument-core'\n\n/**\n * Load configuration from a file path using native Node.js fs\n */\nasync function loadFromFile(filePath: string): Promise<InstrumentationConfig> {\n const { readFile } = await import('fs/promises')\n const content = await readFile(filePath, 'utf-8')\n return parseAndValidateConfig(content)\n}\n\n/**\n * Load configuration from a URL using native fetch\n */\nasync function loadFromUrl(url: string): Promise<InstrumentationConfig> {\n const response = await fetch(url)\n if (!response.ok) {\n throw new Error(`Failed to fetch config from ${url}: ${response.statusText}`)\n }\n const content = await response.text()\n return parseAndValidateConfig(content)\n}\n\n/**\n * Load configuration from URI (file path or URL)\n *\n * @param uri - Configuration URI (file://, http://, https://, or relative path)\n * @returns Promise that resolves to validated configuration\n */\nexport async function loadConfig(\n uri: string,\n _options?: { cacheTimeout?: number }\n): Promise<InstrumentationConfig> {\n // Handle URL protocols\n if (uri.startsWith('http://') || uri.startsWith('https://')) {\n return loadFromUrl(uri)\n }\n\n // Handle file:// protocol\n if (uri.startsWith('file://')) {\n const filePath = uri.slice(7) // Remove 'file://'\n return loadFromFile(filePath)\n }\n\n // Treat as file path\n return loadFromFile(uri)\n}\n\n/**\n * Load configuration from inline content\n *\n * @param content - YAML string, JSON string, or plain object\n * @returns Promise that resolves to validated configuration\n */\nexport async function loadConfigFromInline(\n content: string | unknown\n): Promise<InstrumentationConfig> {\n return parseAndValidateConfig(content)\n}\n\n/**\n * Reset the config loader cache (no-op for native implementation)\n * @internal\n */\nexport function _resetConfigLoaderCache(): void {\n // No cache in native implementation\n}\n\n/**\n * Legacy options interface for backward compatibility\n */\nexport interface ConfigLoaderOptions {\n configPath?: string\n configUrl?: string\n config?: InstrumentationConfig\n cacheTimeout?: number\n}\n\n/**\n * Load configuration with priority order (backward compatible API)\n *\n * Priority order (highest to lowest):\n * 1. Explicit config object (options.config)\n * 2. Environment variable (ATRIM_INSTRUMENTATION_CONFIG)\n * 3. Explicit path/URL (options.configPath or options.configUrl)\n * 4. Project root file (./instrumentation.yaml)\n * 5. Default config (built-in defaults)\n *\n * @param options - Configuration options\n * @returns Promise that resolves to validated configuration\n */\nexport async function loadConfigWithOptions(\n options: ConfigLoaderOptions = {}\n): Promise<InstrumentationConfig> {\n // Priority 1: Explicit config object\n if (options.config) {\n return loadConfigFromInline(options.config)\n }\n\n // Priority 2: Environment variable\n const envConfigPath = process.env.ATRIM_INSTRUMENTATION_CONFIG\n if (envConfigPath) {\n return loadConfig(envConfigPath, options)\n }\n\n // Priority 3: Explicit options\n if (options.configUrl) {\n return loadConfig(options.configUrl, options)\n }\n if (options.configPath) {\n return loadConfig(options.configPath, options)\n }\n\n // Priority 4: Project root file\n const { existsSync } = await import('fs')\n const { join } = await import('path')\n\n const defaultPath = join(process.cwd(), 'instrumentation.yaml')\n if (existsSync(defaultPath)) {\n return loadConfig(defaultPath, options)\n }\n\n // Priority 5: Default config\n return defaultConfig\n}\n\n// ============================================================================\n// Effect-Based API (for Effect users)\n// ============================================================================\n\n/**\n * Load configuration from URI (Effect version)\n */\nexport const loadConfigEffect = (\n uri: string,\n options?: { cacheTimeout?: number }\n): Effect.Effect<InstrumentationConfig, Error> =>\n Effect.tryPromise({\n try: () => loadConfig(uri, options),\n catch: (error) => (error instanceof Error ? error : new Error(String(error)))\n })\n\n/**\n * Load configuration from inline content (Effect version)\n */\nexport const loadConfigFromInlineEffect = (\n content: string | unknown\n): Effect.Effect<InstrumentationConfig, Error> =>\n Effect.tryPromise({\n try: () => loadConfigFromInline(content),\n catch: (error) => (error instanceof Error ? error : new Error(String(error)))\n })\n\n/**\n * Load configuration with priority order (Effect version)\n */\nexport const loadConfigWithOptionsEffect = (\n options: ConfigLoaderOptions = {}\n): Effect.Effect<InstrumentationConfig, Error> =>\n Effect.tryPromise({\n try: () => loadConfigWithOptions(options),\n catch: (error) => (error instanceof Error ? error : new Error(String(error)))\n })\n","/**\n * Auto-Tracing Configuration Loader\n *\n * Loads auto-tracing configuration from instrumentation.yaml\n * and provides a typed Effect service for accessing it.\n */\n\nimport { Effect, Context, Layer } from 'effect'\nimport {\n type AutoInstrumentationConfig,\n type InstrumentationConfig,\n type ExporterConfig,\n AutoInstrumentationConfigSchema,\n defaultConfig,\n logger\n} from '@atrim/instrument-core'\nimport { loadConfigWithOptions, type ConfigLoaderOptions } from '../../../core/config-loader.js'\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Re-export config type for convenience\n */\nexport type { AutoInstrumentationConfig }\n\n/**\n * Default auto-tracing configuration when not specified in instrumentation.yaml\n */\nexport const defaultAutoTracingConfig: AutoInstrumentationConfig = {\n enabled: false,\n granularity: 'fiber',\n span_naming: {\n default: 'effect.fiber.{fiber_id}',\n infer_from_source: true,\n rules: []\n },\n filter: {\n include: [],\n exclude: []\n },\n performance: {\n sampling_rate: 1.0,\n min_duration: '0ms',\n max_concurrent: 0\n },\n metadata: {\n fiber_info: true,\n source_location: true,\n parent_fiber: true\n }\n}\n\n// ============================================================================\n// Service Definition\n// ============================================================================\n\n/**\n * Service tag for auto-tracing configuration\n */\nexport class AutoTracingConfig extends Context.Tag('AutoTracingConfig')<\n AutoTracingConfig,\n AutoInstrumentationConfig\n>() {}\n\n// ============================================================================\n// Configuration Loading\n// ============================================================================\n\n/**\n * Load auto-tracing configuration from instrumentation.yaml\n *\n * Returns the config from effect.auto_instrumentation section,\n * or defaults if not specified.\n */\nexport const loadAutoTracingConfig = (\n options?: ConfigLoaderOptions\n): Effect.Effect<AutoInstrumentationConfig, never, never> =>\n Effect.gen(function* () {\n // Load full config\n const config = yield* Effect.tryPromise({\n try: () => loadConfigWithOptions(options),\n catch: (error) => {\n logger.log(`@atrim/auto-trace: Failed to load config: ${error}`)\n return error\n }\n }).pipe(Effect.catchAll(() => Effect.succeed(null)))\n\n if (!config) {\n logger.log('@atrim/auto-trace: No config found, using defaults')\n return defaultAutoTracingConfig\n }\n\n // Extract auto_instrumentation section\n const autoConfig = config.effect?.auto_instrumentation\n\n if (!autoConfig) {\n logger.log('@atrim/auto-trace: No auto_instrumentation config, using defaults')\n return defaultAutoTracingConfig\n }\n\n // Validate and merge with defaults\n const parsed = AutoInstrumentationConfigSchema.safeParse(autoConfig)\n if (!parsed.success) {\n logger.log(`@atrim/auto-trace: Invalid config, using defaults: ${parsed.error.message}`)\n return defaultAutoTracingConfig\n }\n\n logger.log('@atrim/auto-trace: Loaded config from instrumentation.yaml')\n return parsed.data\n })\n\n/**\n * Load auto-tracing configuration synchronously from cache or default\n *\n * Note: This is a synchronous fallback when Effect runtime isn't available.\n * Prefer loadAutoTracingConfig() when possible.\n */\nexport const loadAutoTracingConfigSync = (): AutoInstrumentationConfig => {\n // For synchronous loading, we can only return defaults\n // The async version should be used for actual config loading\n return defaultAutoTracingConfig\n}\n\n// ============================================================================\n// Layer\n// ============================================================================\n\n/**\n * Layer that provides auto-tracing configuration\n */\nexport const AutoTracingConfigLive = Layer.effect(AutoTracingConfig, loadAutoTracingConfig())\n\n/**\n * Layer that provides custom auto-tracing configuration\n */\nexport const AutoTracingConfigLayer = (\n config: AutoInstrumentationConfig\n): Layer.Layer<AutoTracingConfig> => Layer.succeed(AutoTracingConfig, config)\n\n// ============================================================================\n// Full Config Loading\n// ============================================================================\n\n/**\n * Load the full instrumentation config from instrumentation.yaml\n *\n * Returns the complete config including exporter settings for setting up\n * the full auto-instrumentation pipeline.\n */\nexport const loadFullConfig = (\n options?: ConfigLoaderOptions\n): Effect.Effect<InstrumentationConfig, never, never> =>\n Effect.gen(function* () {\n const config = yield* Effect.tryPromise({\n try: () => loadConfigWithOptions(options),\n catch: (error) => {\n logger.log(`@atrim/auto-trace: Failed to load config: ${error}`)\n return error\n }\n }).pipe(Effect.catchAll(() => Effect.succeed(null)))\n\n if (!config) {\n logger.log('@atrim/auto-trace: No config found, using defaults')\n return defaultConfig\n }\n\n return config\n })\n\n/**\n * Default exporter configuration\n */\nexport const defaultExporterConfig: ExporterConfig = {\n type: 'otlp',\n processor: 'batch',\n batch: {\n scheduled_delay_millis: 1000,\n max_export_batch_size: 100\n }\n}\n","/**\n * Auto-Tracing Supervisor for Effect-TS\n *\n * Provides automatic tracing of all Effect fibers without manual Effect.withSpan() calls.\n * Uses Effect's Supervisor API to intercept fiber creation/termination and create\n * OpenTelemetry spans automatically.\n *\n * @example\n * ```typescript\n * import { AutoTracingLive } from '@atrim/instrument-node/effect/auto'\n *\n * const program = Effect.gen(function* () {\n * yield* doWork() // Automatically traced!\n * }).pipe(Effect.provide(AutoTracingLive))\n * ```\n */\n\nimport {\n Supervisor,\n Effect,\n Layer,\n FiberRef,\n FiberRefs,\n Context,\n Option,\n Exit,\n Fiber\n} from 'effect'\nimport * as OtelApi from '@opentelemetry/api'\nimport {\n BatchSpanProcessor,\n SimpleSpanProcessor,\n ConsoleSpanExporter,\n BasicTracerProvider\n} from '@opentelemetry/sdk-trace-base'\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'\nimport { resourceFromAttributes } from '@opentelemetry/resources'\nimport { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions'\nimport type { AutoInstrumentationConfig, ExporterConfig } from '@atrim/instrument-core'\nimport { logger } from '@atrim/instrument-core'\nimport { inferSpanName, type SourceInfo } from './naming.js'\nimport { loadAutoTracingConfig, loadFullConfig } from './config.js'\n\n// ============================================================================\n// FiberRefs for opt-out and name override\n// ============================================================================\n\n/**\n * FiberRef to enable/disable auto-tracing for specific fibers\n * Use withoutAutoTracing() to disable\n */\nexport const AutoTracingEnabled = FiberRef.unsafeMake<boolean>(true)\n\n/**\n * FiberRef to override auto-generated span name\n * Use setSpanName() to override\n */\nexport const AutoTracingSpanName = FiberRef.unsafeMake<Option.Option<string>>(Option.none())\n\n// ============================================================================\n// AutoTracingSupervisor\n// ============================================================================\n\n/**\n * Supervisor that automatically creates OpenTelemetry spans for all Effect fibers\n *\n * This supervisor intercepts fiber creation and termination, creating spans\n * based on configuration from instrumentation.yaml.\n */\nexport class AutoTracingSupervisor extends Supervisor.AbstractSupervisor<void> {\n // WeakMap to associate fibers with their OTel spans\n private readonly fiberSpans = new WeakMap<Fiber.RuntimeFiber<unknown, unknown>, OtelApi.Span>()\n\n // WeakMap for fiber start times (for min_duration filtering)\n private readonly fiberStartTimes = new WeakMap<Fiber.RuntimeFiber<unknown, unknown>, bigint>()\n\n // OpenTelemetry tracer - lazily initialized\n private _tracer: OtelApi.Tracer | null = null\n\n // Compiled filter patterns\n private readonly includePatterns: RegExp[]\n private readonly excludePatterns: RegExp[]\n\n // Active fiber count (for max_concurrent limiting)\n private activeFiberCount = 0\n\n // Root span for parent context (set by withAutoTracing)\n private _rootSpan: OtelApi.Span | null = null\n\n constructor(private readonly config: AutoInstrumentationConfig) {\n super()\n\n // Compile filter patterns\n this.includePatterns = (config.filter?.include || []).map((p) => new RegExp(p))\n this.excludePatterns = (config.filter?.exclude || []).map((p) => new RegExp(p))\n\n logger.log('@atrim/auto-trace: Supervisor initialized')\n logger.log(` Granularity: ${config.granularity || 'fiber'}`)\n logger.log(` Sampling rate: ${config.performance?.sampling_rate ?? 1.0}`)\n logger.log(` Infer from source: ${config.span_naming?.infer_from_source ?? true}`)\n }\n\n /**\n * Set the root span for parent context propagation\n */\n setRootSpan(span: OtelApi.Span): void {\n this._rootSpan = span\n }\n\n /**\n * Get the tracer lazily - this allows time for the NodeSdk layer to register the global provider\n */\n private get tracer(): OtelApi.Tracer {\n if (!this._tracer) {\n this._tracer = OtelApi.trace.getTracer('@atrim/auto-trace', '1.0.0')\n }\n return this._tracer\n }\n\n /**\n * Returns the current value (void for this supervisor)\n */\n override get value(): Effect.Effect<void> {\n return Effect.void\n }\n\n /**\n * Called when a fiber starts executing\n */\n override onStart<A, E, R>(\n _context: Context.Context<R>,\n _effect: Effect.Effect<A, E, R>,\n parent: Option.Option<Fiber.RuntimeFiber<unknown, unknown>>,\n fiber: Fiber.RuntimeFiber<A, E>\n ): void {\n // Check if auto-tracing is enabled for this fiber\n // Note: FiberRef access in supervisor hooks must be synchronous\n const fiberRefsValue = fiber.getFiberRefs()\n const enabled = FiberRefs.getOrDefault(fiberRefsValue, AutoTracingEnabled)\n if (!enabled) {\n return\n }\n\n // Check sampling\n const samplingRate = this.config.performance?.sampling_rate ?? 1.0\n if (samplingRate < 1.0 && Math.random() > samplingRate) {\n return\n }\n\n // Check max concurrent\n const maxConcurrent = this.config.performance?.max_concurrent ?? 0\n if (maxConcurrent > 0 && this.activeFiberCount >= maxConcurrent) {\n return\n }\n\n // Check for span name override\n const nameOverride = FiberRefs.getOrDefault(fiberRefsValue, AutoTracingSpanName)\n\n // Parse source info for span naming and attributes\n const sourceInfo = this.config.span_naming?.infer_from_source\n ? this.parseStackTrace()\n : undefined\n\n // Infer span name\n let spanName: string\n if (Option.isSome(nameOverride)) {\n spanName = nameOverride.value\n } else {\n spanName = inferSpanName(fiber.id().id, sourceInfo, this.config)\n }\n\n // Check filter patterns\n if (!this.shouldTrace(spanName)) {\n return\n }\n\n // Get parent span context and fiber ID if available\n // Use ROOT_CONTEXT as base since Effect's fiber scheduler runs in a different async context\n let parentContext: OtelApi.Context = OtelApi.ROOT_CONTEXT\n let parentFiberId: number | undefined\n\n if (Option.isSome(parent)) {\n // Fiber has a parent fiber - try to find its span\n parentFiberId = parent.value.id().id\n const parentSpan = this.fiberSpans.get(parent.value)\n if (parentSpan) {\n parentContext = OtelApi.trace.setSpan(OtelApi.ROOT_CONTEXT, parentSpan)\n } else if (this._rootSpan) {\n // Parent fiber exists but no span found - fall back to root span\n parentContext = OtelApi.trace.setSpan(OtelApi.ROOT_CONTEXT, this._rootSpan)\n }\n } else if (this._rootSpan) {\n // No fiber parent, but we have a root span - use it as the parent\n parentContext = OtelApi.trace.setSpan(OtelApi.ROOT_CONTEXT, this._rootSpan)\n }\n\n // Create the span with full attributes\n const span = this.tracer.startSpan(\n spanName,\n {\n kind: OtelApi.SpanKind.INTERNAL,\n attributes: this.getInitialAttributes(fiber, sourceInfo, parentFiberId)\n },\n parentContext\n )\n\n // Store span and start time\n this.fiberSpans.set(fiber as Fiber.RuntimeFiber<unknown, unknown>, span)\n this.fiberStartTimes.set(fiber as Fiber.RuntimeFiber<unknown, unknown>, process.hrtime.bigint())\n this.activeFiberCount++\n }\n\n /**\n * Called when a fiber completes (success or failure)\n */\n override onEnd<A, E>(exit: Exit.Exit<A, E>, fiber: Fiber.RuntimeFiber<A, E>): void {\n const span = this.fiberSpans.get(fiber as Fiber.RuntimeFiber<unknown, unknown>)\n if (!span) {\n return\n }\n\n // Check min_duration filtering\n const startTime = this.fiberStartTimes.get(fiber as Fiber.RuntimeFiber<unknown, unknown>)\n if (startTime) {\n const duration = process.hrtime.bigint() - startTime\n const minDuration = this.parseMinDuration(this.config.performance?.min_duration)\n if (minDuration > 0 && duration < minDuration) {\n // Drop span if too short\n // Note: We can't actually \"drop\" a started span, but we can avoid ending it properly\n // In practice, this means the span will have no end time which is not ideal\n // A better approach would be to delay span creation, but that's more complex\n this.fiberSpans.delete(fiber as Fiber.RuntimeFiber<unknown, unknown>)\n this.fiberStartTimes.delete(fiber as Fiber.RuntimeFiber<unknown, unknown>)\n this.activeFiberCount--\n return\n }\n }\n\n // Set span status based on exit\n if (Exit.isSuccess(exit)) {\n span.setStatus({ code: OtelApi.SpanStatusCode.OK })\n } else {\n // Set error status\n span.setStatus({\n code: OtelApi.SpanStatusCode.ERROR,\n message: 'Fiber failed'\n })\n span.setAttribute('effect.fiber.failed', true)\n }\n\n // End the span\n span.end()\n\n // Cleanup\n this.fiberSpans.delete(fiber as Fiber.RuntimeFiber<unknown, unknown>)\n this.fiberStartTimes.delete(fiber as Fiber.RuntimeFiber<unknown, unknown>)\n this.activeFiberCount--\n }\n\n /**\n * Check if a span name should be traced based on filter patterns\n */\n private shouldTrace(spanName: string): boolean {\n // Check exclude patterns first (they take precedence)\n for (const pattern of this.excludePatterns) {\n if (pattern.test(spanName)) {\n return false\n }\n }\n\n // If include patterns are specified, span must match at least one\n if (this.includePatterns.length > 0) {\n for (const pattern of this.includePatterns) {\n if (pattern.test(spanName)) {\n return true\n }\n }\n return false\n }\n\n // No include patterns = trace everything not excluded\n return true\n }\n\n /**\n * Get initial span attributes for a fiber\n */\n private getInitialAttributes(\n fiber: Fiber.RuntimeFiber<unknown, unknown>,\n sourceInfo: SourceInfo | undefined,\n parentFiberId: number | undefined\n ): OtelApi.Attributes {\n const attrs: OtelApi.Attributes = {\n 'effect.auto_traced': true\n }\n\n // Add fiber info\n if (this.config.metadata?.fiber_info !== false) {\n attrs['effect.fiber.id'] = fiber.id().id\n }\n\n // Add source location info\n if (this.config.metadata?.source_location !== false && sourceInfo) {\n attrs['code.function'] = sourceInfo.function\n attrs['code.filepath'] = sourceInfo.file\n attrs['code.lineno'] = sourceInfo.line\n attrs['code.column'] = sourceInfo.column\n }\n\n // Add parent fiber info\n if (this.config.metadata?.parent_fiber !== false && parentFiberId !== undefined) {\n attrs['effect.fiber.parent_id'] = parentFiberId\n }\n\n return attrs\n }\n\n /**\n * Parse stack trace to get source info\n */\n private parseStackTrace(): SourceInfo | undefined {\n const stack = new Error().stack\n if (!stack) return undefined\n\n const lines = stack.split('\\n')\n // Skip Error, parseStackTrace, onStart, Effect internals\n // Look for first line that's not from effect or this module\n for (let i = 3; i < lines.length; i++) {\n const line = lines[i]\n if (line === undefined) continue\n\n if (\n !line.includes('node_modules/effect') &&\n !line.includes('@atrim/instrument') &&\n !line.includes('auto/supervisor')\n ) {\n // Parse line like \" at functionName (file:line:col)\"\n const match = line.match(/at\\s+(?:(.+?)\\s+)?\\(?(.+?):(\\d+):(\\d+)\\)?/)\n if (match) {\n const [, funcName, filePath, lineNum, colNum] = match\n return {\n function: funcName ?? 'anonymous',\n file: filePath ?? 'unknown',\n line: parseInt(lineNum ?? '0', 10),\n column: parseInt(colNum ?? '0', 10)\n }\n }\n }\n }\n\n return undefined\n }\n\n /**\n * Parse min_duration string to nanoseconds\n */\n private parseMinDuration(duration: string | undefined): bigint {\n if (!duration || duration === '0ms') return BigInt(0)\n\n const match = duration.match(/^(\\d+)\\s*(ms|millis|s|sec|seconds|us|micros)?$/i)\n if (!match) return BigInt(0)\n\n const value = parseInt(match[1] ?? '0', 10)\n const unit = (match[2] ?? 'ms').toLowerCase()\n\n switch (unit) {\n case 'us':\n case 'micros':\n return BigInt(value) * BigInt(1000)\n case 'ms':\n case 'millis':\n return BigInt(value) * BigInt(1000000)\n case 's':\n case 'sec':\n case 'seconds':\n return BigInt(value) * BigInt(1000000000)\n default:\n return BigInt(value) * BigInt(1000000) // Default to ms\n }\n }\n}\n\n// ============================================================================\n// Layers and factory functions\n// ============================================================================\n\n/**\n * Create a custom AutoTracingSupervisor with the given config\n */\nexport const createAutoTracingSupervisor = (\n config: AutoInstrumentationConfig\n): AutoTracingSupervisor => {\n return new AutoTracingSupervisor(config)\n}\n\n/**\n * Layer that provides auto-tracing with custom configuration\n *\n * @example\n * ```typescript\n * const CustomAutoTracing = createAutoTracingLayer({\n * enabled: true,\n * span_naming: {\n * default: 'app.{function}',\n * rules: [{ match: { file: 'src/services/.*' }, name: 'service.{function}' }]\n * }\n * })\n * ```\n */\nexport const createAutoTracingLayer = (options?: {\n config?: AutoInstrumentationConfig\n}): Layer.Layer<never> => {\n return Layer.unwrapEffect(\n Effect.gen(function* () {\n // Load config from options or instrumentation.yaml\n const config = options?.config ?? (yield* loadAutoTracingConfig())\n\n if (!config.enabled) {\n logger.log('@atrim/auto-trace: Auto-tracing disabled via config')\n return Layer.empty\n }\n\n // Create supervisor\n const supervisor = createAutoTracingSupervisor(config)\n\n // Return layer that adds the supervisor\n return Supervisor.addSupervisor(supervisor)\n })\n )\n}\n\n/**\n * Wrap an Effect with auto-tracing supervision\n *\n * This creates a span for the main effect AND supervises all child fibers.\n * Use this when you need to ensure all fibers in an effect are traced.\n *\n * @example\n * ```typescript\n * const program = Effect.gen(function* () {\n * yield* doWork() // Automatically traced!\n * })\n *\n * const tracedProgram = withAutoTracing(program, { enabled: true, ... })\n * Effect.runPromise(tracedProgram)\n * ```\n */\nexport const withAutoTracing = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n config: AutoInstrumentationConfig,\n mainSpanName?: string\n): Effect.Effect<A, E, R> => {\n if (!config.enabled) {\n logger.log('@atrim/auto-trace: Auto-tracing disabled via config')\n return effect\n }\n\n const supervisor = createAutoTracingSupervisor(config)\n\n // Get the tracer\n const tracer = OtelApi.trace.getTracer('@atrim/auto-trace', '1.0.0')\n\n // Determine span name for main effect\n const spanName = mainSpanName ?? inferSpanName(0, undefined, config)\n\n // Start span for main effect\n const mainSpan = tracer.startSpan(spanName, {\n kind: OtelApi.SpanKind.INTERNAL,\n attributes: {\n 'effect.auto_traced': true,\n 'effect.fiber.id': 0, // Main fiber\n 'effect.main_fiber': true\n }\n })\n\n // Set the root span on the supervisor so child fibers use it as parent\n supervisor.setRootSpan(mainSpan)\n\n // Wrap the effect to handle the main span lifecycle\n return Effect.acquireUseRelease(\n // Acquire: return the span (already started)\n Effect.succeed(mainSpan),\n // Use: run the supervised effect\n () => Effect.supervised(supervisor)(effect),\n // Release: end the span\n (span, exit) =>\n Effect.sync(() => {\n if (Exit.isSuccess(exit)) {\n span.setStatus({ code: OtelApi.SpanStatusCode.OK })\n } else {\n span.setStatus({\n code: OtelApi.SpanStatusCode.ERROR,\n message: 'Effect failed'\n })\n }\n span.end()\n })\n )\n}\n\n/**\n * Zero-config auto-tracing layer\n *\n * Loads configuration from instrumentation.yaml and automatically traces\n * all Effect fibers based on the configuration.\n *\n * @example\n * ```typescript\n * import { AutoTracingLive } from '@atrim/instrument-node/effect/auto'\n *\n * const program = Effect.gen(function* () {\n * yield* doWork() // Automatically traced!\n * }).pipe(Effect.provide(AutoTracingLive))\n * ```\n */\nexport const AutoTracingLive: Layer.Layer<never> = createAutoTracingLayer()\n\n// ============================================================================\n// Opt-out utilities\n// ============================================================================\n\n/**\n * Disable auto-tracing for a specific Effect\n *\n * @example\n * ```typescript\n * const program = Effect.gen(function* () {\n * yield* publicWork() // Traced\n * yield* withoutAutoTracing(internalWork()) // NOT traced\n * })\n * ```\n */\nexport const withoutAutoTracing = <A, E, R>(\n effect: Effect.Effect<A, E, R>\n): Effect.Effect<A, E, R> => effect.pipe(Effect.locally(AutoTracingEnabled, false))\n\n/**\n * Override the auto-generated span name for a specific Effect\n *\n * @example\n * ```typescript\n * const program = Effect.gen(function* () {\n * yield* setSpanName('custom.operation.name')(myEffect)\n * })\n * ```\n */\nexport const setSpanName =\n (name: string) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>\n effect.pipe(Effect.locally(AutoTracingSpanName, Option.some(name)))\n\n// ============================================================================\n// Full Auto-Instrumentation Layer (Exporter + Supervisor)\n// ============================================================================\n\n/**\n * Create and register a global TracerProvider based on exporter config\n *\n * Unlike @effect/opentelemetry's NodeSdk.layer(), this function creates a\n * standard OTel BasicTracerProvider and registers it globally so that\n * the AutoTracingSupervisor can access it via the OTel API.\n */\nconst createExporterLayer = (\n exporterConfig: ExporterConfig | undefined,\n serviceName: string,\n serviceVersion: string\n): Layer.Layer<never> => {\n const config = exporterConfig ?? {\n type: 'otlp' as const,\n processor: 'batch' as const,\n batch: {\n scheduled_delay_millis: 1000,\n max_export_batch_size: 100\n }\n }\n\n // Handle 'none' type - no exporter\n if (config.type === 'none') {\n logger.log('@atrim/auto-trace: Exporter type is \"none\", no spans will be exported')\n return Layer.empty\n }\n\n // Create the span exporter\n const createSpanExporter = () => {\n if (config.type === 'console') {\n logger.log('@atrim/auto-trace: Using ConsoleSpanExporter')\n return new ConsoleSpanExporter()\n }\n\n // Default to OTLP\n const endpoint =\n config.endpoint || process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318'\n logger.log(`@atrim/auto-trace: Using OTLPTraceExporter (${endpoint})`)\n const exporterConfig: { url: string; headers?: Record<string, string> } = {\n url: `${endpoint}/v1/traces`\n }\n if (config.headers) {\n exporterConfig.headers = config.headers\n logger.log(`@atrim/auto-trace: Using custom headers: ${Object.keys(config.headers).join(', ')}`)\n }\n return new OTLPTraceExporter(exporterConfig)\n }\n\n // Create the span processor\n const createSpanProcessor = () => {\n const exporter = createSpanExporter()\n\n if (config.processor === 'simple' || config.type === 'console') {\n logger.log('@atrim/auto-trace: Using SimpleSpanProcessor')\n return new SimpleSpanProcessor(exporter)\n }\n\n // Default to batch processor\n const batchConfig = config.batch ?? {\n scheduled_delay_millis: 1000,\n max_export_batch_size: 100\n }\n logger.log('@atrim/auto-trace: Using BatchSpanProcessor')\n return new BatchSpanProcessor(exporter, {\n scheduledDelayMillis: batchConfig.scheduled_delay_millis,\n maxExportBatchSize: batchConfig.max_export_batch_size\n })\n }\n\n // Create a Layer that sets up the global TracerProvider\n // This uses Effect.sync to run setup synchronously when the layer is built\n return Layer.effectDiscard(\n Effect.sync(() => {\n // Create the provider with resource info\n const provider = new BasicTracerProvider({\n resource: resourceFromAttributes({\n [ATTR_SERVICE_NAME]: serviceName,\n [ATTR_SERVICE_VERSION]: serviceVersion\n }),\n spanProcessors: [createSpanProcessor()]\n })\n\n // Register as the global tracer provider using OTel API\n // (BasicTracerProvider.register() was removed in v2, use OTel API directly)\n OtelApi.trace.setGlobalTracerProvider(provider)\n logger.log('@atrim/auto-trace: Global TracerProvider registered')\n\n // Return cleanup function (not used by Layer.effectDiscard but good practice)\n return () => {\n provider.shutdown().catch((err) => {\n logger.log(`@atrim/auto-trace: Error shutting down provider: ${err}`)\n })\n }\n })\n )\n}\n\n/**\n * Create a fully YAML-driven auto-instrumentation layer\n *\n * This layer reads all configuration from instrumentation.yaml including:\n * - Exporter configuration (type, endpoint, processor)\n * - Auto-tracing configuration (naming rules, filters, performance)\n * - Service metadata (name, version)\n *\n * @example\n * ```typescript\n * import { createFullAutoTracingLayer } from '@atrim/instrument-node/effect/auto'\n *\n * // Everything configured via instrumentation.yaml - no code config needed!\n * const AppLive = createFullAutoTracingLayer()\n *\n * Effect.runPromise(program.pipe(Effect.provide(AppLive)))\n * ```\n */\nexport const createFullAutoTracingLayer = (): Layer.Layer<never> => {\n return Layer.unwrapEffect(\n Effect.gen(function* () {\n // Load full config from instrumentation.yaml\n const config = yield* loadFullConfig()\n\n // Get service info from env or defaults\n const serviceName = process.env.OTEL_SERVICE_NAME || 'effect-service'\n const serviceVersion = process.env.npm_package_version || '1.0.0'\n\n // Get auto-tracing config\n const autoConfig = config.effect?.auto_instrumentation\n\n // If auto-instrumentation is disabled, return empty layer\n if (!autoConfig?.enabled) {\n logger.log('@atrim/auto-trace: Auto-instrumentation disabled via config')\n return Layer.empty\n }\n\n // Get exporter config\n const exporterConfig = config.effect?.exporter_config\n\n // Log configuration\n logger.log('@atrim/auto-trace: Full auto-instrumentation enabled')\n logger.log(` Service: ${serviceName}`)\n logger.log(` Exporter: ${exporterConfig?.type ?? 'otlp'}`)\n\n // Create exporter layer\n const exporterLayer = createExporterLayer(exporterConfig, serviceName, serviceVersion)\n\n // Create supervisor\n const supervisor = createAutoTracingSupervisor(autoConfig)\n const supervisorLayer = Supervisor.addSupervisor(supervisor)\n\n // Merge both layers\n return Layer.mergeAll(exporterLayer, supervisorLayer)\n })\n )\n}\n\n/**\n * Fully YAML-driven auto-instrumentation layer\n *\n * This is the recommended way to use auto-instrumentation. All configuration\n * comes from instrumentation.yaml - no code configuration needed.\n *\n * @example\n * ```yaml\n * # instrumentation.yaml\n * effect:\n * auto_instrumentation:\n * enabled: true\n * span_naming:\n * default: \"effect.{function}\"\n * rules:\n * - match: { function: \"internal.*\" }\n * name: \"internal.{function}\"\n * filter:\n * exclude:\n * - \"^internal\\\\.\"\n * exporter_config:\n * type: otlp # or 'console' for dev\n * endpoint: http://localhost:4318\n * processor: batch # or 'simple' for dev\n * ```\n *\n * @example\n * ```typescript\n * import { FullAutoTracingLive } from '@atrim/instrument-node/effect/auto'\n *\n * // Just provide the layer - everything else from YAML!\n * Effect.runPromise(program.pipe(Effect.provide(FullAutoTracingLive)))\n * ```\n */\nexport const FullAutoTracingLive: Layer.Layer<never> = createFullAutoTracingLayer()\n"]}
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { Layer, Supervisor, Effect, Context, Option, Fiber, Exit, FiberRef } from 'effect';
|
|
2
|
+
import * as OtelApi from '@opentelemetry/api';
|
|
3
|
+
import { AutoInstrumentationConfig, InstrumentationConfig } from '@atrim/instrument-core';
|
|
4
|
+
export { AutoInstrumentationConfig } from '@atrim/instrument-core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Auto-Tracing Supervisor for Effect-TS
|
|
8
|
+
*
|
|
9
|
+
* Provides automatic tracing of all Effect fibers without manual Effect.withSpan() calls.
|
|
10
|
+
* Uses Effect's Supervisor API to intercept fiber creation/termination and create
|
|
11
|
+
* OpenTelemetry spans automatically.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { AutoTracingLive } from '@atrim/instrument-node/effect/auto'
|
|
16
|
+
*
|
|
17
|
+
* const program = Effect.gen(function* () {
|
|
18
|
+
* yield* doWork() // Automatically traced!
|
|
19
|
+
* }).pipe(Effect.provide(AutoTracingLive))
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* FiberRef to enable/disable auto-tracing for specific fibers
|
|
25
|
+
* Use withoutAutoTracing() to disable
|
|
26
|
+
*/
|
|
27
|
+
declare const AutoTracingEnabled: FiberRef.FiberRef<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* FiberRef to override auto-generated span name
|
|
30
|
+
* Use setSpanName() to override
|
|
31
|
+
*/
|
|
32
|
+
declare const AutoTracingSpanName: FiberRef.FiberRef<Option.Option<string>>;
|
|
33
|
+
/**
|
|
34
|
+
* Supervisor that automatically creates OpenTelemetry spans for all Effect fibers
|
|
35
|
+
*
|
|
36
|
+
* This supervisor intercepts fiber creation and termination, creating spans
|
|
37
|
+
* based on configuration from instrumentation.yaml.
|
|
38
|
+
*/
|
|
39
|
+
declare class AutoTracingSupervisor extends Supervisor.AbstractSupervisor<void> {
|
|
40
|
+
private readonly config;
|
|
41
|
+
private readonly fiberSpans;
|
|
42
|
+
private readonly fiberStartTimes;
|
|
43
|
+
private _tracer;
|
|
44
|
+
private readonly includePatterns;
|
|
45
|
+
private readonly excludePatterns;
|
|
46
|
+
private activeFiberCount;
|
|
47
|
+
private _rootSpan;
|
|
48
|
+
constructor(config: AutoInstrumentationConfig);
|
|
49
|
+
/**
|
|
50
|
+
* Set the root span for parent context propagation
|
|
51
|
+
*/
|
|
52
|
+
setRootSpan(span: OtelApi.Span): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get the tracer lazily - this allows time for the NodeSdk layer to register the global provider
|
|
55
|
+
*/
|
|
56
|
+
private get tracer();
|
|
57
|
+
/**
|
|
58
|
+
* Returns the current value (void for this supervisor)
|
|
59
|
+
*/
|
|
60
|
+
get value(): Effect.Effect<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Called when a fiber starts executing
|
|
63
|
+
*/
|
|
64
|
+
onStart<A, E, R>(_context: Context.Context<R>, _effect: Effect.Effect<A, E, R>, parent: Option.Option<Fiber.RuntimeFiber<unknown, unknown>>, fiber: Fiber.RuntimeFiber<A, E>): void;
|
|
65
|
+
/**
|
|
66
|
+
* Called when a fiber completes (success or failure)
|
|
67
|
+
*/
|
|
68
|
+
onEnd<A, E>(exit: Exit.Exit<A, E>, fiber: Fiber.RuntimeFiber<A, E>): void;
|
|
69
|
+
/**
|
|
70
|
+
* Check if a span name should be traced based on filter patterns
|
|
71
|
+
*/
|
|
72
|
+
private shouldTrace;
|
|
73
|
+
/**
|
|
74
|
+
* Get initial span attributes for a fiber
|
|
75
|
+
*/
|
|
76
|
+
private getInitialAttributes;
|
|
77
|
+
/**
|
|
78
|
+
* Parse stack trace to get source info
|
|
79
|
+
*/
|
|
80
|
+
private parseStackTrace;
|
|
81
|
+
/**
|
|
82
|
+
* Parse min_duration string to nanoseconds
|
|
83
|
+
*/
|
|
84
|
+
private parseMinDuration;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Create a custom AutoTracingSupervisor with the given config
|
|
88
|
+
*/
|
|
89
|
+
declare const createAutoTracingSupervisor: (config: AutoInstrumentationConfig) => AutoTracingSupervisor;
|
|
90
|
+
/**
|
|
91
|
+
* Layer that provides auto-tracing with custom configuration
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const CustomAutoTracing = createAutoTracingLayer({
|
|
96
|
+
* enabled: true,
|
|
97
|
+
* span_naming: {
|
|
98
|
+
* default: 'app.{function}',
|
|
99
|
+
* rules: [{ match: { file: 'src/services/.*' }, name: 'service.{function}' }]
|
|
100
|
+
* }
|
|
101
|
+
* })
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
declare const createAutoTracingLayer: (options?: {
|
|
105
|
+
config?: AutoInstrumentationConfig;
|
|
106
|
+
}) => Layer.Layer<never>;
|
|
107
|
+
/**
|
|
108
|
+
* Wrap an Effect with auto-tracing supervision
|
|
109
|
+
*
|
|
110
|
+
* This creates a span for the main effect AND supervises all child fibers.
|
|
111
|
+
* Use this when you need to ensure all fibers in an effect are traced.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const program = Effect.gen(function* () {
|
|
116
|
+
* yield* doWork() // Automatically traced!
|
|
117
|
+
* })
|
|
118
|
+
*
|
|
119
|
+
* const tracedProgram = withAutoTracing(program, { enabled: true, ... })
|
|
120
|
+
* Effect.runPromise(tracedProgram)
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
declare const withAutoTracing: <A, E, R>(effect: Effect.Effect<A, E, R>, config: AutoInstrumentationConfig, mainSpanName?: string) => Effect.Effect<A, E, R>;
|
|
124
|
+
/**
|
|
125
|
+
* Zero-config auto-tracing layer
|
|
126
|
+
*
|
|
127
|
+
* Loads configuration from instrumentation.yaml and automatically traces
|
|
128
|
+
* all Effect fibers based on the configuration.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* import { AutoTracingLive } from '@atrim/instrument-node/effect/auto'
|
|
133
|
+
*
|
|
134
|
+
* const program = Effect.gen(function* () {
|
|
135
|
+
* yield* doWork() // Automatically traced!
|
|
136
|
+
* }).pipe(Effect.provide(AutoTracingLive))
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
declare const AutoTracingLive: Layer.Layer<never>;
|
|
140
|
+
/**
|
|
141
|
+
* Disable auto-tracing for a specific Effect
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const program = Effect.gen(function* () {
|
|
146
|
+
* yield* publicWork() // Traced
|
|
147
|
+
* yield* withoutAutoTracing(internalWork()) // NOT traced
|
|
148
|
+
* })
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
declare const withoutAutoTracing: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
152
|
+
/**
|
|
153
|
+
* Override the auto-generated span name for a specific Effect
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const program = Effect.gen(function* () {
|
|
158
|
+
* yield* setSpanName('custom.operation.name')(myEffect)
|
|
159
|
+
* })
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
declare const setSpanName: (name: string) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
163
|
+
/**
|
|
164
|
+
* Create a fully YAML-driven auto-instrumentation layer
|
|
165
|
+
*
|
|
166
|
+
* This layer reads all configuration from instrumentation.yaml including:
|
|
167
|
+
* - Exporter configuration (type, endpoint, processor)
|
|
168
|
+
* - Auto-tracing configuration (naming rules, filters, performance)
|
|
169
|
+
* - Service metadata (name, version)
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* import { createFullAutoTracingLayer } from '@atrim/instrument-node/effect/auto'
|
|
174
|
+
*
|
|
175
|
+
* // Everything configured via instrumentation.yaml - no code config needed!
|
|
176
|
+
* const AppLive = createFullAutoTracingLayer()
|
|
177
|
+
*
|
|
178
|
+
* Effect.runPromise(program.pipe(Effect.provide(AppLive)))
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
declare const createFullAutoTracingLayer: () => Layer.Layer<never>;
|
|
182
|
+
/**
|
|
183
|
+
* Fully YAML-driven auto-instrumentation layer
|
|
184
|
+
*
|
|
185
|
+
* This is the recommended way to use auto-instrumentation. All configuration
|
|
186
|
+
* comes from instrumentation.yaml - no code configuration needed.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```yaml
|
|
190
|
+
* # instrumentation.yaml
|
|
191
|
+
* effect:
|
|
192
|
+
* auto_instrumentation:
|
|
193
|
+
* enabled: true
|
|
194
|
+
* span_naming:
|
|
195
|
+
* default: "effect.{function}"
|
|
196
|
+
* rules:
|
|
197
|
+
* - match: { function: "internal.*" }
|
|
198
|
+
* name: "internal.{function}"
|
|
199
|
+
* filter:
|
|
200
|
+
* exclude:
|
|
201
|
+
* - "^internal\\."
|
|
202
|
+
* exporter_config:
|
|
203
|
+
* type: otlp # or 'console' for dev
|
|
204
|
+
* endpoint: http://localhost:4318
|
|
205
|
+
* processor: batch # or 'simple' for dev
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* import { FullAutoTracingLive } from '@atrim/instrument-node/effect/auto'
|
|
211
|
+
*
|
|
212
|
+
* // Just provide the layer - everything else from YAML!
|
|
213
|
+
* Effect.runPromise(program.pipe(Effect.provide(FullAutoTracingLive)))
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
declare const FullAutoTracingLive: Layer.Layer<never>;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Node.js configuration loader
|
|
220
|
+
*
|
|
221
|
+
* Provides configuration loading using native Node.js APIs (fs, fetch)
|
|
222
|
+
* This module doesn't require Effect Platform, making it work without Effect installed.
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Legacy options interface for backward compatibility
|
|
227
|
+
*/
|
|
228
|
+
interface ConfigLoaderOptions {
|
|
229
|
+
configPath?: string;
|
|
230
|
+
configUrl?: string;
|
|
231
|
+
config?: InstrumentationConfig;
|
|
232
|
+
cacheTimeout?: number;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Auto-Tracing Configuration Loader
|
|
237
|
+
*
|
|
238
|
+
* Loads auto-tracing configuration from instrumentation.yaml
|
|
239
|
+
* and provides a typed Effect service for accessing it.
|
|
240
|
+
*/
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Default auto-tracing configuration when not specified in instrumentation.yaml
|
|
244
|
+
*/
|
|
245
|
+
declare const defaultAutoTracingConfig: AutoInstrumentationConfig;
|
|
246
|
+
declare const AutoTracingConfig_base: Context.TagClass<AutoTracingConfig, "AutoTracingConfig", {
|
|
247
|
+
enabled: boolean;
|
|
248
|
+
filter: {
|
|
249
|
+
include: string[];
|
|
250
|
+
exclude: string[];
|
|
251
|
+
};
|
|
252
|
+
granularity: "fiber" | "operator";
|
|
253
|
+
span_naming: {
|
|
254
|
+
default: string;
|
|
255
|
+
infer_from_source: boolean;
|
|
256
|
+
rules: {
|
|
257
|
+
match: {
|
|
258
|
+
function?: string | undefined;
|
|
259
|
+
file?: string | undefined;
|
|
260
|
+
module?: string | undefined;
|
|
261
|
+
};
|
|
262
|
+
name: string;
|
|
263
|
+
}[];
|
|
264
|
+
};
|
|
265
|
+
performance: {
|
|
266
|
+
sampling_rate: number;
|
|
267
|
+
min_duration: string;
|
|
268
|
+
max_concurrent: number;
|
|
269
|
+
};
|
|
270
|
+
metadata: {
|
|
271
|
+
fiber_info: boolean;
|
|
272
|
+
source_location: boolean;
|
|
273
|
+
parent_fiber: boolean;
|
|
274
|
+
};
|
|
275
|
+
}>;
|
|
276
|
+
/**
|
|
277
|
+
* Service tag for auto-tracing configuration
|
|
278
|
+
*/
|
|
279
|
+
declare class AutoTracingConfig extends AutoTracingConfig_base {
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Load auto-tracing configuration from instrumentation.yaml
|
|
283
|
+
*
|
|
284
|
+
* Returns the config from effect.auto_instrumentation section,
|
|
285
|
+
* or defaults if not specified.
|
|
286
|
+
*/
|
|
287
|
+
declare const loadAutoTracingConfig: (options?: ConfigLoaderOptions) => Effect.Effect<AutoInstrumentationConfig, never, never>;
|
|
288
|
+
/**
|
|
289
|
+
* Load auto-tracing configuration synchronously from cache or default
|
|
290
|
+
*
|
|
291
|
+
* Note: This is a synchronous fallback when Effect runtime isn't available.
|
|
292
|
+
* Prefer loadAutoTracingConfig() when possible.
|
|
293
|
+
*/
|
|
294
|
+
declare const loadAutoTracingConfigSync: () => AutoInstrumentationConfig;
|
|
295
|
+
/**
|
|
296
|
+
* Layer that provides auto-tracing configuration
|
|
297
|
+
*/
|
|
298
|
+
declare const AutoTracingConfigLive: Layer.Layer<AutoTracingConfig, never, never>;
|
|
299
|
+
/**
|
|
300
|
+
* Layer that provides custom auto-tracing configuration
|
|
301
|
+
*/
|
|
302
|
+
declare const AutoTracingConfigLayer: (config: AutoInstrumentationConfig) => Layer.Layer<AutoTracingConfig>;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Span Name Inference for Auto-Tracing
|
|
306
|
+
*
|
|
307
|
+
* Provides intelligent span naming based on source code information
|
|
308
|
+
* and configuration rules from instrumentation.yaml.
|
|
309
|
+
*/
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Source code information extracted from stack traces
|
|
313
|
+
*/
|
|
314
|
+
interface SourceInfo {
|
|
315
|
+
/** Function name (or 'anonymous') */
|
|
316
|
+
function: string;
|
|
317
|
+
/** Full file path */
|
|
318
|
+
file: string;
|
|
319
|
+
/** Line number */
|
|
320
|
+
line: number;
|
|
321
|
+
/** Column number */
|
|
322
|
+
column: number;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Template variables available for span naming
|
|
326
|
+
*/
|
|
327
|
+
interface TemplateVariables {
|
|
328
|
+
fiber_id: string;
|
|
329
|
+
function: string;
|
|
330
|
+
module: string;
|
|
331
|
+
file: string;
|
|
332
|
+
line: string;
|
|
333
|
+
operator: string;
|
|
334
|
+
[key: string]: string;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Infer a span name based on fiber ID, source info, and configuration
|
|
338
|
+
*
|
|
339
|
+
* Priority:
|
|
340
|
+
* 1. Match against naming rules (first match wins)
|
|
341
|
+
* 2. Use default template with source info if available
|
|
342
|
+
* 3. Fallback to default template with fiber ID only
|
|
343
|
+
*
|
|
344
|
+
* @param fiberId - The fiber's numeric ID
|
|
345
|
+
* @param sourceInfo - Optional source code information from stack trace
|
|
346
|
+
* @param config - Auto-instrumentation configuration
|
|
347
|
+
* @returns The inferred span name
|
|
348
|
+
*/
|
|
349
|
+
declare function inferSpanName(fiberId: number, sourceInfo: SourceInfo | undefined, config: AutoInstrumentationConfig): string;
|
|
350
|
+
/**
|
|
351
|
+
* Sanitize a span name to be OpenTelemetry compliant
|
|
352
|
+
*
|
|
353
|
+
* - Replaces invalid characters with underscores
|
|
354
|
+
* - Ensures name is not empty
|
|
355
|
+
* - Truncates to reasonable length
|
|
356
|
+
*/
|
|
357
|
+
declare function sanitizeSpanName(name: string): string;
|
|
358
|
+
|
|
359
|
+
export { AutoTracingConfig, AutoTracingConfigLayer, AutoTracingConfigLive, AutoTracingEnabled, AutoTracingLive, AutoTracingSpanName, AutoTracingSupervisor, FullAutoTracingLive, type SourceInfo, type TemplateVariables, createAutoTracingLayer, createAutoTracingSupervisor, createFullAutoTracingLayer, defaultAutoTracingConfig, inferSpanName, loadAutoTracingConfig, loadAutoTracingConfigSync, sanitizeSpanName, setSpanName, withAutoTracing, withoutAutoTracing };
|