Documentation
¶
Overview ¶
Package profilequery reads continuous profiles back out of ClickHouse and writes them in formats other tools open.
It is the reusable half of `forge obs profile`: nothing here shells out or touches a terminal. Stacks come from the tables docker-compose.yml's `profiles-schema` job creates (see profiles-schema.sql in a scaffolded project); Stack is the interchange value, and Pprof, Speedscope and Folded write it for `go tool pprof`, speedscope.app (and an embedded speedscope view) and flamegraph.pl respectively.
Index ¶
Constants ¶
const RangeSQL = `` /* 605-byte string literal not displayed */
RangeSQL is the aggregated-flamegraph statement: stacks of one service and sample type between {from} and {to}, from the per-minute table joined to the stack dictionary. Output columns: frames (root to leaf), unit, value.
const ServicesSQL = `` /* 212-byte string literal not displayed */
ServicesSQL lists the services that sent profiles in a range, for when the caller did not name one.
const TraceSQL = `` /* 373-byte string literal not displayed */
TraceSQL reads the raw tier for the samples linked to a trace (and optionally a span). Output columns match RangeSQL.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Profile ¶
type Profile struct {
Service string
SampleType string // cpu, alloc_space, inuse_space, goroutine, ...
Unit string // nanoseconds, bytes, count
From, To time.Time
Stacks []Stack
}
Profile is an aggregated profile: the stacks of one service and sample type over a time range, or of one trace.
func (Profile) Folded ¶
Folded writes the collapsed-stack format: "root;child;leaf value" per line. flamegraph.pl, speedscope and d3-flamegraph all read it.
func (Profile) Pprof ¶
Pprof writes a gzip-compressed pprof profile that `go tool pprof` opens. Only function names survive the trip through ClickHouse's stack dictionary, so there are no line numbers or addresses; -top, -tree, -peek and -http flamegraphs all work.
func (Profile) Speedscope ¶
Speedscope writes speedscope's file format (a single "sampled" profile), the shape an embedded speedscope view loads directly.
type Query ¶
type Query struct {
Service string
SampleType string
// Env filters on deployment.environment.name when non-empty (range queries only).
Env string
From, To time.Time
// TraceID, when set, reads the RAW tier for that trace instead of the
// per-minute aggregate: the samples whose goroutine was serving the trace's
// spans. Raw rows live 24h; the aggregate 30d.
TraceID string
// SpanID narrows a trace query to one span.
SpanID string
}
Query selects what to read. SQL turns it into a statement with named parameters; callers pass Params to the client, never string-concatenate.