Documentation ¶
Index ¶
- Constants
- func CloneLabelPairs(lbs []*typesv1.LabelPair) []*typesv1.LabelPair
- func CompareLabelPairs(a []*typesv1.LabelPair, b []*typesv1.LabelPair) int
- func CompareProfile(a, b *ingestv1.Profile) int64
- func ExportDiffToFlamebearer(fg *querierv1.FlameGraphDiff, profileType *typesv1.ProfileType) *flamebearer.FlamebearerProfile
- func ExportToFlamebearer(fg *querierv1.FlameGraph, profileType *typesv1.ProfileType) *flamebearer.FlamebearerProfile
- func LabelPairsString(lbs []*typesv1.LabelPair) string
- func MergeBatchMergeStacktraces(responses ...*ingestv1.MergeProfilesStacktracesResult) *ingestv1.MergeProfilesStacktracesResult
- func NewFlameGraph(t *Tree, maxNodes int64) *querierv1.FlameGraph
- func NewFlamegraphDiff(left, right *Tree, maxNodes int) (*querierv1.FlameGraphDiff, error)
- func ParseProfileTypeSelector(id string) (*typesv1.ProfileType, error)
- func SelectorFromProfileType(profileType *typesv1.ProfileType) *labels.Matcher
- func SetProfileMetadata(p *profile.Profile, ty *typesv1.ProfileType)
- func StringToLabelsPairs(s string) ([]*typesv1.LabelPair, error)
- func SumSeries(series ...[]*typesv1.Series) []*typesv1.Series
- type FlameGraphMerger
- type Labels
- func (ls Labels) BytesWithLabels(buf []byte, names ...string) []byte
- func (ls Labels) Clone() Labels
- func (ls Labels) Get(name string) string
- func (ls Labels) Hash() uint64
- func (ls Labels) HashForLabels(b []byte, names ...string) (uint64, []byte)
- func (ls Labels) HashWithoutLabels(b []byte, names ...string) (uint64, []byte)
- func (ls Labels) Len() int
- func (ls Labels) Less(i, j int) bool
- func (ls Labels) Swap(i, j int)
- func (ls Labels) ToPrometheusLabels() labels.Labels
- func (ls Labels) WithLabels(names ...string) Labels
- func (ls Labels) WithoutPrivateLabels() Labels
- type LabelsBuilder
- type SeriesMerger
- type Stack
- type StacktraceMerger
- type StacktracesHasher
- type Tree
- type TreeMerger
Constants ¶
const ( LabelNameProfileType = "__profile_type__" LabelNameType = "__type__" LabelNameUnit = "__unit__" LabelNamePeriodType = "__period_type__" LabelNamePeriodUnit = "__period_unit__" LabelNameDelta = "__delta__" LabelNameProfileName = pmodel.MetricNameLabel )
const MaxNodes = 8192
Variables ¶
This section is empty.
Functions ¶
func CloneLabelPairs ¶
CloneLabelPairs clones the label pairs.
func CompareLabelPairs ¶
Compare compares the two label sets. The result will be 0 if a==b, <0 if a < b, and >0 if a > b.
func CompareProfile ¶
CompareProfile compares the two profiles.
func ExportDiffToFlamebearer ¶ added in v0.6.0
func ExportDiffToFlamebearer(fg *querierv1.FlameGraphDiff, profileType *typesv1.ProfileType) *flamebearer.FlamebearerProfile
func ExportToFlamebearer ¶ added in v0.6.0
func ExportToFlamebearer(fg *querierv1.FlameGraph, profileType *typesv1.ProfileType) *flamebearer.FlamebearerProfile
ExportToFlamebearer exports the flamegraph to a Flamebearer struct.
func LabelPairsString ¶
LabelPairsString returns a string representation of the label pairs.
func MergeBatchMergeStacktraces ¶
func MergeBatchMergeStacktraces(responses ...*ingestv1.MergeProfilesStacktracesResult) *ingestv1.MergeProfilesStacktracesResult
func NewFlameGraph ¶ added in v0.6.0
func NewFlameGraph(t *Tree, maxNodes int64) *querierv1.FlameGraph
func NewFlamegraphDiff ¶ added in v0.6.0
func NewFlamegraphDiff(left, right *Tree, maxNodes int) (*querierv1.FlameGraphDiff, error)
NewFlamegraphDiff generates a FlameGraphDiff from 2 trees. It also prunes the final tree based on the maxNodes parameter Notice that the resulting FlameGraph can't be used interchangeably with a 'single' Flamegraph Due to many differences: * Nodes * It's structure is different
i+0 = x offset, left tree i+1 = total , left tree i+2 = self , left tree i+3 = x offset, right tree i+4 = total , right tree i+5 = self , right tree i+6 = index in the names array
func ParseProfileTypeSelector ¶
func ParseProfileTypeSelector(id string) (*typesv1.ProfileType, error)
ParseProfileTypeSelector parses the profile selector string.
func SelectorFromProfileType ¶
func SelectorFromProfileType(profileType *typesv1.ProfileType) *labels.Matcher
SelectorFromProfileType builds a *label.Matcher from an profile type struct
func SetProfileMetadata ¶ added in v0.6.0
func SetProfileMetadata(p *profile.Profile, ty *typesv1.ProfileType)
SetProfileMetadata sets the metadata on the profile.
func StringToLabelsPairs ¶
StringToLabelsPairs converts a string representation of label pairs to a slice of label pairs.
Types ¶
type FlameGraphMerger ¶ added in v0.6.1
type FlameGraphMerger struct {
// contains filtered or unexported fields
}
func NewFlameGraphMerger ¶ added in v0.6.1
func NewFlameGraphMerger() *FlameGraphMerger
func (*FlameGraphMerger) FlameGraph ¶ added in v0.6.1
func (m *FlameGraphMerger) FlameGraph(maxNodes int64) *querierv1.FlameGraph
func (*FlameGraphMerger) MergeFlameGraph ¶ added in v0.6.1
func (m *FlameGraphMerger) MergeFlameGraph(src *querierv1.FlameGraph)
MergeFlameGraph adds the flame graph stack traces to the resulting flame graph. The call is thread-safe, but the resulting flame graph or tree should be only accessed after all the samples are merged.
func (*FlameGraphMerger) Tree ¶ added in v0.6.1
func (m *FlameGraphMerger) Tree() *Tree
type Labels ¶
Labels is a sorted set of labels. Order has to be guaranteed upon instantiation.
func LabelsFromStrings ¶
LabelsFromStrings creates new labels from pairs of strings.
func (Labels) BytesWithLabels ¶
BytesWithLabels is just as Bytes(), but only for labels matching names. 'names' have to be sorted in ascending order. It uses an byte invalid character as a separator and so should not be used for printing.
func (Labels) Get ¶
Get returns the value for the label with the given name. Returns an empty string if the label doesn't exist.
func (Labels) HashForLabels ¶
HashForLabels returns a hash value for the labels matching the provided names. 'names' have to be sorted in ascending order.
func (Labels) HashWithoutLabels ¶
HashWithoutLabels returns a hash value for all labels except those matching the provided names. 'names' have to be sorted in ascending order.
func (Labels) ToPrometheusLabels ¶
func (Labels) WithLabels ¶
WithLabels returns a subset of Labels that matches match with the provided label names.
func (Labels) WithoutPrivateLabels ¶
type LabelsBuilder ¶
type LabelsBuilder struct {
// contains filtered or unexported fields
}
LabelsBuilder allows modifying Labels.
func NewLabelsBuilder ¶
func NewLabelsBuilder(base Labels) *LabelsBuilder
NewLabelsBuilder returns a new LabelsBuilder.
func (*LabelsBuilder) Del ¶
func (b *LabelsBuilder) Del(ns ...string) *LabelsBuilder
Del deletes the label of the given name.
func (*LabelsBuilder) Labels ¶
func (b *LabelsBuilder) Labels() Labels
Labels returns the labels from the builder. If no modifications were made, the original labels are returned.
func (*LabelsBuilder) Reset ¶
func (b *LabelsBuilder) Reset(base Labels)
Reset clears all current state for the builder.
func (*LabelsBuilder) Set ¶
func (b *LabelsBuilder) Set(n, v string) *LabelsBuilder
Set the name/value pair as a label.
type SeriesMerger ¶ added in v0.6.1
type SeriesMerger struct {
// contains filtered or unexported fields
}
func NewSeriesMerger ¶ added in v0.6.1
func NewSeriesMerger(sum bool) *SeriesMerger
NewSeriesMerger creates a new series merger. If sum is set, samples with matching timestamps are summed, otherwise duplicates are discarded.
func (*SeriesMerger) MergeSeries ¶ added in v0.6.1
func (m *SeriesMerger) MergeSeries(s []*typesv1.Series)
func (*SeriesMerger) Series ¶ added in v0.6.1
func (m *SeriesMerger) Series() []*typesv1.Series
type Stack ¶ added in v0.6.0
type Stack[T any] struct { // contains filtered or unexported fields }
Stack is a stack of values. Pushing and popping values is O(1).
func (*Stack[T]) Push ¶ added in v0.6.0
func (s *Stack[T]) Push(v T)
Push adds a value to the top of the stack.
type StacktraceMerger ¶ added in v0.6.0
type StacktraceMerger struct {
// contains filtered or unexported fields
}
func NewStackTraceMerger ¶ added in v0.6.0
func NewStackTraceMerger() *StacktraceMerger
NewStackTraceMerger merges collections of StacktraceSamples. The result is a byte tree representation of the merged samples.
func (*StacktraceMerger) MergeStackTraces ¶ added in v0.6.0
func (m *StacktraceMerger) MergeStackTraces(stacks []*ingestv1.StacktraceSample, names []string)
MergeStackTraces adds the stack traces to the resulting tree. The call is thread-safe, but the resulting tree bytes should be only build after all the samples are merged. Note that the function may reuse the capacity of the names slice.
func (*StacktraceMerger) Size ¶ added in v0.6.0
func (m *StacktraceMerger) Size() int
func (*StacktraceMerger) TreeBytes ¶ added in v0.6.0
func (m *StacktraceMerger) TreeBytes(maxNodes int64) []byte
type StacktracesHasher ¶
type StacktracesHasher struct {
// contains filtered or unexported fields
}
func (StacktracesHasher) Hashes ¶
func (h StacktracesHasher) Hashes(fnIds []int32) uint64
todo we might want to reuse the results to avoid allocations
type Tree ¶ added in v0.6.0
type Tree struct {
// contains filtered or unexported fields
}
func UnmarshalTree ¶ added in v0.6.0
func (*Tree) InsertStack ¶ added in v0.6.0
func (*Tree) MarshalTruncate ¶ added in v0.6.0
MarshalTruncate writes tree byte representation to the writer provider, the number of nodes is limited to maxNodes. The function modifies the tree: truncated nodes are removed from the tree.
type TreeMerger ¶ added in v0.6.0
type TreeMerger struct {
// contains filtered or unexported fields
}
func NewTreeMerger ¶ added in v0.6.0
func NewTreeMerger() *TreeMerger
func (*TreeMerger) MergeTreeBytes ¶ added in v0.6.0
func (m *TreeMerger) MergeTreeBytes(b []byte) error
func (*TreeMerger) Tree ¶ added in v0.6.0
func (m *TreeMerger) Tree() *Tree