Distributed Tracing
Gate supports distributed tracing through OpenTelemetry, allowing you to track requests as they flow through your proxy infrastructure. Tracing helps identify performance bottlenecks, debug connection issues, and understand player request flows.Enabling Tracing
Tracing is disabled by default. Enable it using theOTEL_TRACES_ENABLED environment variable:
Trace Instrumentation
Gate automatically instruments key operations with tracing spans. The instrumentation is implemented throughout the codebase using OpenTelemetry’s Go SDK.Instrumented Operations
Gate creates traces for the following operations:Proxy Operations (pkg/edition/java/proxy/proxy.go:XX)
Proxy.Start- Proxy startup and initializationHandleConn- New player connection handling- Attributes:
net.peer.addr,net.peer.port
- Attributes:
Authentication (pkg/edition/java/auth/authenticator.go:XX)
AuthenticateJoin- Player authentication with Mojang- Attributes:
player.username,player.uuid,player.ip
- Attributes:
Network Operations (pkg/edition/java/netmc/connection.go:XX)
startReadLoop- Packet reading loop- Attributes:
connection.id,connection.state
- Attributes:
HandlePacket- Individual packet processing- Attributes:
packet.type,packet.size
- Attributes:
Server Connections (pkg/edition/java/proxy/server.go:XX)
serverConnection.dial- Backend server connection- Attributes:
server.name,server.address,server.port
- Attributes:
Trace Context Propagation
Gate uses the W3C Trace Context standard for propagation:- Gate proxy instances
- Backend servers (if instrumented)
- External authentication services
- Custom plugins and middleware
Configuration
Basic Setup
Advanced Configuration
Sampling Configuration
Control trace sampling to manage volume and costs:always_on- Sample all traces (default)always_off- Sample no tracestraceidratio- Sample based on trace ID ratioparentbased_always_on- Respect parent sampling decision, otherwise always sampleparentbased_traceidratio- Respect parent, otherwise sample by ratio
Backend Integration
Jaeger
Jaeger is a popular open-source distributed tracing system.Direct to Jaeger
Via OpenTelemetry Collector
Docker Compose with Jaeger
http://localhost:16686
Grafana Tempo
Tempo is Grafana’s high-scale distributed tracing backend.Configuration
Docker Compose with Tempo
Tempo Configuration
Grafana Cloud
Honeycomb
Trace Analysis
Understanding Trace Structure
A typical player connection trace shows:Example Queries
Jaeger UI
- Find slow connections: Filter by duration > 1s
- Search by player: Use tag
player.username=<name> - Error traces: Filter by tag
error=true - By operation: Select operation like
AuthenticateJoin
Grafana with Tempo
Common Patterns
Slow Player Connections
Look for high duration in:AuthenticateJoin- Mojang API slownessserverConnection.dial- Backend server latencyHandlePacket- Packet processing issues
Connection Failures
Check for error status in:HandleConn- Initial connection problemsAuthenticateJoin- Authentication failuresserverConnection.dial- Backend unreachable
Trace Correlation
Linking Traces to Metrics
Use exemplars to link metrics to traces in Grafana:Linking Traces to Logs
Gate automatically includes trace context in logs when using structured logging:Custom Tracing
Add custom spans in your Gate plugins:Performance Considerations
Overhead
- Tracing adds ~1-2% CPU overhead when enabled
- Memory impact: ~100-200 bytes per span
- Network: Traces are batched and compressed
Optimization Tips
-
Use sampling for high-traffic proxies:
-
Batch traces in the collector:
-
Filter unnecessary spans:
Troubleshooting
No Traces Appearing
-
Verify tracing is enabled:
-
Test the endpoint:
- Check Gate logs for trace export errors
Incomplete Traces
- Ensure all services use the same propagation format
- Verify trace context is passed through middleware
- Check for trace context being lost at service boundaries
High Trace Volume
- Implement sampling:
OTEL_TRACES_SAMPLER_ARG - Use tail-based sampling in the collector
- Filter low-value spans
Next Steps
Metrics
Monitor proxy performance with metrics
Logging
Configure structured logging

