/
factory.go
84 lines (75 loc) · 2.42 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
//
//go:generate mdatagen metadata.yaml
package sumologicprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/sumologicprocessor"
import (
"context"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/processorhelper"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/sumologicprocessor/internal/metadata"
)
var processorCapabilities = consumer.Capabilities{MutatesData: true}
// NewFactory returns a new factory for the processor.
func NewFactory() processor.Factory {
return processor.NewFactory(
metadata.Type,
createDefaultConfig,
processor.WithTraces(createTracesProcessor, metadata.TracesStability),
processor.WithMetrics(createMetricsProcessor, metadata.MetricsStability),
processor.WithLogs(createLogsProcessor, metadata.LogsStability),
)
}
func createLogsProcessor(
ctx context.Context,
set processor.CreateSettings,
cfg component.Config,
nextConsumer consumer.Logs,
) (processor.Logs, error) {
processor := newsumologicProcessor(set, cfg.(*Config))
return processorhelper.NewLogsProcessor(
ctx,
set,
cfg,
nextConsumer,
processor.processLogs,
processorhelper.WithCapabilities(processorCapabilities),
processorhelper.WithStart(processor.start),
processorhelper.WithShutdown(processor.shutdown))
}
func createMetricsProcessor(
ctx context.Context,
set processor.CreateSettings,
cfg component.Config,
nextConsumer consumer.Metrics,
) (processor.Metrics, error) {
processor := newsumologicProcessor(set, cfg.(*Config))
return processorhelper.NewMetricsProcessor(
ctx,
set,
cfg,
nextConsumer,
processor.processMetrics,
processorhelper.WithCapabilities(processorCapabilities),
processorhelper.WithStart(processor.start),
processorhelper.WithShutdown(processor.shutdown))
}
func createTracesProcessor(
ctx context.Context,
set processor.CreateSettings,
cfg component.Config,
nextConsumer consumer.Traces,
) (processor.Traces, error) {
processor := newsumologicProcessor(set, cfg.(*Config))
return processorhelper.NewTracesProcessor(
ctx,
set,
cfg,
nextConsumer,
processor.processTraces,
processorhelper.WithCapabilities(processorCapabilities),
processorhelper.WithStart(processor.start),
processorhelper.WithShutdown(processor.shutdown))
}