-
Notifications
You must be signed in to change notification settings - Fork 578
/
types.go
45 lines (38 loc) · 1.29 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package storage
//revive:disable:max-public-structs TODO: we will refactor this later
import (
"context"
"time"
"github.com/grafana/pyroscope/pkg/og/storage/metadata"
"github.com/grafana/pyroscope/pkg/og/storage/segment"
"github.com/grafana/pyroscope/pkg/og/storage/tree"
)
// MetricsExporter exports values of particular stack traces sample from profiling
// data as a Prometheus metrics.
type MetricsExporter interface {
// Evaluate evaluates metrics export rules against the input key and creates
// prometheus counters for new time series, if required. Returned observer can
// be used to evaluate and observe particular samples.
//
// If there are no matching rules, the function returns false.
Evaluate(*PutInput) (SampleObserver, bool)
}
type SampleObserver interface {
// Observe adds v to the matched counters if k satisfies node selector.
// k is a sample stack trace where frames are delimited by semicolon.
// v is the sample value.
Observe(k []byte, v int)
}
type PutInput struct {
StartTime time.Time
EndTime time.Time
Key *segment.Key
Val *tree.Tree
SpyName string
SampleRate uint32
Units metadata.Units
AggregationType metadata.AggregationType
}
type Putter interface {
Put(context.Context, *PutInput) error
}