pprof

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProfileIDLabelName = "profile_id" // For compatibility with the existing clients.
	SpanIDLabelName    = "span_id"    // Will be supported in the future.
)

Variables

This section is empty.

Functions

func CompareSampleLabels added in v1.1.0

func CompareSampleLabels(a, b []*profilev1.Label) int

CompareSampleLabels compares sample label pairs. It's expected that sample labels are sorted. The result will be 0 if a == b, < 0 if a < b, and > 0 if a > b.

func ConvertIDsToIndices added in v1.2.0

func ConvertIDsToIndices(p *profilev1.Profile)

func FilterLabelsInPlace added in v1.1.0

func FilterLabelsInPlace(labels []*profilev1.Label, keys []int64) int

func FromBytes

func FromBytes(input []byte, fn func(*profilev1.Profile, int) error) error

Read Profile from Bytes

func FromProfile

func FromProfile(p *profile.Profile) (*profilev1.Profile, error)

func GetLanguage added in v1.2.0

func GetLanguage(profile *Profile, logger log.Logger) string

func LabelID added in v1.2.0

func LabelID(p *profilev1.Profile, name string) int64

func LabelKeysByString added in v1.1.0

func LabelKeysByString(p *profilev1.Profile, keys ...string) []int64

func LabelKeysMapByString added in v1.1.0

func LabelKeysMapByString(p *profilev1.Profile, keys ...string) map[string]int64

func LabelsWithout added in v1.1.0

func LabelsWithout(labels []*profilev1.Label, keys []int64) []*profilev1.Label

func Marshal added in v1.2.1

func Marshal(p *profilev1.Profile, compress bool) ([]byte, error)

func ProfileSpans added in v1.2.0

func ProfileSpans(p *profilev1.Profile) []uint64

func RenameLabel added in v1.1.0

func RenameLabel(p *profilev1.Profile, oldName, newName string)

func RewriteFunctions added in v1.2.0

func RewriteFunctions(p *profilev1.Profile, n []uint32)

func RewriteFunctionsWithMap added in v1.2.0

func RewriteFunctionsWithMap(p *profilev1.Profile, n map[uint64]uint64)

func RewriteLocations added in v1.2.0

func RewriteLocations(p *profilev1.Profile, n []uint32)

func RewriteLocationsWithMap added in v1.2.0

func RewriteLocationsWithMap(p *profilev1.Profile, n map[uint64]uint64)

func RewriteMappings added in v1.2.0

func RewriteMappings(p *profilev1.Profile, n []uint32)

func RewriteMappingsWithMap added in v1.2.0

func RewriteMappingsWithMap(p *profilev1.Profile, n map[uint64]uint64)

func RewriteStrings added in v1.2.0

func RewriteStrings(p *profilev1.Profile, n []uint32)

func SetProfileMetadata added in v1.2.1

func SetProfileMetadata(p *profilev1.Profile, ty *typesv1.ProfileType, timeNanos int64, period int64)

SetProfileMetadata sets the metadata on the profile.

func Unmarshal added in v1.2.1

func Unmarshal(data []byte, p *profilev1.Profile) error

func ZeroLabelStrings added in v1.2.0

func ZeroLabelStrings(p *profilev1.Profile)

Types

type FunctionKey added in v1.2.0

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

func GetFunctionKey added in v1.2.0

func GetFunctionKey(fn *profilev1.Function) FunctionKey

type LabelsByKeyValue added in v1.1.0

type LabelsByKeyValue []*profilev1.Label

func (LabelsByKeyValue) Len added in v1.1.0

func (l LabelsByKeyValue) Len() int

func (LabelsByKeyValue) Less added in v1.1.0

func (l LabelsByKeyValue) Less(i, j int) bool

func (LabelsByKeyValue) Swap added in v1.1.0

func (l LabelsByKeyValue) Swap(i, j int)

type LocationKey added in v1.2.0

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

func GetLocationKey added in v1.2.0

func GetLocationKey(loc *profilev1.Location) LocationKey

type MappingKey added in v1.2.0

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

func GetMappingKey added in v1.2.0

func GetMappingKey(m *profilev1.Mapping) MappingKey

type Profile

type Profile struct {
	*profilev1.Profile
	// contains filtered or unexported fields
}

func NewProfile added in v1.1.0

func NewProfile() *Profile

func OpenFile

func OpenFile(path string) (*Profile, error)

