Skip to content

Commit

Permalink
reduce changelog with new batcher change
Browse files Browse the repository at this point in the history
  • Loading branch information
splunkericl committed May 3, 2024
1 parent a117868 commit 1b5d22e
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions exporter/splunkhecexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,10 @@ func NewFactory() exporter.Factory {
exporter.WithLogs(createLogsExporter, metadata.LogsStability))
}

func getExporterOptions(cfg *Config, startFunc component.StartFunc, shutdownFunc component.ShutdownFunc) []exporterhelper.Option {
options := []exporterhelper.Option{
// explicitly disable since we rely on http.Client timeout logic.
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}),
exporterhelper.WithRetry(cfg.BackOffConfig),
exporterhelper.WithQueue(cfg.QueueSettings),
exporterhelper.WithStart(startFunc),
exporterhelper.WithShutdown(shutdownFunc),
exporterhelper.WithBatcher(cfg.BatcherConfig),
}

return options
}

func createDefaultConfig() component.Config {
batcherCfg := exporterbatcher.NewDefaultConfig()
batcherCfg.Enabled = false

defaultMaxConns := defaultMaxIdleCons
defaultIdleConnTimeout := defaultIdleConnTimeout
return &Config{
Expand All @@ -86,13 +75,10 @@ func createDefaultConfig() component.Config {
HTTP2ReadIdleTimeout: defaultHTTP2ReadIdleTimeout,
HTTP2PingTimeout: defaultHTTP2PingTimeout,
},
SplunkAppName: defaultSplunkAppName,
BackOffConfig: configretry.NewDefaultBackOffConfig(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
BatcherConfig: exporterbatcher.Config{
Enabled: false,
FlushTimeout: 200 * time.Millisecond, // need default value to prevent validation failures
},
SplunkAppName: defaultSplunkAppName,
BackOffConfig: configretry.NewDefaultBackOffConfig(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
BatcherConfig: batcherCfg,
DisableCompression: false,
MaxContentLengthLogs: defaultContentLengthLogsLimit,
MaxContentLengthMetrics: defaultContentLengthMetricsLimit,
Expand Down Expand Up @@ -128,14 +114,19 @@ func createTracesExporter(

c := newTracesClient(set, cfg)

exporterOptions := getExporterOptions(cfg, c.start, c.stop)

e, err := exporterhelper.NewTracesExporter(
ctx,
set,
cfg,
c.pushTraceData,
exporterOptions...)
// explicitly disable since we rely on http.Client timeout logic.
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}),
exporterhelper.WithRetry(cfg.BackOffConfig),
exporterhelper.WithQueue(cfg.QueueSettings),
exporterhelper.WithStart(c.start),
exporterhelper.WithShutdown(c.stop),
exporterhelper.WithBatcher(cfg.BatcherConfig),
)

if err != nil {
return nil, err
Expand All @@ -158,14 +149,19 @@ func createMetricsExporter(

c := newMetricsClient(set, cfg)

exporterOptions := getExporterOptions(cfg, c.start, c.stop)

e, err := exporterhelper.NewMetricsExporter(
ctx,
set,
cfg,
c.pushMetricsData,
exporterOptions...)
// explicitly disable since we rely on http.Client timeout logic.
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}),
exporterhelper.WithRetry(cfg.BackOffConfig),
exporterhelper.WithQueue(cfg.QueueSettings),
exporterhelper.WithStart(c.start),
exporterhelper.WithShutdown(c.stop),
exporterhelper.WithBatcher(cfg.BatcherConfig),
)
if err != nil {
return nil, err
}
Expand All @@ -187,14 +183,19 @@ func createLogsExporter(

c := newLogsClient(set, cfg)

exporterOptions := getExporterOptions(cfg, c.start, c.stop)

logsExporter, err := exporterhelper.NewLogsExporter(
ctx,
set,
cfg,
c.pushLogData,
exporterOptions...)
// explicitly disable since we rely on http.Client timeout logic.
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}),
exporterhelper.WithRetry(cfg.BackOffConfig),
exporterhelper.WithQueue(cfg.QueueSettings),
exporterhelper.WithStart(c.start),
exporterhelper.WithShutdown(c.stop),
exporterhelper.WithBatcher(cfg.BatcherConfig),
)

if err != nil {
return nil, err
Expand Down

0 comments on commit 1b5d22e

Please sign in to comment.