forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
factory.go
52 lines (43 loc) · 1.4 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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package syslogexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/syslogexporter"
import (
"context"
"fmt"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configretry"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/syslogexporter/internal/metadata"
)
// NewFactory returns a new factory for the syslog exporter.
func NewFactory() exporter.Factory {
return exporter.NewFactory(
metadata.Type,
createDefaultConfig,
exporter.WithLogs(createLogsExporter, metadata.LogsStability),
)
}
func createDefaultConfig() component.Config {
qs := exporterhelper.NewDefaultQueueConfig()
qs.Enabled = false
return &Config{
Port: DefaultPort,
Network: DefaultNetwork,
Protocol: DefaultProtocol,
BackOffConfig: configretry.NewDefaultBackOffConfig(),
QueueSettings: qs,
TimeoutSettings: exporterhelper.NewDefaultTimeoutConfig(),
}
}
func createLogsExporter(
ctx context.Context,
params exporter.Settings,
cfg component.Config,
) (exporter.Logs, error) {
exp, err := newLogsExporter(ctx, params, cfg.(*Config))
if err != nil {
return nil, fmt.Errorf("failed to create the logs exporter: %w", err)
}
return exp, nil
}