profile

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package profile captures phase timing, CPU profiles, and HTTP round-trip logs for performance analysis.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GraphQLLabel

func GraphQLLabel(ctx context.Context) string

GraphQLLabel extracts the operation label from ctx, or "" if absent.

func WithGraphQLLabel

func WithGraphQLLabel(ctx context.Context, label string) context.Context

WithGraphQLLabel returns a context that tags subsequent HTTP requests with a GraphQL operation label (e.g. "resolve", "reachability", "peel"). The loggingTransport uses this to break down POST /graphql by purpose.

Types

type HTTPLog

type HTTPLog struct {
	// contains filtered or unexported fields
}

HTTPLog collects per-request timing data.

func (*HTTPLog) Total

func (h *HTTPLog) Total() int64

Total returns the number of HTTP round trips recorded.

func (*HTTPLog) WriteSummary

func (h *HTTPLog) WriteSummary(w io.Writer)

WriteSummary prints aggregated HTTP stats.

type Options

type Options struct {
	TracePath      string // runtime/trace output file (viewable with `go tool trace`)
	CPUProfilePath string // pprof CPU profile output file
	HTTPLog        bool   // log every HTTP round-trip
	Output         io.Writer
}

Options configures what profiling to enable.

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session holds all profiling state for one CLI invocation. Create with Start, tear down with Stop (writes summaries).

func Start

func Start(opts Options) (*Session, error)

Start begins profiling. Returns a no-op session if nothing is enabled.

func (*Session) Enabled

func (s *Session) Enabled() bool

Enabled reports whether any profiling is active.

func (*Session) Phase

func (s *Session) Phase(name string) func()

Phase records wall-clock timing for a named phase. Call the returned function when the phase ends.

func (*Session) Stop

func (s *Session) Stop()

Stop ends profiling, writes summary, closes files.

func (*Session) WrapTransport

func (s *Session) WrapTransport(rt http.RoundTripper) http.RoundTripper

WrapTransport wraps an http.RoundTripper with request logging. Returns the original transport if HTTP logging is disabled.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL