github.com/grafana/pyroscope@v1.18.0/examples/tracing/python/README.md (about) 1 # Span Profiles with Grafana Tempo and Pyroscope 2 3 The docker compose consists of: 4 - Three Python Rideshare App instances (us-east, eu-north, ap-south regions) 5 - Tempo for trace collection 6 - Pyroscope for continuous profiling 7 - Grafana for visualization 8 - Load Generator for simulating traffic 9 10 For a detailed guide about Python span profiles configuration, refer to the docs [Pyroscope documentation](https://grafana.com/docs/pyroscope/latest/configure-client/trace-span-profiles/python-span-profiles/). 11 12 The `rideshare` app generates traces and profiling data that should be available in Grafana. 13 Pyroscope and Tempo datasources are provisioned automatically. 14 15 ### Build and run 16 17 The project can be run locally with the following commands: 18 19 ```shell 20 # Pull latest pyroscope and grafana images: 21 docker pull grafana/pyroscope:latest 22 docker pull grafana/grafana:latest 23 24 docker compose up 25 ``` 26 The load generator will automatically start sending requests to all regional instances. 27 28 ### Viewing Traces and Profiles 29 30 Navigate to the [Explore page](http://localhost:3000/explore?schemaVersion=1&panes=%7B%22yM9%22:%7B%22datasource%22:%22tempo%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22datasource%22:%7B%22type%22:%22tempo%22,%22uid%22:%22tempo%22%7D,%22queryType%22:%22traceqlSearch%22,%22limit%22:20,%22tableType%22:%22traces%22,%22filters%22:%5B%7B%22id%22:%22e73a615e%22,%22operator%22:%22%3D%22,%22scope%22:%22span%22%7D,%7B%22id%22:%22service-name%22,%22tag%22:%22service.name%22,%22operator%22:%22%3D%22,%22scope%22:%22resource%22,%22value%22:%5B%22rideshare.python.push.app%22%5D,%22valueType%22:%22string%22%7D%5D%7D%5D,%22range%22:%7B%22from%22:%22now-6h%22,%22to%22:%22now%22%7D%7D%7D&orgId=1), select a trace and click on a span that has a linked profile: 31 32  33 34 By default, only the root span gets labeled (the first span created locally): such spans are marked with the link icon 35 and have `pyroscope.profile.id` attribute set to the corresponding span ID. 36 Please note that presence of the attribute does not necessarily 37 indicate that the span has a profile: stack trace samples might not be collected, if the utilized CPU time is 38 less than the sample interval (10ms). 39 40 ### Grafana Tempo configuration 41 42 In order to correlate trace spans with profiling data, the Tempo datasource should have the following configured: 43 - The profiling data source 44 - Tags to use when making profiling queries 45 46  47 48 While tags are optional, configuring them is highly recommended for optimizing query performance. 49 In our example, we configured the `service.name` tag for use in Pyroscope queries as the `service_name` label. 50 This configuration restricts the data set for lookup, ensuring that queries remain 51 consistently fast. Note that the tags you configure must be present in the span attributes or resources 52 for a trace to profiles span link to appear. 53 54 Please refer to our [documentation](https://grafana.com/docs/grafana/next/datasources/tempo/configure-tempo-data-source/#trace-to-profiles) for more details.