trojan-metrics
Prometheus metrics collection and HTTP exporter for trojan-rs.
Overview
This crate instruments the trojan server with counters, gauges, and histograms exposed via a Prometheus-compatible HTTP endpoint.
Endpoints
| Path | Description |
|---|---|
/metrics |
Prometheus metrics scrape endpoint |
/health |
Health check (always returns 200) |
/ready |
Readiness check |
Metrics
| Metric | Type | Description |
|---|---|---|
trojan_connections_total |
Counter | Total accepted connections |
trojan_connections_active |
Gauge | Currently active connections |
trojan_auth_success_total |
Counter | Successful authentications |
trojan_auth_failure_total |
Counter | Failed authentications |
trojan_bytes_received_total |
Counter | Bytes received from clients |
trojan_bytes_sent_total |
Counter | Bytes sent to clients |
trojan_errors_total |
Counter | Errors by type |
trojan_connection_duration_seconds |
Histogram | Connection lifetime |
trojan_tls_handshake_duration_seconds |
Histogram | TLS handshake time |
trojan_dns_resolve_duration_seconds |
Histogram | DNS resolution time |
trojan_target_connect_duration_seconds |
Histogram | Target connection time |
Usage
use ;
// Start metrics server
init_metrics_server.await;
// Record events
record_connection_accepted;
record_bytes_sent;
License
GPL-3.0-only