UNPKG

autotel

Version:
87 lines (85 loc) 2.64 kB
import { getAutotelTracer } from './chunk-HA2WBOGQ.js'; import { metrics, trace } from '@opentelemetry/api'; var IS_PRODUCTION = process.env.NODE_ENV === "production"; var IS_DEV = process.env.NODE_ENV === "development"; process.env.NODE_ENV === "test"; var FEATURE_FLAGS = { /** Enable full auto-instrumentation (expensive, production only) */ ENABLE_AUTO_INSTRUMENTATION: IS_PRODUCTION && process.env.autotel_AUTO_INSTRUMENT !== "false", /** Enable verbose logging (development only) */ ENABLE_VERBOSE_LOGGING: IS_DEV || process.env.autotel_VERBOSE === "true", /** Enable metrics collection (production only) */ ENABLE_METRICS_BY_DEFAULT: IS_PRODUCTION && process.env.autotel_METRICS !== "false", /** Enable async resource detection (production only) */ ENABLE_RESOURCE_DETECTION: IS_PRODUCTION && process.env.autotel_RESOURCE_DETECTION === "true", /** Enable tracing in all environments (can be disabled via autotel_TRACING=false) */ ENABLE_TRACING: process.env.autotel_TRACING !== "false", /** Enable log redaction for sensitive fields (can be disabled via autotel_REDACTION=false) */ ENABLE_REDACTION: process.env.autotel_REDACTION !== "false" }; var Config = class { config = { tracerName: "app", meterName: "app", tracer: getAutotelTracer("app"), meter: metrics.getMeter("app") }; /** * Get feature flags */ get featureFlags() { return FEATURE_FLAGS; } /** * Update global configuration */ configure(options) { if (options.tracerName) { this.config.tracerName = options.tracerName; this.config.tracer = getAutotelTracer(options.tracerName); } if (options.meterName) { this.config.meterName = options.meterName; this.config.meter = metrics.getMeter(options.meterName); } if (options.tracer) { this.config.tracer = options.tracer; } if (options.meter) { this.config.meter = options.meter; } } /** * Get current configuration */ get() { return this.config; } /** * Reset to defaults (mainly for testing) */ reset() { this.config = { tracerName: "app", meterName: "app", tracer: trace.getTracer("app"), meter: metrics.getMeter("app") }; } }; var globalConfig = new Config(); function configure(options) { globalConfig.configure(options); } function getConfig() { return { ...globalConfig.get(), featureFlags: FEATURE_FLAGS }; } function resetConfig() { globalConfig.reset(); } export { FEATURE_FLAGS, configure, getConfig, resetConfig }; //# sourceMappingURL=chunk-J5QENANM.js.map //# sourceMappingURL=chunk-J5QENANM.js.map