-
Notifications
You must be signed in to change notification settings - Fork 38
/
factory.go
66 lines (58 loc) · 2.11 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package metricfrequencyprocessor
import (
"context"
"time"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/processorhelper"
)
const (
typeStr = "metric_frequency"
defaultMinPointAccumulationTime = 15 * time.Minute
defaultConstantMetricsReportFrequency = 5 * time.Minute
defaultLowInfoMetricsReportFrequency = 2 * time.Minute
defaultMaxReportFrequency = 30 * time.Second
defaultIqrAnomalyCoef = 1.5
defaultVariationIqrThresholdCoef = 4.0
defaultDataPointExpirationTime = 1 * time.Hour
defaultDataPointCacheCleanupInterval = 10 * time.Minute
defaultMetricCacheCleanupInterval = 3 * time.Hour
stabilityLevel = component.StabilityLevelBeta
)
var Type = component.MustNewType(typeStr)
func NewFactory() processor.Factory {
return processor.NewFactory(
Type,
createDefaultConfig,
processor.WithMetrics(createMetricsProcessor, stabilityLevel),
)
}
func createDefaultConfig() component.Config {
return &Config{
sieveConfig{
MinPointAccumulationTime: defaultMinPointAccumulationTime,
ConstantMetricsReportFrequency: defaultConstantMetricsReportFrequency,
LowInfoMetricsReportFrequency: defaultLowInfoMetricsReportFrequency,
MaxReportFrequency: defaultMaxReportFrequency,
IqrAnomalyCoef: defaultIqrAnomalyCoef,
VariationIqrThresholdCoef: defaultVariationIqrThresholdCoef,
},
cacheConfig{
DataPointExpirationTime: defaultDataPointExpirationTime,
DataPointCacheCleanupInterval: defaultDataPointCacheCleanupInterval,
MetricCacheCleanupInterval: defaultMetricCacheCleanupInterval,
},
}
}
func createMetricsProcessor(
ctx context.Context,
params processor.Settings,
cfg component.Config,
nextConsumer consumer.Metrics,
) (processor.Metrics, error) {
var internalProcessor = &metricsfrequencyprocessor{
sieve: newMetricSieve(cfg.(*Config)),
}
return processorhelper.NewMetricsProcessor(ctx, params, cfg, nextConsumer, internalProcessor.ProcessMetrics)
}