testhelper

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FooMapping = &profile.Mapping{
		ID:              1,
		Start:           uint64(1),
		Limit:           uint64(2),
		Offset:          uint64(3),
		File:            "foobar.so",
		BuildID:         "v1",
		HasFunctions:    true,
		HasFilenames:    true,
		HasLineNumbers:  true,
		HasInlineFrames: false,
	}
	FooFunction = &profile.Function{
		ID:         1,
		Name:       "foo",
		SystemName: "sfoo",
		Filename:   "foo.go",
		StartLine:  1,
	}
	FooLocation = &profile.Location{
		ID:       1,
		Address:  1,
		IsFolded: false,
		Mapping:  FooMapping,
		Line: []profile.Line{
			{
				Function: FooFunction,
				Line:     100,
			},
		},
	}
	BarFunction = &profile.Function{
		ID:         2,
		Name:       "bar",
		SystemName: "sbar",
		Filename:   "bar.go",
		StartLine:  1,
	}
	BarLocation = &profile.Location{
		ID:       2,
		Address:  2,
		IsFolded: true,
		Mapping:  FooMapping,
		Line: []profile.Line{
			{
				Function: BarFunction,
				Line:     200,
			},
		},
	}

	FooBarProfile = &profile.Profile{
		SampleType: []*profile.ValueType{
			{Type: "cpu", Unit: "nanoseconds"},
		},
		DefaultSampleType: "cpu",
		Sample: []*profile.Sample{
			{
				Value:    []int64{1},
				Location: []*profile.Location{FooLocation, BarLocation},
			},
			{
				Value:    []int64{2},
				Location: []*profile.Location{FooLocation},
			},
			{
				Value:    []int64{3},
				Location: []*profile.Location{BarLocation},
			},
		},
		TimeNanos:     1,
		DurationNanos: int64(15 * time.Nanosecond),
		Mapping:       []*profile.Mapping{FooMapping},
		Location:      []*profile.Location{FooLocation, BarLocation},
		Function:      []*profile.Function{FooFunction, BarFunction},
		PeriodType: &profile.ValueType{
			Type: "cpu",
			Unit: "nanoseconds",
		},
		Period: 10000000,
	}

	FooBarProfileWithSpans = &profile.Profile{
		SampleType: []*profile.ValueType{
			{Type: "cpu", Unit: "nanoseconds"},
		},
		DefaultSampleType: "cpu",
		Sample: []*profile.Sample{
			{
				Value:    []int64{1},
				Location: []*profile.Location{FooLocation, BarLocation},
				Label: map[string][]string{
					"span_id": {"badbadbadbadbada"},
				},
			},
			{
				Value:    []int64{1},
				Location: []*profile.Location{FooLocation, BarLocation},
				Label: map[string][]string{
					"span_id": {"badbadbadbadbadb"},
				},
			},
			{
				Value:    []int64{2},
				Location: []*profile.Location{FooLocation},
				Label: map[string][]string{
					"span_id": {"badbadbadbadbadb"},
				},
			},
			{
				Value:    []int64{3},
				Location: []*profile.Location{BarLocation},
			},
		},
		TimeNanos:     1,
		DurationNanos: int64(15 * time.Nanosecond),
		Mapping:       []*profile.Mapping{FooMapping},
		Location:      []*profile.Location{FooLocation, BarLocation},
		Function:      []*profile.Function{FooFunction, BarFunction},
		PeriodType: &profile.ValueType{
			Type: "cpu",
			Unit: "nanoseconds",
		},
		Period: 10000000,
	}
)

Functions

This section is empty.

Types

type ProfileBuilder

type ProfileBuilder struct {
	*profilev1.Profile

	uuid.UUID
	Labels []*typesv1.LabelPair
	// contains filtered or unexported fields
}

func NewProfileBuilder

func NewProfileBuilder(ts int64) *ProfileBuilder

NewProfileBuilder creates a new ProfileBuilder with the given nanoseconds timestamp.

func NewProfileBuilderWithLabels added in v1.1.0

func NewProfileBuilderWithLabels(ts int64, labels []*typesv1.LabelPair) *ProfileBuilder

NewProfileBuilderWithLabels creates a new ProfileBuilder with the given nanoseconds timestamp and labels.

func (*ProfileBuilder) AddExternalFunction added in v1.1.0

func (m *ProfileBuilder) AddExternalFunction(frame string, externalFunctionID uint32) uint64

func (*ProfileBuilder) AddExternalSample added in v1.2.0

func (m *ProfileBuilder) AddExternalSample(locs []uint64, values []int64, externalSampleID uint32)

func (*ProfileBuilder) AddExternalSampleWithLabels added in v1.3.0

func (m *ProfileBuilder) AddExternalSampleWithLabels(locs []uint64, values []int64, labels phlaremodel.Labels, locationsID, labelsID uint64)

func (*ProfileBuilder) AddSampleType

func (m *ProfileBuilder) AddSampleType(typ, unit string)

func (*ProfileBuilder) CPUProfile

func (m *ProfileBuilder) CPUProfile() *ProfileBuilder

func (*ProfileBuilder) CustomProfile

func (m *ProfileBuilder) CustomProfile(name, typ, unit, periodType, periodUnit string)

func (*ProfileBuilder) FindExternalSample added in v1.2.0

func (m *ProfileBuilder) FindExternalSample(externalSampleID uint32) *profilev1.Sample

func (*ProfileBuilder) FindExternalSampleWithLabels added in v1.3.0

func (m *ProfileBuilder) FindExternalSampleWithLabels(locationsID, labelsID uint64) *profilev1.Sample

func (*ProfileBuilder) FindLocationByExternalID added in v1.1.0

func (m *ProfileBuilder) FindLocationByExternalID(externalID uint32) (uint64, bool)

func (*ProfileBuilder) ForStacktraceString

func (m *ProfileBuilder) ForStacktraceString(stacktraces ...string) *StacktraceBuilder

func (*ProfileBuilder) MemoryProfile

func (m *ProfileBuilder) MemoryProfile() *ProfileBuilder

func (*ProfileBuilder) MetricName added in v1.1.0

func (m *ProfileBuilder) MetricName(name string)

func (*ProfileBuilder) Name

func (m *ProfileBuilder) Name() string

func (*ProfileBuilder) PeriodType added in v1.1.0

func (m *ProfileBuilder) PeriodType(periodType string, periodUnit string)

func (*ProfileBuilder) WithLabels

func (m *ProfileBuilder) WithLabels(lv ...string) *ProfileBuilder

type StacktraceBuilder

type StacktraceBuilder struct {
	*ProfileBuilder
	// contains filtered or unexported fields
}

func (*StacktraceBuilder) AddSamples

func (s *StacktraceBuilder) AddSamples(samples ...int64) *ProfileBuilder

Jump to

Keyboard shortcuts

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