This article is only relevant for v0.9.10 and later.

Debugging using fgtrace

Tutorial on how to get started with fgtrace
  1. Enable fgtrace

    ActivateFgtrace
    ActivateFgtrace

  2. Forward the new fgtrace port

    ForwardFgtrace
    ForwardFgtrace

  3. Visit the /debug/fgtrace trace path using Insomnia or a similar tool. Please note that it will take about half a minute for a trace to complete.

    InsomniaExampleTrace
    InsomniaExampleTrace

  4. Export the returned JSON

    InsomniaSaveJson
    InsomniaSaveJson

  5. Open the Perfetto UI

  6. Click on “Open trace file” and select the exported JSON

    PerfettoOpenSavedTrace
    PerfettoOpenSavedTrace

  7. Wait for it to load

  8. You are now viewing a Chrome-like waterfall graph that shows the wallclock time used by each goroutine.

    PerfettoTraceOverview
    PerfettoTraceOverview

  9. Expanding a goroutine will allow you to view the function calls it made.

    PerfettoTraceDetails
    PerfettoTraceDetails

  10. Please note that due to our sampling frequency, function calls that take less than 0.01 seconds will not be captured.

Changing the trace length and frequency

To control the trace length and frequency, you can use the query parameters “seconds” and “hz”.

InsomniaTraceOptions
InsomniaTraceOptions

Last modified May 5, 2023: feat: finishing touches (1147002)