Profiling (flame graph)
The Spitfire Agent samples, 19 times a second, which functions your applications spend CPU time in. No code, package or environment variable is added and the application is not restarted. The result shows as a flame graph on the service page's Profiling tab. On in Starter and above.
Turning it on
- Install the Spitfire Agent on the server the application runs on (Agent). On Linux it runs as root; on Mac and Windows the containers of Docker Desktop are profiled.
- On the Agents page open the Agent and check that the Profiling module is on on the scope card (it is on by default).
- Wait a few minutes: samples arrive once a minute.
Reading the flame graph
- Open the service in APM → Services and go to the Profiling tab.
- Each box is a function. The wider the box, the more CPU went to that function and the ones it called. The caller is above, the callee below.
- Click a box to focus on it. Show all goes back.
- Type in Find a function (e.g.
json): the matching boxes get an orange outline and their share shows above. - The Functions table below shows each function's Self (its own code only) and Total (with what it calls) share, its file and line.
A sample is about 1/19 second of CPU; the "≈ s CPU" figure comes from that.
Comparing
- Pick from Compare: The same length before, Yesterday, same hours or before / after a deploy.
- Red boxes' share grew, green ones' shrank.
- The Functions table sorts by Change (points): what grew most comes first.
Traces and servers
- With the Agent's eBPF tracing on too, a trace's page shows a CPU during this span card: the samples taken during the picked span or the whole trace.
- Opening a server in APM → Servers shows the services that used its CPU most and the server's flame graph.
In the load test report
- Open a run's report. When samples came during the run, the Where the CPU went during the run section shows.
- The line on top names the function that used the most CPU, its share and its file. When the function has no file of its own (a library's or the kernel's), the code of yours that called it is named.
- Pick The 15 minutes before the run or another run of the same test in Compare. Red boxes grew their share, green ones shrank.
- When the test reached more than one service, pick one in Service.
When a run's Root cause card has a CPU cause, the same function is cited as evidence. Open in Profiling opens the flame graph of that moment.
In event suggestions
When a CPU event opens on a server, the suggestion names, next to the process using the CPU, the function inside that service the CPU went to. The link opens the flame graph of the 10 minutes before the event. Without enough samples the suggestion names the processes only.
In method hot spots
APM → Top lists → Method hot spots gets a Sampled CPU column. Self time is wall time and counts I/O waits too. A method with a high self time and a low sampled CPU is waiting (database, network, a lock). When both are high it burns the CPU. Without samples the column shows —.
Sending from your own profiler
If you have a profiler that sends the OpenTelemetry profiles signal (e.g. the OpenTelemetry eBPF profiler), you can send to Spitfire directly.
Get an OTLP key: Preparing the OTLP sender.
Set the profiler's exporter (put your own address and key in place of
<spitfire>andsfotlp_…):OTEL_EXPORTER_OTLP_ENDPOINT=https://<spitfire>/otlp OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf OTEL_EXPORTER_OTLP_HEADERS=authorization=sfotlp_…Start the profiler. Every sample needs the
service.nameresource attribute; the service page opens under that name.
With gRPC, send to the OTLP gRPC address with the same key.
When no profile comes
Open the Agent on the Agents page and look at the Profiling line. When something is wrong, the reason is there.
On Linux the Agent must run as root and the kernel must have BTF. To check:
ls /sys/kernel/btf/vmlinux && uname -rWithout the file the kernel needs 5.8 or later.
On Mac and Windows, Docker Desktop must be running and the Agent's Docker module on. Only containers are profiled.
On the Free edition, profiling opens with Starter.
Check the application really uses the CPU: an idle application makes no samples.
From the command line
The functions a service spent its CPU in over the last hour:
spitfire cloud apm profile order-api --range 1hA load test run, compared with the 15 minutes before it (CHANGE is the difference in points):
spitfire cloud apm profile --run <run-id>
SPITFIRE_URL and SPITFIRE_TOKEN must be set as for the other spitfire cloud commands.
How long it is kept
| Edition | Profile samples | Samples tied to spans |
|---|---|---|
| Free | not kept | not kept |
| Starter | 3 days | 3 days |
| Growth, Scale | 7 days | 3 days |
| Enterprise | 15 days | 3 days |
Turning it off
- On the Agents page open the Agent.
- Switch off the Profiling module on the scope card. The Agent stops profiling at once.