Monitoring
Health check
Section titled “Health check”curl http://localhost:8080/healthResponse: OK with HTTP 200.
Prometheus metrics
Section titled “Prometheus metrics”Enable in config:
[features]metrics = trueScrape endpoint: GET /metrics
Key metrics:
rcommerce_http_requests_total— request count by method/path/statusrcommerce_http_request_duration_seconds— request latency histogramrcommerce_db_pool_connections— database connection pool statsrcommerce_cache_hits_total/rcommerce_cache_misses_total— cache hit rate
Structured logging
Section titled “Structured logging”Set log level:
RUST_LOG=info # defaultRUST_LOG=debug # verboseRUST_LOG=rcommerce_api=debug,sqlx=warn # targetedOpenTelemetry
Section titled “OpenTelemetry”rCommerce supports OpenTelemetry traces. Configure in your OTLP collector:
[features]otel_endpoint = "http://otel-collector:4317"Database monitoring
Section titled “Database monitoring”-- Active connectionsSELECT count(*) FROM pg_stat_activity WHERE datname = 'rcommerce';
-- Slow queriesSELECT query, mean_exec_time, callsFROM pg_stat_statementsWHERE mean_exec_time > 100ORDER BY mean_exec_time DESCLIMIT 10;
-- Table sizesSELECT relname, pg_size_pretty(pg_total_relation_size(relid))FROM pg_catalog.pg_statio_user_tablesORDER BY pg_total_relation_size(relid) DESC;