-
Notifications
You must be signed in to change notification settings - Fork 25
/
factory.go
45 lines (38 loc) · 1.24 KB
/
factory.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 rollupprocessor
import (
"context"
"github.com/prometheus/client_golang/prometheus"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/processor"
)
const (
// The value of "type" key in configuration.
typeStr = "rollup"
)
var defaultRollupBuckets = []float64{10, 25, 100, 250, 1000, 2500, 10000}
// NewFactory returns a new factory for the Rollup processor.
func NewFactory(promRegistry *prometheus.Registry) processor.Factory {
return processor.NewFactory(
typeStr,
createDefaultConfig(promRegistry),
processor.WithLogs(CreateLogsProcessor, component.StabilityLevelDevelopment))
}
func createDefaultConfig(promRegistry *prometheus.Registry) func() component.Config {
return func() component.Config {
return &Config{
AttributeCardinalityLimit: defaultAttributeCardinalityLimit,
RollupBuckets: defaultRollupBuckets,
promRegistry: promRegistry,
}
}
}
// CreateLogsProcessor returns rollupProcessor handling logs.
func CreateLogsProcessor(
_ context.Context,
set processor.CreateSettings,
cfg component.Config,
nextConsumer consumer.Logs,
) (processor.Logs, error) {
return newRollupLogsProcessor(set, nextConsumer, cfg.(*Config))
}