autotel
Version:
Write Once, Observe Anywhere
110 lines (106 loc) • 3.19 kB
TypeScript
import { A as AutotelConfig } from './init-D6JfWEjL.js';
import { SamplingPreset } from './sampling.js';
import '@opentelemetry/sdk-trace-base';
import '@opentelemetry/sdk-node';
import '@opentelemetry/resources';
import './event-subscriber.js';
import './logger.js';
import 'pino';
import '@opentelemetry/api';
import '@opentelemetry/sdk-metrics';
import '@opentelemetry/sdk-logs';
import './filtering-span-processor.js';
import './span-name-normalizer.js';
import './attribute-redacting-processor.js';
import './processors.js';
/**
* YAML configuration loader for autotel
*
* Supports:
* - Auto-discovery of autotel.yaml in cwd
* - AUTOTEL_CONFIG_FILE env var override
* - Environment variable substitution: ${env:VAR} and ${env:VAR:-default}
*
* @example Auto-discovery
* ```yaml
* # autotel.yaml in project root
* service:
* name: my-service
* exporter:
* endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}
* ```
*
* @example Explicit path
* ```bash
* AUTOTEL_CONFIG_FILE=./config/otel.yaml tsx --import autotel/auto src/index.ts
* ```
*/
/**
* YAML config structure
* Maps to AutotelConfig with user-friendly naming
*/
interface YamlConfig {
service?: {
name?: string;
version?: string;
environment?: string;
};
exporter?: {
endpoint?: string;
protocol?: 'http' | 'grpc';
headers?: Record<string, string>;
};
resource?: Record<string, string | number | boolean>;
sampling?: {
preset?: SamplingPreset;
type?: 'adaptive' | 'always_on' | 'always_off' | 'ratio';
ratio?: number;
baseline_rate?: number;
always_sample_errors?: boolean;
always_sample_slow?: boolean;
slow_threshold_ms?: number;
};
autoInstrumentations?: string[] | Record<string, {
enabled?: boolean;
}>;
debug?: boolean;
}
/**
* Load and parse YAML config file (auto-discovery)
*
* Automatically finds and loads autotel.yaml or uses AUTOTEL_CONFIG_FILE.
* Returns null if no config file found (not an error - YAML config is optional).
*
* @returns Partial AutotelConfig or null if no config file found
*
* @example
* const yamlConfig = loadYamlConfig();
* if (yamlConfig) {
* init({ ...yamlConfig, debug: true });
* }
*/
declare function loadYamlConfig(): Partial<AutotelConfig> | null;
/**
* Load YAML config from a specific file path
*
* Unlike loadYamlConfig(), this throws if the file cannot be read.
*
* @param filePath - Path to YAML config file
* @returns Partial AutotelConfig
* @throws Error if file cannot be read or parsed
*
* @example
* import { loadYamlConfigFromFile } from 'autotel/yaml';
* import { init } from 'autotel';
*
* const config = loadYamlConfigFromFile('./config/otel.yaml');
* init({ ...config, debug: true });
*/
declare function loadYamlConfigFromFile(filePath: string): Partial<AutotelConfig>;
/**
* Check if a YAML config file exists (without loading it)
*
* @returns true if a config file would be found by loadYamlConfig()
*/
declare function hasYamlConfig(): boolean;
export { type YamlConfig, hasYamlConfig, loadYamlConfig, loadYamlConfigFromFile };