Skip to main content

Metrics Collection

Gate exposes operational metrics through OpenTelemetry, providing insights into proxy performance, player connections, and server health. Metrics can be exported to Prometheus, Grafana Cloud, or any OpenTelemetry-compatible backend.

Enabling Metrics

Metrics collection is disabled by default. Enable it using the OTEL_METRICS_ENABLED environment variable:

Available Metrics

Gate exposes the following metrics (defined in pkg/edition/java/proxy/otel_meter.go:17):

Proxy Metrics

gate.player_count

  • Type: Gauge (Int64)
  • Description: Current total player count on the proxy
  • Unit: 1 (players)
  • Labels: Automatically includes service.name, service.version

gate.registered_servers

  • Type: Gauge (Int64)
  • Description: Current total registered servers on the proxy
  • Unit: 1 (servers)
  • Labels: Automatically includes service.name, service.version

Runtime Metrics

Gate automatically includes Go runtime metrics through the OpenTelemetry SDK:
  • process.runtime.go.mem.heap_alloc - Heap memory allocated
  • process.runtime.go.mem.heap_inuse - Heap memory in use
  • process.runtime.go.gc.count - Number of garbage collections
  • process.runtime.go.gc.pause_ns - GC pause time
  • process.runtime.go.goroutines - Number of goroutines

Host Metrics

When using the honeycombio/otel-config-go library, Gate includes host-level metrics:
  • CPU usage - system.cpu.utilization
  • Memory usage - system.memory.usage, system.memory.utilization
  • Network I/O - system.network.io
  • Disk I/O - system.disk.io

Metric Export Formats

Export metrics using OpenTelemetry Protocol to a collector or backend:

Prometheus Remote Write

The OpenTelemetry Collector can convert OTLP metrics to Prometheus format:

Prometheus Integration

Setup with OpenTelemetry Collector

  1. Configure Gate to send metrics to the collector:
  1. Configure the collector to export to Prometheus:
  1. Enable Prometheus remote write receiver:
Start Prometheus with the remote write receiver flag:

Metric Name Translation

When metrics are exported to Prometheus:
  • OpenTelemetry service.name → Prometheus job label
  • OpenTelemetry service.instance.id → Prometheus instance label
  • Metric names keep their original format (e.g., gate.player_count)

Grafana Dashboards

Basic Player Monitoring

Advanced Proxy Metrics

Configuration Examples

Local Development

Production with Grafana Cloud

Self-Hosted Stack

Docker Compose Example

Alerting Rules

Example Prometheus alerting rules for Gate:

Custom Metrics

To add custom metrics in your Gate plugins or extensions:

Troubleshooting

Metrics Not Appearing

  1. Verify metrics are enabled:
  2. Check the metrics endpoint:
  3. Review OpenTelemetry Collector logs:

High Cardinality Issues

  • Avoid adding high-cardinality labels (e.g., player UUIDs, timestamps)
  • Use resource attributes for static metadata
  • Consider sampling for high-volume metrics

Performance Impact

  • Metrics collection has minimal overhead (less than 1% CPU)
  • Adjust OTEL_EXPORTER_OTLP_METRICS_PERIOD to balance freshness vs. load
  • Use batching in the OpenTelemetry Collector

Next Steps

Tracing

Set up distributed tracing for request flows

Logging

Configure structured logging and log aggregation