-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
factory.go
60 lines (50 loc) · 1.83 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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package mezmoexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/mezmoexporter"
import (
"context"
"errors"
"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/mezmoexporter/internal/metadata"
)
// NewFactory creates a factory for Mezmo exporter.
func NewFactory() exporter.Factory {
return exporter.NewFactory(
metadata.Type,
createDefaultConfig,
exporter.WithLogs(createLogsExporter, metadata.LogsStability),
)
}
// Create a default Memzo config
func createDefaultConfig() component.Config {
return &Config{
ClientConfig: createDefaultClientConfig(),
BackOffConfig: configretry.NewDefaultBackOffConfig(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
IngestURL: defaultIngestURL,
}
}
// Create a log exporter for exporting to Mezmo
func createLogsExporter(ctx context.Context, settings exporter.CreateSettings, exporterConfig component.Config) (exporter.Logs, error) {
log := settings.Logger
if exporterConfig == nil {
return nil, errors.New("nil config")
}
expCfg := exporterConfig.(*Config)
exp := newLogsExporter(expCfg, settings.TelemetrySettings, settings.BuildInfo, log)
return exporterhelper.NewLogsExporter(
ctx,
settings,
expCfg,
exp.pushLogData,
// explicitly disable since we rely on http.Client timeout logic.
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}),
exporterhelper.WithRetry(expCfg.BackOffConfig),
exporterhelper.WithQueue(expCfg.QueueSettings),
exporterhelper.WithStart(exp.start),
exporterhelper.WithShutdown(exp.stop),
)
}