Documentation ¶
Index ¶
- Constants
- func AggregateStacks(profile *pprofprofile.Profile) ([][]string, error)
- func AnyStackContains(foundStacks [][]string, stack []string) bool
- func ChooseArch() (string, error)
- func IsRunningOnCI() bool
- func NewTestProfiler(logger log.Logger, reg *prometheus.Registry, ofp *objectfile.Pool, ...) (*cpu.CPU, error)
- func ParsePrometheusMetricsEndpoint(content string) map[string]string
- func ProfileDuration() time.Duration
- func RequireAnyStackContains(t *testing.T, foundStacks [][]string, stack []string)
- func WaitForServer(url string) error
- type Sample
- type TestProfileStore
Constants ¶
const ( Arm64 = "arm64" Amd64 = "x86" )
Variables ¶
This section is empty.
Functions ¶
func AggregateStacks ¶
func AggregateStacks(profile *pprofprofile.Profile) ([][]string, error)
AggregateStacks aggregates the stacks of the given samples into a single slice.
func AnyStackContains ¶
AnyStackContains returns whether the passed string slice is contained in any of the slice of string slices. This is used to ensure that a stacktrace is contained in a given profile.
func IsRunningOnCI ¶
func IsRunningOnCI() bool
IsRunningOnCI returns whether we might be running in a continuous integration environment. GitHub Actions and most other CI platforms set the CI environment variable.
func NewTestProfiler ¶
func ParsePrometheusMetricsEndpoint ¶
ParsePrometheusMetricsEndpoint does some very light parsing of the metrics published in Prometheus.
func ProfileDuration ¶
ProfileDuration sets the profile runtime to a shorter time period when running outside of CI. The logic for this is that very loaded systems, such as GH actions might take a long time to spawn processes. By increasing the runtime we reduce the chance of flaky test executions, but we shouldn't have to pay this price during local dev.
func RequireAnyStackContains ¶
RequireAnyStackContains asserts that the given stack is contained in any of the given stacks.
func WaitForServer ¶
WaitForServer waits up to 100ms * 5. Returns an error if the HTTP server is not reachable and a nil error if it is.
Types ¶
type TestProfileStore ¶
type TestProfileStore struct {
Samples []Sample
}
func NewTestProfileStore ¶
func NewTestProfileStore() *TestProfileStore
func (*TestProfileStore) SampleForProcess ¶
func (tpw *TestProfileStore) SampleForProcess(pid int, last bool) *Sample
SampleForProcess returns the first or last matching sample for a given PID.
func (*TestProfileStore) Store ¶
func (tpw *TestProfileStore) Store(_ context.Context, labels model.LabelSet, profile profile.Writer, _ []*profilestorepb.ExecutableInfo) error