func RawFromBytes

func RawFromBytes(input []byte) (_ *Profile, err error)

Read RawProfile from bytes

func RawFromProto added in v1.1.0

func RawFromProto(pbp *profilev1.Profile) *Profile

func (*Profile) Close

func (p *Profile) Close()

func (*Profile) Normalize

func (p *Profile) Normalize()

Normalize normalizes the profile by:

  • Removing all duplicate samples (summing their values).
  • Removing redundant profile labels (byte => unique of an allocation site) todo: We should reassess if this was a good choice because by merging duplicate stacktrace samples we cannot recompute the allocation per site ("bytes") profile label.
  • Removing empty samples.
  • Then remove unused references.
  • Ensure that the profile has a time_nanos set
  • Removes addresses from symbolized profiles.

func (*Profile) SizeBytes

func (p *Profile) SizeBytes() int

func (*Profile) WriteTo

func (p *Profile) WriteTo(w io.Writer) (int64, error)

WriteTo writes the profile to the given writer.

type ProfileMerge added in v1.2.0

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

func (*ProfileMerge) Merge added in v1.2.0

func (m *ProfileMerge) Merge(p *profilev1.Profile) error

Merge adds p to the profile merge. Profile is modified in place but not retained by the function.

func (*ProfileMerge) Profile added in v1.2.0

func (m *ProfileMerge) Profile() *profilev1.Profile

type RewriteTable added in v1.2.0

type RewriteTable[K comparable, V, M any] struct {
	// contains filtered or unexported fields
}

RewriteTable maintains unique values V and their indices. V is never modified nor retained, K and M are kept in memory.

func NewRewriteTable added in v1.2.0

func NewRewriteTable[K comparable, V, M any](
	size int,
	k func(V) K,
	v func(V) M,
) RewriteTable[K, V, M]

func (*RewriteTable[K, V, M]) Append added in v1.2.0

func (t *RewriteTable[K, V, M]) Append(values []V)

func (*RewriteTable[K, V, M]) Index added in v1.2.0

func (t *RewriteTable[K, V, M]) Index(dst []uint32, values []V)

func (*RewriteTable[K, V, M]) Values added in v1.2.0

func (t *RewriteTable[K, V, M]) Values() []M

type SampleExporter added in v1.1.0

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

func NewSampleExporter added in v1.1.0

func NewSampleExporter(p *profilev1.Profile) *SampleExporter

func (*SampleExporter) ExportSamples added in v1.1.0

func (e *SampleExporter) ExportSamples(dst *profilev1.Profile, samples []*profilev1.Sample) *profilev1.Profile

ExportSamples creates a new complete profile with the subset of samples provided. It is assumed that those are part of the source profile. Provided samples are modified in place.

The same exporter instance can be used to export non-overlapping sample sets from a single profile.

type SampleGroup added in v1.1.0

type SampleGroup struct {
	Labels  []*profilev1.Label
	Samples []*profilev1.Sample
}

func GroupSamplesByLabels added in v1.1.0

func GroupSamplesByLabels(p *profilev1.Profile) []SampleGroup

GroupSamplesByLabels splits samples into groups by labels. It's expected that sample labels are sorted.

func GroupSamplesWithoutLabels added in v1.1.0

func GroupSamplesWithoutLabels(p *profilev1.Profile, labels ...string) []SampleGroup

GroupSamplesWithoutLabels splits samples into groups by labels ignoring ones from the list: those are preserved as sample labels. It's expected that sample labels are sorted.

func GroupSamplesWithoutLabelsByKey added in v1.1.0

func GroupSamplesWithoutLabelsByKey(p *profilev1.Profile, keys []int64) []SampleGroup

type SampleHasher added in v1.1.0

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

func (SampleHasher) Hashes added in v1.1.0

func (h SampleHasher) Hashes(samples []*profilev1.Sample) []uint64

type SampleKey added in v1.2.0

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

func GetSampleKey added in v1.2.0

func GetSampleKey(s *profilev1.Sample) SampleKey

type SamplesByLabels added in v1.1.0

type SamplesByLabels []*profilev1.Sample

func (SamplesByLabels) Len added in v1.1.0

func (s SamplesByLabels) Len() int

func (SamplesByLabels) Less added in v1.1.0

func (s SamplesByLabels) Less(i, j int) bool

func (SamplesByLabels) Swap added in v1.1.0

func (s SamplesByLabels) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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