Set Up Distributed Tracing for Godot Engine

Learn how to connect operations in your Godot game with requests to your backend services.

Available since: v2.2.0

Distributed tracing connects work in your game with work in your backend. For example, a trace can show how much time a leaderboard request spends in the game, your API, and its database.

Use SentryHTTPRequest to instrument outgoing HTTP and HTTPS requests and add trace headers automatically. For Godot's HTTPRequest, HTTPClient, WebSocketPeer, or another client that the SDK doesn't instrument, attach the headers manually.

  1. Enable tracing in your game.
  2. Set up the Sentry SDK for your backend and enable its distributed tracing support.
  3. Either send the request with SentryHTTPRequest or follow Custom Trace Propagation to attach headers from a span yourself.

The receiving service uses these headers to continue the same trace:

  • sentry-trace identifies the trace, the sending span, and its sampling decision.
  • baggage carries additional trace metadata, such as the sample rate and organization ID.
  • traceparent provides the W3C trace context when you enable propagate_traceparent.

Restrict headers to your own services with Limiting Trace Propagation. For Web exports, also configure your backend to allow the headers through CORS.

Make sure any proxies, gateways, or firewalls between your game and backend preserve the tracing headers.

The SDK starts a trace when it initializes. Spans and events share that trace until you start a new one. Ending a span finishes only that operation; it doesn't start a new trace.

To separate unrelated work, such as game matches, start a new trace before starting the next operation.

The outgoing sentry-trace header carries the span's sampling decision so downstream services can honor it. With traces_sample_rate set to its default of 0.0, the SDK still provides trace headers, but the span isn't sent and the headers mark the trace as unsampled.

Use a sample rate of 1.0 in your game and backend while verifying the connection, then adjust it for production.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").