forked from r0mdau/fluentforwardexporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfactory.go
79 lines (70 loc) · 2.17 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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package fluentforwardexporter // import "github.com/r0mdau/fluentforwardexporter"
import (
"context"
"time"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configretry"
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"github.com/axoflow/fluentforwardexporter/internal/metadata"
)
// NewFactory creates a factory for the fluentforward exporter.
func NewFactory() exporter.Factory {
// later count failed log records
//_ = view.Register(metricViews()...)
return exporter.NewFactory(
metadata.Type,
createDefaultConfig,
exporter.WithLogs(createLogsExporter, metadata.LogsStability),
)
}
func createDefaultConfig() component.Config {
return &Config{
TCPClientSettings: TCPClientSettings{
Endpoint: Endpoint{
TCPAddr: "localhost:24224",
ValidateTCPResolution: false,
},
ConnectionTimeout: time.Second * 30,
ClientConfig: configtls.ClientConfig{
Insecure: true,
InsecureSkipVerify: false,
Config: configtls.Config{
CAFile: "",
CertFile: "",
KeyFile: "",
},
},
SharedKey: "",
},
RequireAck: false,
Tag: "tag",
CompressGzip: false,
DefaultLabelsEnabled: map[string]bool{
"timestamp": true,
"level": true,
"message": true,
},
BackOffConfig: configretry.NewDefaultBackOffConfig(),
QueueConfig: exporterhelper.NewDefaultQueueConfig(),
}
}
func createLogsExporter(ctx context.Context, set exporter.Settings, config component.Config) (exporter.Logs, error) {
exporterConfig := config.(*Config)
exp := newExporter(exporterConfig, set.TelemetrySettings)
return exporterhelper.NewLogs(
ctx,
set,
config,
exp.pushLogData,
// explicitly disable since we rely on net.Dialer timeout logic.
exporterhelper.WithTimeout(exporterhelper.TimeoutConfig{Timeout: 0}),
exporterhelper.WithRetry(exporterConfig.BackOffConfig),
exporterhelper.WithQueue(exporterConfig.QueueConfig),
exporterhelper.WithStart(exp.start),
exporterhelper.WithShutdown(exp.stop),
)
}