Documentation ¶
Index ¶
- Constants
- 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 GetSafeTimeRange(now time.Time, req any) model.Interval
- func GetTimeRange(req TimeRangeRequest) (model.Interval, bool)
- func IsLabelAllowedForIngestion(name string) bool
- func LabelPairsString(lbs []*typesv1.LabelPair) string
- func MergeSeries(aggregation *typesv1.TimeSeriesAggregationType, series ...[]*typesv1.Series) []*typesv1.Series
- func NewFlameGraph(t *Tree, maxNodes int64) *querierv1.FlameGraph
- func NewFlamegraphDiff(left, right *Tree, maxNodes int64) (*querierv1.FlameGraphDiff, error)
- func NewFlamegraphDiffFromBytes(left, right []byte, maxNodes int64) (*querierv1.FlameGraphDiff, error)
- func NewMergeIterator[P Profile](max P, deduplicate bool, iters ...iter.Iterator[P]) iter.Iterator[P]
- func NewTimeRangedIterator[T Timestamp](it iter.Iterator[T], min, max model.Time) iter.Iterator[T]
- func NewTimeSeriesMergeIterator(series []*typesv1.Series) iter.Iterator[TimeSeriesValue]
- func ParseProfileTypeSelector(id string) (*typesv1.ProfileType, error)
- func RangeSeries(it iter.Iterator[TimeSeriesValue], start, end, step int64, ...) []*typesv1.Series
- func SelectorFromProfileType(profileType *typesv1.ProfileType) *labels.Matcher
- func SetTimeRange(r interface{}, startTime, endTime model.Time) bool
- func StacktracePartitionFromProfile(lbls []Labels, p *profilev1.Profile) uint64
- func TopSeries(s []*typesv1.Series, k int) []*typesv1.Series
- type FlameGraphMerger
- type LabelMerger
- func (m *LabelMerger) HasNames() bool
- func (m *LabelMerger) HasSeries() bool
- func (m *LabelMerger) HasValues() bool
- func (m *LabelMerger) LabelNames() []string
- func (m *LabelMerger) LabelValues() []string
- func (m *LabelMerger) MergeLabelNames(names []string)
- func (m *LabelMerger) MergeLabelValues(values []string)
- func (m *LabelMerger) MergeSeries(series []*typesv1.Labels)
- func (m *LabelMerger) SeriesLabels() []*typesv1.Labels
- type Labels
- func (ls Labels) BytesWithLabels(buf []byte, names ...string) []byte
- func (ls Labels) Clone() Labels
- func (ls Labels) Delete(name string) Labels
- func (ls Labels) Get(name string) string
- func (ls Labels) GetLabel(name string) (*typesv1.LabelPair, bool)
- func (ls Labels) Hash() uint64
- func (ls Labels) InsertSorted(name, value string) Labels
- func (ls Labels) Len() int
- func (ls Labels) Less(i, j int) bool
- func (ls Labels) Range(f func(l *typesv1.LabelPair))
- func (ls Labels) Swap(i, j int)
- func (ls Labels) ToPrometheusLabels() labels.Labels
- func (ls Labels) Unique() Labels
- func (ls Labels) WithLabels(names ...string) Labels
- func (ls Labels) WithoutPrivateLabels() Labels
- type LabelsBuilder
- func (b *LabelsBuilder) Del(ns ...string) *LabelsBuilder
- func (b *LabelsBuilder) Get(n string) string
- func (b *LabelsBuilder) Labels() Labels
- func (b *LabelsBuilder) LabelsUnsorted() Labels
- func (b *LabelsBuilder) Range(f func(l *typesv1.LabelPair))
- func (b *LabelsBuilder) Reset(base Labels)
- func (b *LabelsBuilder) Set(n, v string) *LabelsBuilder
- type LabelsEnforcedOrder
- type MergeIterator
- type Profile
- type ServiceVersion
- type SessionID
- type SpanSelector
- type Stack
- type StacktraceMerger
- type StacktraceNode
- type StacktraceTree
- func (t *StacktraceTree) Bytes(dst io.Writer, maxNodes int64, funcs []string)
- func (t *StacktraceTree) Insert(locations []int32, value int64) int32
- func (t *StacktraceTree) LookupLocations(dst []uint64, idx int32) []uint64
- func (t *StacktraceTree) MinValue(maxNodes int64) int64
- func (t *StacktraceTree) Reset()
- func (t *StacktraceTree) Traverse(maxNodes int64, fn StacktraceTreeTraverseFn) error
- func (t *StacktraceTree) Tree(maxNodes int64, names []string) *Tree
- type StacktraceTreeTraverseFn
- type TimeRangeRequest
- type TimeRangedIterator
- type TimeSeriesAggregator
- type TimeSeriesBuilder
- type TimeSeriesIterator
- type TimeSeriesMerger
- type TimeSeriesValue
- type Timestamp
- type Tree
- func (t *Tree) Bytes(maxNodes int64) []byte
- func (t *Tree) Fix()
- func (t *Tree) FormatNodeNames(fn func(string) string)
- func (t *Tree) InsertStack(v int64, stack ...string)
- func (t *Tree) IterateStacks(cb func(name string, self int64, stack []string))
- func (t *Tree) MarshalTruncate(w io.Writer, maxNodes int64) (err error)
- func (t *Tree) Merge(src *Tree)
- func (t *Tree) String() string
- func (t *Tree) Total() (v int64)
- func (t *Tree) WriteCollapsed(dst io.Writer)
- type TreeMerger
Constants ¶
const ( LabelNameProfileType = "__profile_type__" LabelNameServiceNamePrivate = "__service_name__" LabelNameDelta = "__delta__" LabelNameProfileName = pmodel.MetricNameLabel LabelNamePeriodType = "__period_type__" LabelNamePeriodUnit = "__period_unit__" LabelNameSessionID = "__session_id__" LabelNameType = "__type__" LabelNameUnit = "__unit__" LabelNameServiceGitRef = "service_git_ref" LabelNameServiceName = "service_name" LabelNameServiceRepository = "service_repository" LabelNameServiceRootPath = "service_root_path" LabelNameOrder = "__order__" LabelOrderEnforced = "enforced" LabelNamePyroscopeSpy = "pyroscope_spy" )
Variables ¶
This section is empty.
Functions ¶
func CompareLabelPairs ¶
CompareLabelPairs 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 ¶
func ExportDiffToFlamebearer(fg *querierv1.FlameGraphDiff, profileType *typesv1.ProfileType) *flamebearer.FlamebearerProfile
func ExportToFlamebearer ¶
func ExportToFlamebearer(fg *querierv1.FlameGraph, profileType *typesv1.ProfileType) *flamebearer.FlamebearerProfile
ExportToFlamebearer exports the flamegraph to a Flamebearer struct.
func GetSafeTimeRange ¶ added in v1.8.0
func GetTimeRange ¶ added in v1.2.0
func GetTimeRange(req TimeRangeRequest) (model.Interval, bool)
GetTimeRange returns the time interval and true if the request has an interval, otherwise ok is false.
func IsLabelAllowedForIngestion ¶ added in v1.1.0
func LabelPairsString ¶
LabelPairsString returns a string representation of the label pairs.
func MergeSeries ¶ added in v1.2.1
func NewFlameGraph ¶
func NewFlameGraph(t *Tree, maxNodes int64) *querierv1.FlameGraph
func NewFlamegraphDiff ¶
func NewFlamegraphDiff(left, right *Tree, maxNodes int64) (*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 NewFlamegraphDiffFromBytes ¶ added in v1.8.0
func NewFlamegraphDiffFromBytes(left, right []byte, maxNodes int64) (*querierv1.FlameGraphDiff, error)
func NewMergeIterator ¶ added in v1.8.0
func NewMergeIterator[P Profile](max P, deduplicate bool, iters ...iter.Iterator[P]) iter.Iterator[P]
NewMergeIterator returns an iterator that k-way merges the given iterators. The given iterators must be sorted by timestamp and labels themselves. Optionally, the iterator can deduplicate profiles with the same timestamp and labels.
func NewTimeRangedIterator ¶ added in v1.8.0
func NewTimeSeriesMergeIterator ¶ added in v1.8.0
func NewTimeSeriesMergeIterator(series []*typesv1.Series) iter.Iterator[TimeSeriesValue]
func ParseProfileTypeSelector ¶
func ParseProfileTypeSelector(id string) (*typesv1.ProfileType, error)
ParseProfileTypeSelector parses the profile selector string.
func RangeSeries ¶ added in v1.8.0
func RangeSeries(it iter.Iterator[TimeSeriesValue], start, end, step int64, aggregation *typesv1.TimeSeriesAggregationType) []*typesv1.Series
RangeSeries aggregates profiles into series. Series contains points spaced by step from start to end. Profiles from the same step are aggregated into one point.
func SelectorFromProfileType ¶
func SelectorFromProfileType(profileType *typesv1.ProfileType) *labels.Matcher
SelectorFromProfileType builds a *label.Matcher from an profile type struct
func SetTimeRange ¶ added in v1.8.0
Types ¶
type FlameGraphMerger ¶
type FlameGraphMerger struct {
// contains filtered or unexported fields
}
func NewFlameGraphMerger ¶
func NewFlameGraphMerger() *FlameGraphMerger
func (*FlameGraphMerger) FlameGraph ¶
func (m *FlameGraphMerger) FlameGraph(maxNodes int64) *querierv1.FlameGraph
func (*FlameGraphMerger) MergeFlameGraph ¶
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) MergeTreeBytes ¶ added in v1.7.0
func (m *FlameGraphMerger) MergeTreeBytes(src []byte) error
func (*FlameGraphMerger) Tree ¶
func (m *FlameGraphMerger) Tree() *Tree
type LabelMerger ¶ added in v1.8.0
type LabelMerger struct {
// contains filtered or unexported fields
}
func NewLabelMerger ¶ added in v1.8.0
func NewLabelMerger() *LabelMerger
func (*LabelMerger) HasNames ¶ added in v1.8.0
func (m *LabelMerger) HasNames() bool
func (*LabelMerger) HasSeries ¶ added in v1.8.0
func (m *LabelMerger) HasSeries() bool
func (*LabelMerger) HasValues ¶ added in v1.8.0
func (m *LabelMerger) HasValues() bool
func (*LabelMerger) LabelNames ¶ added in v1.8.0
func (m *LabelMerger) LabelNames() []string
func (*LabelMerger) LabelValues ¶ added in v1.8.0
func (m *LabelMerger) LabelValues() []string
func (*LabelMerger) MergeLabelNames ¶ added in v1.8.0
func (m *LabelMerger) MergeLabelNames(names []string)
func (*LabelMerger) MergeLabelValues ¶ added in v1.8.0
func (m *LabelMerger) MergeLabelValues(values []string)
func (*LabelMerger) MergeSeries ¶ added in v1.8.0
func (m *LabelMerger) MergeSeries(series []*typesv1.Labels)
func (*LabelMerger) SeriesLabels ¶ added in v1.8.0
func (m *LabelMerger) SeriesLabels() []*typesv1.Labels
type Labels ¶
Labels is a sorted set of labels. Order has to be guaranteed upon instantiation.
func EmptyLabels ¶ added in v1.7.0
func EmptyLabels() Labels
EmptyLabels returns n empty Labels value, for convenience.
func LabelsFromMap ¶ added in v1.7.0
LabelsFromMap returns new sorted Labels from the given map.
func LabelsFromStrings ¶
LabelsFromStrings creates new labels from pairs of strings.
func (Labels) BytesWithLabels ¶
BytesWithLabels is just as Bytes(), but only for labels matching names. It uses an byte invalid character as a separator and so should not be used for printing.
func (Labels) Delete ¶ added in v1.1.0
Delete removes the first label encountered with the name given in place.
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) InsertSorted ¶ added in v1.7.0
InsertSorted adds the given label to the set of labels. It assumes the labels are sorted lexicographically.
func (Labels) ToPrometheusLabels ¶
func (Labels) Unique ¶ added in v1.1.0
Unique returns a set labels with unique keys. Labels expected to be sorted: underlying capacity is reused and the original order is preserved: the first key takes precedence over duplicates. Method receiver should not be used after the call.
func (Labels) WithLabels ¶
WithLabels returns a subset of Labels that 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) Get ¶ added in v1.7.0
func (b *LabelsBuilder) Get(n string) string
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) LabelsUnsorted ¶ added in v1.7.0
func (b *LabelsBuilder) LabelsUnsorted() Labels
LabelsUnsorted returns the labels from the builder. If no modifications were made, the original labels are returned.
The order is not deterministic.
func (*LabelsBuilder) Range ¶ added in v1.7.0
func (b *LabelsBuilder) Range(f func(l *typesv1.LabelPair))
Range calls f on each label in the Builder.
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 LabelsEnforcedOrder ¶ added in v1.7.0
LabelsEnforcedOrder is a sort order of labels, where profile type and service name labels always go first. This is crucial for query performance as labels determine the physical order of the profiling data.
func (LabelsEnforcedOrder) Len ¶ added in v1.7.0
func (ls LabelsEnforcedOrder) Len() int
func (LabelsEnforcedOrder) Less ¶ added in v1.7.0
func (ls LabelsEnforcedOrder) Less(i, j int) bool
func (LabelsEnforcedOrder) Swap ¶ added in v1.7.0
func (ls LabelsEnforcedOrder) Swap(i, j int)
type MergeIterator ¶ added in v1.8.0
type MergeIterator[P Profile] struct { // contains filtered or unexported fields }
func (*MergeIterator[P]) At ¶ added in v1.8.0
func (i *MergeIterator[P]) At() P
func (*MergeIterator[P]) Close ¶ added in v1.8.0
func (i *MergeIterator[P]) Close() error
func (*MergeIterator[P]) Err ¶ added in v1.8.0
func (i *MergeIterator[P]) Err() error
func (*MergeIterator[P]) Next ¶ added in v1.8.0
func (i *MergeIterator[P]) Next() bool
type ServiceVersion ¶ added in v1.3.0
type ServiceVersion struct { Repository string `json:"repository,omitempty"` GitRef string `json:"git_ref,omitempty"` BuildID string `json:"build_id,omitempty"` RootPath string `json:"root_path,omitempty"` }
func ServiceVersionFromLabels ¶ added in v1.3.0
func ServiceVersionFromLabels(lbls Labels) (ServiceVersion, bool)
ServiceVersionFromLabels Attempts to extract a service version from the given labels. Returns false if no service version was found.
type SpanSelector ¶ added in v1.2.0
type SpanSelector map[uint64]struct{}
func NewSpanSelector ¶ added in v1.2.0
func NewSpanSelector(spans []string) (SpanSelector, error)
type Stack ¶
type Stack[T any] struct { // contains filtered or unexported fields }
Stack is a stack of values. Pushing and popping values is O(1).
type StacktraceMerger ¶
type StacktraceMerger struct {
// contains filtered or unexported fields
}
func NewStackTraceMerger ¶
func NewStackTraceMerger() *StacktraceMerger
NewStackTraceMerger merges collections of StacktraceSamples. The result is a byte tree representation of the merged samples.
func (*StacktraceMerger) MergeStackTraces ¶
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 ¶
func (m *StacktraceMerger) Size() int
func (*StacktraceMerger) TreeBytes ¶
func (m *StacktraceMerger) TreeBytes(maxNodes int64) []byte
type StacktraceNode ¶
type StacktraceTree ¶
type StacktraceTree struct{ Nodes []StacktraceNode }
func NewStacktraceTree ¶
func NewStacktraceTree(size int) *StacktraceTree
func (*StacktraceTree) Bytes ¶
func (t *StacktraceTree) Bytes(dst io.Writer, maxNodes int64, funcs []string)
func (*StacktraceTree) Insert ¶
func (t *StacktraceTree) Insert(locations []int32, value int64) int32
func (*StacktraceTree) LookupLocations ¶ added in v1.2.1
func (t *StacktraceTree) LookupLocations(dst []uint64, idx int32) []uint64
func (*StacktraceTree) MinValue ¶
func (t *StacktraceTree) MinValue(maxNodes int64) int64
MinValue returns the minimum "total" value a node in a tree has to have.
func (*StacktraceTree) Reset ¶ added in v1.7.0
func (t *StacktraceTree) Reset()
func (*StacktraceTree) Traverse ¶
func (t *StacktraceTree) Traverse(maxNodes int64, fn StacktraceTreeTraverseFn) error
type TimeRangeRequest ¶ added in v1.2.0
TimeRangeRequest is a request that has a time interval.
type TimeRangedIterator ¶ added in v1.8.0
type TimeRangedIterator[T Timestamp] struct { iter.Iterator[T] // contains filtered or unexported fields }
func (*TimeRangedIterator[T]) Next ¶ added in v1.8.0
func (it *TimeRangedIterator[T]) Next() bool
type TimeSeriesAggregator ¶ added in v1.8.0
type TimeSeriesAggregator interface { Add(ts int64, value float64) GetAndReset() *typesv1.Point IsEmpty() bool GetTimestamp() int64 }
func NewTimeSeriesAggregator ¶ added in v1.8.0
func NewTimeSeriesAggregator(aggregation *typesv1.TimeSeriesAggregationType) TimeSeriesAggregator
type TimeSeriesBuilder ¶ added in v1.8.0
type TimeSeriesBuilder struct {
// contains filtered or unexported fields
}
func NewTimeSeriesBuilder ¶ added in v1.8.0
func NewTimeSeriesBuilder(by ...string) *TimeSeriesBuilder
func (*TimeSeriesBuilder) Add ¶ added in v1.8.0
func (s *TimeSeriesBuilder) Add(fp model.Fingerprint, lbs Labels, ts int64, value float64)
func (*TimeSeriesBuilder) Build ¶ added in v1.8.0
func (s *TimeSeriesBuilder) Build() []*typesv1.Series
func (*TimeSeriesBuilder) Init ¶ added in v1.8.0
func (s *TimeSeriesBuilder) Init(by ...string)
type TimeSeriesIterator ¶ added in v1.8.0
type TimeSeriesIterator struct {
// contains filtered or unexported fields
}
func NewSeriesIterator ¶ added in v1.8.0
func NewSeriesIterator(lbs []*typesv1.LabelPair, points []*typesv1.Point) *TimeSeriesIterator
func (*TimeSeriesIterator) At ¶ added in v1.8.0
func (s *TimeSeriesIterator) At() TimeSeriesValue
func (*TimeSeriesIterator) Close ¶ added in v1.8.0
func (s *TimeSeriesIterator) Close() error
func (*TimeSeriesIterator) Err ¶ added in v1.8.0
func (s *TimeSeriesIterator) Err() error
func (*TimeSeriesIterator) Next ¶ added in v1.8.0
func (s *TimeSeriesIterator) Next() bool
type TimeSeriesMerger ¶ added in v1.8.0
type TimeSeriesMerger struct {
// contains filtered or unexported fields
}
func NewTimeSeriesMerger ¶ added in v1.8.0
func NewTimeSeriesMerger(sum bool) *TimeSeriesMerger
NewTimeSeriesMerger creates a new series merger. If sum is set, samples with matching timestamps are summed, otherwise duplicates are retained.
func (*TimeSeriesMerger) IsEmpty ¶ added in v1.8.0
func (m *TimeSeriesMerger) IsEmpty() bool
func (*TimeSeriesMerger) MergeTimeSeries ¶ added in v1.8.0
func (m *TimeSeriesMerger) MergeTimeSeries(s []*typesv1.Series)
func (*TimeSeriesMerger) TimeSeries ¶ added in v1.8.0
func (m *TimeSeriesMerger) TimeSeries() []*typesv1.Series
type TimeSeriesValue ¶ added in v1.8.0
func (TimeSeriesValue) Labels ¶ added in v1.8.0
func (p TimeSeriesValue) Labels() Labels
func (TimeSeriesValue) Timestamp ¶ added in v1.8.0
func (p TimeSeriesValue) Timestamp() model.Time
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
func MustUnmarshalTree ¶ added in v1.8.0
func UnmarshalTree ¶
func (*Tree) Bytes ¶ added in v1.7.0
Bytes returns marshaled tree byte representation; the number of nodes is limited to maxNodes. The function modifies the tree: truncated nodes are removed from the tree in place.
func (*Tree) Fix ¶ added in v1.1.0
func (t *Tree) Fix()
Fix re-establishes order of nodes and merges duplicates.
func (*Tree) FormatNodeNames ¶ added in v1.1.0
func (*Tree) InsertStack ¶
func (*Tree) IterateStacks ¶
func (*Tree) MarshalTruncate ¶
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.
func (*Tree) WriteCollapsed ¶
type TreeMerger ¶
type TreeMerger struct {
// contains filtered or unexported fields
}
func NewTreeMerger ¶
func NewTreeMerger() *TreeMerger
func (*TreeMerger) IsEmpty ¶ added in v1.8.0
func (m *TreeMerger) IsEmpty() bool
func (*TreeMerger) MergeTree ¶ added in v1.7.0
func (m *TreeMerger) MergeTree(t *Tree)
func (*TreeMerger) MergeTreeBytes ¶
func (m *TreeMerger) MergeTreeBytes(b []byte) error
func (*TreeMerger) Tree ¶
func (m *TreeMerger) Tree() *Tree