# Metrics Feature Configuration
# Settings for Prometheus metrics collection and monitoring

[features]
metrics = true

# Metrics Collection
[metrics]
enabled = true
endpoint = "/metrics"
health_endpoint = "/metrics/health"
collection_interval = 30  # seconds
enable_process_metrics = true
enable_runtime_metrics = true

# Prometheus Configuration
[metrics.prometheus]
namespace = "rustelo"
subsystem = ""
registry_type = "default"  # "default" or "custom"
enable_exemplars = false
histogram_buckets = [0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0]

# HTTP Metrics
[metrics.http]
enabled = true
track_request_count = true
track_request_duration = true
track_requests_in_flight = true
track_response_size = true
track_request_size = true
include_user_agent = false
include_ip_address = false
slow_request_threshold = 1.0  # seconds

# Database Metrics
[metrics.database]
enabled = true
track_connection_pool = true
track_query_duration = true
track_query_count = true
track_connection_errors = true
track_migration_status = true
slow_query_threshold = 0.1  # seconds
include_query_tags = false  # Can expose sensitive data

# Authentication Metrics
[metrics.auth]
enabled = true
track_login_attempts = true
track_login_failures = true
track_session_duration = true
track_active_sessions = true
track_token_generations = true
track_password_resets = true
track_registration_attempts = true
include_failure_reasons = true

# Content Metrics
[metrics.content]
enabled = true
track_content_requests = true
track_cache_performance = true
track_content_processing_time = true
track_search_queries = true
track_content_views = true
track_popular_content = true

# Email Metrics
[metrics.email]
enabled = true
track_emails_sent = true
track_email_failures = true
track_queue_size = true
track_processing_time = true
track_bounce_rate = true
track_delivery_rate = true
include_provider_metrics = true

# System Metrics
[metrics.system]
enabled = true
track_memory_usage = true
track_cpu_usage = true
track_disk_usage = true
track_network_io = true
track_file_descriptors = true
track_uptime = true
collection_interval = 15  # seconds

# Business Metrics
[metrics.business]
enabled = true
track_user_registrations = true
track_user_logins = true
track_content_creation = true
track_api_usage = true
track_feature_usage = true
track_error_rates = true
track_conversion_metrics = false

# Performance Metrics
[metrics.performance]
enabled = true
track_garbage_collection = true
track_thread_pool_usage = true
track_async_task_metrics = true
track_lock_contention = false
track_allocation_rate = false

# Custom Metrics
[metrics.custom]
enabled = true
allow_custom_counters = true
allow_custom_gauges = true
allow_custom_histograms = true
max_custom_metrics = 100
custom_metric_prefix = "custom_"

# Metric Labels
[metrics.labels]
include_environment = true
include_version = true
include_instance_id = true
include_hostname = false
custom_labels = {}

# Metric Filtering
[metrics.filters]
exclude_patterns = []
include_patterns = ["*"]
exclude_sensitive_data = true
max_label_count = 20
max_label_length = 100

# Aggregation Settings
[metrics.aggregation]
enable_summary_metrics = true
summary_objectives = [0.5, 0.9, 0.95, 0.99]
histogram_max_age = 600  # seconds
gauge_max_age = 300  # seconds

# Export Configuration
[metrics.export]
format = "prometheus"  # "prometheus", "json", "statsd"
compression = "gzip"
timeout = 30  # seconds
include_help_text = true
include_type_info = true

# Rate Limiting for Metrics Endpoint
[metrics.rate_limiting]
enabled = true
requests_per_minute = 60
burst_limit = 10
exclude_internal_requests = true

# Security
[metrics.security]
enable_authentication = false
allowed_ips = []  # Empty means all IPs allowed
api_key_header = "X-Metrics-API-Key"
api_key = ""  # Set in environment or use encrypted value

# Alerting Integration
[metrics.alerting]
enabled = false
webhook_url = ""
alert_threshold_errors = 10
alert_threshold_latency = 5.0  # seconds
alert_cooldown = 300  # seconds

# Development Settings
[metrics.development]
enable_debug_metrics = false
log_metric_collection = false
metric_collection_timeout = 5  # seconds
enable_metric_validation = true
