-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathfactory.go
73 lines (62 loc) · 2.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
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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
//go:generate mdatagen metadata.yaml
package opensearchexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter"
import (
"context"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter/internal/metadata"
)
// NewFactory creates a factory for OpenSearch exporter.
func NewFactory() exporter.Factory {
return exporter.NewFactory(
metadata.Type,
newDefaultConfig,
exporter.WithTraces(createTracesExporter, metadata.TracesStability),
exporter.WithLogs(createLogsExporter, metadata.LogsStability),
)
}
func newDefaultConfig() component.Config {
return &Config{
HTTPClientSettings: confighttp.NewDefaultHTTPClientSettings(),
Dataset: defaultDataset,
Namespace: defaultNamespace,
BulkAction: defaultBulkAction,
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
MappingsSettings: MappingsSettings{Mode: defaultMappingMode},
}
}
func createTracesExporter(ctx context.Context,
set exporter.CreateSettings,
cfg component.Config) (exporter.Traces, error) {
c := cfg.(*Config)
te, e := newSSOTracesExporter(c, set)
if e != nil {
return nil, e
}
return exporterhelper.NewTracesExporter(ctx, set, cfg,
te.pushTraceData,
exporterhelper.WithStart(te.Start),
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
exporterhelper.WithRetry(c.RetrySettings),
exporterhelper.WithTimeout(c.TimeoutSettings))
}
func createLogsExporter(ctx context.Context,
set exporter.CreateSettings,
cfg component.Config) (exporter.Logs, error) {
c := cfg.(*Config)
le, e := newLogExporter(c, set)
if e != nil {
return nil, e
}
return exporterhelper.NewLogsExporter(ctx, set, cfg,
le.pushLogData,
exporterhelper.WithStart(le.Start),
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: true}),
exporterhelper.WithRetry(c.RetrySettings),
exporterhelper.WithTimeout(c.TimeoutSettings))
}