integration

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
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

func AnyStackContains(foundStacks [][]string, stack []string) bool

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 ChooseArch

func ChooseArch() (string, error)

Choose host architecture.

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 NewTestProfiler(
	logger log.Logger,
	reg *prometheus.Registry,
	ofp *objectfile.Pool,
	profileStore profiler.ProfileStore,
	tempDir string,
	config *cpu.Config,
	relabelConfig ...*relabel.Config,
) (*cpu.CPU, error)

func ParsePrometheusMetricsEndpoint

func ParsePrometheusMetricsEndpoint(content string) map[string]string

ParsePrometheusMetricsEndpoint does some very light parsing of the metrics published in Prometheus.

func ProfileDuration

func ProfileDuration() time.Duration

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

func RequireAnyStackContains(t *testing.T, foundStacks [][]string, stack []string)

RequireAnyStackContains asserts that the given stack is contained in any of the given stacks.

func WaitForServer

func WaitForServer(url string) error

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 Sample

type Sample struct {
	Labels  model.LabelSet
	Profile *pprofprofile.Profile
}

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

Jump to

Keyboard shortcuts

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