autotel
Version:
Write Once, Observe Anywhere
79 lines (75 loc) • 2.31 kB
TypeScript
import { Tracer, Meter } from '@opentelemetry/api';
export { ILogger } from './logger.js';
import 'pino';
/**
* Global configuration for OpenTelemetry decorators
*
* Allows users to inject custom loggers, tracers, and meters
* while maintaining sensible defaults.
*/
declare const FEATURE_FLAGS: {
/** Enable full auto-instrumentation (expensive, production only) */
readonly ENABLE_AUTO_INSTRUMENTATION: boolean;
/** Enable verbose logging (development only) */
readonly ENABLE_VERBOSE_LOGGING: boolean;
/** Enable metrics collection (production only) */
readonly ENABLE_METRICS_BY_DEFAULT: boolean;
/** Enable async resource detection (production only) */
readonly ENABLE_RESOURCE_DETECTION: boolean;
/** Enable tracing in all environments (can be disabled via autotel_TRACING=false) */
readonly ENABLE_TRACING: boolean;
/** Enable log redaction for sensitive fields (can be disabled via autotel_REDACTION=false) */
readonly ENABLE_REDACTION: boolean;
};
/**
* Runtime configuration for OpenTelemetry instrumentation
*
* This configures the tracer and meter used by autotel's functional API.
* Use `configure()` to set custom tracer/meter instances.
*/
interface RuntimeConfig {
/**
* Tracer name for OpenTelemetry
* @default 'app'
*/
tracerName?: string;
/**
* Meter name for OpenTelemetry metrics
* @default 'app'
*/
meterName?: string;
/**
* Custom tracer instance (for advanced use cases like Datadog direct)
* @default trace.getTracer(tracerName)
*/
tracer?: Tracer;
/**
* Custom meter instance
* @default metrics.getMeter(meterName)
*/
meter?: Meter;
}
/**
* Configure global instrumentation behavior
*
* @example
* ```typescript
* import { configure } from 'autotel/config'
*
* configure({
* tracerName: 'my-app'
* })
* ```
*/
declare function configure(options: RuntimeConfig): void;
/**
* Get current configuration (internal use)
*/
declare function getConfig(): Required<RuntimeConfig> & {
featureFlags: typeof FEATURE_FLAGS;
};
/**
* Reset configuration to defaults (internal use - mainly for testing)
*/
declare function resetConfig(): void;
export { FEATURE_FLAGS, type RuntimeConfig, configure, getConfig, resetConfig };