tracing.md (2434B)
1 # Tracing 2 3 GoToSocial comes with [OpenTelemetry][otel] based tracing built-in. It's not wired through every function, but our HTTP handlers and database library will create spans. How to configure tracing is explained in the [Observability configuration reference][obs]. 4 5 In order to receive the traces, you need something to ingest them and then visualise them. There are many options available including self-hosted and commercial options. 6 7 We provide an example of how to do this using [Grafana Tempo][tempo] to ingest the spans and [Grafana][grafana] to explore them. Please beware that the configuration we provide is not suitable for a production setup. It can be used safely for local development and can provide a good starting point for setting up your own tracing infrastructure. 8 9 You'll need the files in [`example/tracing`][ext]. Once you have those you can run `docker-compose up -d` to get Tempo and Grafana running. With both services running, you can add the following to your GoToSocial configuration and restart your instance: 10 11 ```yaml 12 tracing-enabled: true 13 tracing-transport: "grpc" 14 tracing-endpoint: "localhost:4317" 15 tracing-insecure: true 16 ``` 17 18 [otel]: https://opentelemetry.io/ 19 [obs]: ../configuration/observability.md 20 [tempo]: https://grafana.com/oss/tempo/ 21 [grafana]: https://grafana.com/oss/grafana/ 22 [ext]: https://github.com/superseriousbusiness/gotosocial/tree/main/example/tracing 23 24 ## Querying and visualising traces 25 26 Once you execute a few queries against your instance, you'll be able to find them in Grafana. You can use the Explore tab and pick Tempo as the datasource. Because our example configuration for Grafana enables [TraceQL][traceql], the Explore tab will have the TraceQL query type selected by default. You can switch to "Search" instead and find all traces emitted by GoToSocial under the "GoToSocial" service name. 27 28 Using TraceQL, a simple query to find all traces related to requests to `/api/v1/instance` would look like this: 29 30 ``` 31 {.http.route = "/api/v1/instance"} 32 ``` 33 34 If you wanted to see all GoToSocial traces, you could instead run: 35 36 ``` 37 {.service.name = "GoToSocial"} 38 ``` 39 40 Once you select a trace, a second panel will open up visualising the span. You can drill down from there, by clicking into every sub-span to see what it was doing. 41 42 ![Grafana showing a trace for the /api/v1/instance endpoint](../assets/tracing.png) 43 44 [traceql]: https://grafana.com/docs/tempo/latest/traceql/