-
Notifications
You must be signed in to change notification settings - Fork 0
/
factory.go
35 lines (29 loc) · 954 Bytes
/
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
package metricsdedupprocessor
import (
"context"
"fmt"
"time"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/processor"
)
// NewFactory returns a new factory for the Metrics Generation processor.
func NewFactory() processor.Factory {
return processor.NewFactory(
component.MustNewType("metricsdedup"),
createDefaultConfig,
processor.WithMetrics(createMetricsProcessor, component.StabilityLevelDevelopment))
}
func createDefaultConfig() component.Config {
return &Config{
ReplicaLabel: "replica",
SwapTimeout: 1 * time.Minute,
}
}
func createMetricsProcessor(_ context.Context, set processor.Settings, cfg component.Config, nextConsumer consumer.Metrics) (processor.Metrics, error) {
processorConfig, ok := cfg.(*Config)
if !ok {
return nil, fmt.Errorf("configuration parsing error")
}
return newProcessor(processorConfig, set.Logger, nextConsumer), nil
}