Profiler
Profiling Go and Rust
Sentry has no profiling SDK for Go or Rust, so Bugzor takes the format those ecosystems already produce: pprof. A Go service’s CPU profile shows up in the same Profiler as a Python or Ruby app’s: flame graph, hottest functions, release comparisons, MCP tools. Available on LongNeck and Zilla.
The Bugzor CLI#
bugzor profile upload cpu.pprof --dsn https://<public-key>@www.bugzor.com/<project-id> --name orders --release v7 --environment production --platform go
curl -s "localhost:6060/debug/pprof/profile?seconds=30" | bugzor profile upload - --name orders # BUGZOR_DSN in the environmentcurl#
curl -sS --fail-with-body -X POST \
-H "Authorization: Bearer <public-key>" --data-binary @cpu.pprof \
"https://www.bugzor.com/api/<project-id>/profile/pprof?name=orders&release=v7&environment=production&platform=go"The body is a pprof profile, gzip-compressed (what go tool pprof and runtime/pprof write) or plain protobuf. The query parameters are optional: name (your service or
job; it appears as the transaction you can filter by), release, environment, platform (go, rust, …). The key can also be sent as X-Sentry-Auth or ?sentry_key=.
A successful upload answers {"id", "samples", "stacks", "frames", "duration_ms"}.
Go#
func uploadCPUProfile(ctx context.Context, d time.Duration) error {
var buf bytes.Buffer
if err := pprof.StartCPUProfile(&buf); err != nil {
return err // another profile is already running
}
select {
case <-time.After(d):
case <-ctx.Done():
}
pprof.StopCPUProfile()
url := fmt.Sprintf("https://www.bugzor.com/api/%s/profile/pprof?name=orders&release=%s&environment=%s&platform=go",
os.Getenv("BUGZOR_PROJECT"), version, env)
req, _ := http.NewRequestWithContext(ctx, http.MethodPost, url, &buf)
req.Header.Set("Authorization", "Bearer "+os.Getenv("BUGZOR_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
if res.StatusCode == http.StatusTooManyRequests { // honour Retry-After before the next one
return fmt.Errorf("profile refused, retry after %s", res.Header.Get("Retry-After"))
}
return nil
}A CPU profile costs a few percent while it runs. One 10 to 30 second profile per instance every 5 to 10 minutes is a good start.
Rust#
pprof-rs (with its protobuf-codec feature) samples a running process and writes the same protobuf:
let guard = pprof::ProfilerGuardBuilder::default().frequency(100).blocklist(&["libc", "libgcc", "pthread", "vdso"]).build()?;
std::thread::sleep(std::time::Duration::from_secs(30));
let report = guard.report().build()?;
let mut body = Vec::new();
report.pprof()?.write_to_vec(&mut body)?; // pprof::protos::Message
ureq::post(&format!("https://www.bugzor.com/api/{project}/profile/pprof?name=api&platform=rust&release={release}"))
.set("Authorization", &format!("Bearer {key}"))
.send_bytes(&body)?;Any tool that writes pprof works the same way (perf through perf_data_converter, async-profiler’s pprof output). Build with debug symbols (debug = 1 in the Rust release
profile, no -ldflags="-s -w" in Go) or frames show as addresses.
What is accepted#
CPU profiles only: a samples/count column, or cpu, wall or time in nanoseconds (divided by the sampling period, 10 ms when the file does not say). Heap, allocation, goroutine,
mutex and block profiles are refused with a 422 that names the sample types the file has. pprof has no threads, so the thread filter shows one “all threads” entry.
Functions are named as the toolchain names them (main.handleOrder, github.com/acme/api.(*Server).Get, crate::module::function); inlined calls are separate frames; code from the
standard library and your dependencies is not marked as your own code.
| Answer | Meaning |
|---|---|
| 200 | stored |
200 with "duplicate": true | the same file was already uploaded; nothing was stored twice |
| 400 | not a pprof file, or over a limit (samples, functions, depth) |
| 401 | no key, or an unknown key |
| 403 | the plan has no Profiler (plan_required), the key is disabled, or the workspace is suspended |
| 413 | too large: 8 MiB uploaded, 48 MiB unpacked |
| 422 | not a CPU profile |
429 + Retry-After | too many profiles from this project, or the Profiler storage is full; wait and try again |
OpenTelemetry Profiles#
If you run the OpenTelemetry Collector or the OpenTelemetry eBPF profiler, send OTLP profiles (alpha) over HTTP/protobuf to https://otlp.bugzor.com/v1development/profiles
with the project key as Authorization: Bearer <public-key>. The resource’s service.name becomes the transaction, service.version the release and deployment.environment.name the environment.
Only CPU profiles are accepted, and JSON is not (protobuf only). In the Collector (run with --feature-gates=service.profilesSupport):
exporters:
otlp_http:
endpoint: https://otlp.bugzor.com
encoding: proto
headers:
Authorization: "Bearer <public-key>"
service:
pipelines:
profiles:
receivers: [pprof] # or the eBPF profiler's receiver
exporters: [otlp_http]Something unclear or out of date? Tell us.