Documentation
¶
Overview ¶
Package profile provides a representation of profile.proto and methods to encode/decode profiles in this format.
Index ¶
- type Function
- type Line
- type Location
- type Mapping
- type Profile
- func (p *Profile) Aggregate(inlineFrame, function, filename, linenumber, address bool) error
- func (p *Profile) CheckValid() error
- func (p *Profile) Compact() *Profile
- func (p *Profile) Copy() *Profile
- func (p *Profile) FilterSamplesByName(focus, ignore, hide, show *regexp.Regexp) (fm, im, hm, hnm bool)
- func (p *Profile) FilterSamplesByTag(focus, ignore TagMatch) (fm, im bool)
- func (p *Profile) FilterTagsByName(show, hide *regexp.Regexp) (sm, hm bool)
- func (p *Profile) HasFileLines() bool
- func (p *Profile) HasFunctions() bool
- func (p *Profile) ParseMemoryMap(rd io.Reader) error
- func (p *Profile) ParseMemoryMapFromScanner(s *bufio.Scanner) error
- func (p *Profile) Prune(dropRx, keepRx *regexp.Regexp)
- func (p *Profile) PruneFrom(dropRx *regexp.Regexp)
- func (p *Profile) RemoveUninteresting() error
- func (p *Profile) SampleIndexByName(sampleIndex string) (int, error)
- func (p *Profile) Scale(ratio float64)
- func (p *Profile) ScaleN(ratios []float64) error
- func (p *Profile) String() string
- func (p *Profile) Write(w io.Writer) error
- func (p *Profile) WriteUncompressed(w io.Writer) error
- type Sample
- type TagMatch
- type ValueType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Function ¶
type Function struct {
ID uint64
Name string
SystemName string
Filename string
StartLine int64
// contains filtered or unexported fields
}
Function corresponds to Profile.Function
type Location ¶
type Location struct {
ID uint64
Mapping *Mapping
Address uint64
Line []Line
// contains filtered or unexported fields
}
Location corresponds to Profile.Location
type Mapping ¶
type Mapping struct {
ID uint64
Start uint64
Limit uint64
Offset uint64
File string
BuildID string
HasFunctions bool
HasFilenames bool
HasLineNumbers bool
HasInlineFrames bool
// contains filtered or unexported fields
}
Mapping corresponds to Profile.Mapping
func ParseProcMaps ¶
ParseProcMaps parses a memory map in the format of /proc/self/maps. ParseMemoryMap should be called after setting on a profile to associate locations to the corresponding mapping based on their address.
func (*Mapping) Unsymbolizable ¶
Unsymbolizable returns true if a mapping points to a binary for which locations can't be symbolized in principle, at least now.
type Profile ¶
type Profile struct {
SampleType []*ValueType
DefaultSampleType string
Sample []*Sample
Mapping []*Mapping
Location []*Location
Function []*Function
Comments []string
DropFrames string
KeepFrames string
TimeNanos int64
DurationNanos int64
PeriodType *ValueType
Period int64
// contains filtered or unexported fields
}
Profile is an in-memory representation of profile.proto.
func Merge ¶
Merge merges all the profiles in profs into a single Profile. Returns a new profile independent of the input profiles. The merged profile is compacted to eliminate unused samples, locations, functions and mappings. Profiles must have identical profile sample and period types or the merge will fail. profile.Period of the resulting profile will be the maximum of all profiles, and profile.TimeNanos will be the earliest nonzero one.
func Parse ¶
Parse parses a profile and checks for its validity. The input may be a gzip-compressed encoded protobuf or one of many legacy profile formats which may be unsupported in the future.
func ParseUncompressed ¶
ParseUncompressed parses an uncompressed protobuf into a profile.
func (*Profile) Aggregate ¶
Aggregate merges the locations in the profile into equivalence classes preserving the request attributes. It also updates the samples to point to the merged locations.
func (*Profile) CheckValid ¶
CheckValid tests whether the profile is valid. Checks include, but are not limited to:
- len(Profile.Sample[n].value) == len(Profile.value_unit)
- Sample.id has a corresponding Profile.Location
func (*Profile) Compact ¶
Compact performs garbage collection on a profile to remove any unreferenced fields. This is useful to reduce the size of a profile after samples or locations have been removed.
func (*Profile) FilterSamplesByName ¶
func (p *Profile) FilterSamplesByName(focus, ignore, hide, show *regexp.Regexp) (fm, im, hm, hnm bool)
FilterSamplesByName filters the samples in a profile and only keeps samples where at least one frame matches focus but none match ignore. Returns true is the corresponding regexp matched at least one sample.
func (*Profile) FilterSamplesByTag ¶
FilterSamplesByTag removes all samples from the profile, except those that match focus and do not match the ignore regular expression.
func (*Profile) FilterTagsByName ¶
FilterTagsByName filters the tags in a profile and only keeps tags that match show and not hide.
func (*Profile) HasFileLines ¶
HasFileLines determines if all locations in this profile have symbolized file and line number information.
func (*Profile) HasFunctions ¶
HasFunctions determines if all locations in this profile have symbolized function information.
func (*Profile) ParseMemoryMap ¶
ParseMemoryMap parses a memory map in the format of /proc/self/maps, and overrides the mappings in the current profile. It renumbers the samples and locations in the profile correspondingly.
func (*Profile) ParseMemoryMapFromScanner ¶
ParseMemoryMapFromScanner parses a memory map in the format of /proc/self/maps or a variety of legacy format, and overrides the mappings in the current profile. It renumbers the samples and locations in the profile correspondingly.
func (*Profile) Prune ¶
Prune removes all nodes beneath a node matching dropRx, and not matching keepRx. If the root node of a Sample matches, the sample will have an empty stack.
func (*Profile) PruneFrom ¶
PruneFrom removes all nodes beneath the lowest node matching dropRx, not including itself.
Please see the example below to understand this method as well as the difference from Prune method.
A sample contains Location of [A,B,C,B,D] where D is the top frame and there's no inline.
PruneFrom(A) returns [A,B,C,B,D] because there's no node beneath A. Prune(A, nil) returns [B,C,B,D] by removing A itself.
PruneFrom(B) returns [B,C,B,D] by removing all nodes beneath the first B when scanning from the bottom. Prune(B, nil) returns [D] because a matching node is found by scanning from the root.
func (*Profile) RemoveUninteresting ¶
RemoveUninteresting prunes and elides profiles using built-in tables of uninteresting function names.
func (*Profile) SampleIndexByName ¶
SampleIndexByName returns the appropriate index for a value of sample index. If numeric, it returns the number, otherwise it looks up the text in the profile sample types.
func (*Profile) String ¶
String dumps a text representation of a profile. Intended mainly for debugging purposes.