Skip to content

Commit df40aae

Browse files
authored
add batcher config to splunkhec exporter (#32563)
**Description:** Add a new feature in splunk hec exporter - utilitize batching framework open-telemetry/opentelemetry-collector#9738 in splunk hec exporter - adds batcher config in splunk hec exporter config and append it as exporter option if enabled **Link to tracking Issue:** Resolves #32545 **Testing:** Added unit test for the config **Documentation:** Updated the README file
1 parent effd258 commit df40aae

File tree

6 files changed

+63
-3
lines changed

6 files changed

+63
-3
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: exporter/splunkhec
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: add experimental exporter batcher config
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [32545]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

exporter/splunkhecexporter/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ The following configuration options can also be configured:
6666
- `telemetry/enabled` (default: false): Specifies whether to enable telemetry inside splunk hec exporter.
6767
- `telemetry/override_metrics_names` (default: empty map): Specifies the metrics name to overrides in splunk hec exporter.
6868
- `telemetry/extra_attributes` (default: empty map): Specifies the extra metrics attributes in splunk hec exporter.
69+
- `batcher`(Experimental, disabled by default): Specifies batching configuration on the exporter. Information about the configuration can be found [here](https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/exporterhelper/README.md)
6970

7071
In addition, this exporter offers queued retry which is enabled by default.
7172
Information about queued retry configuration parameters can be found

exporter/splunkhecexporter/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"go.opentelemetry.io/collector/config/confighttp"
1414
"go.opentelemetry.io/collector/config/configopaque"
1515
"go.opentelemetry.io/collector/config/configretry"
16+
"go.opentelemetry.io/collector/exporter/exporterbatcher"
1617
"go.opentelemetry.io/collector/exporter/exporterhelper"
1718

1819
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk"
@@ -68,6 +69,10 @@ type Config struct {
6869
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
6970
configretry.BackOffConfig `mapstructure:"retry_on_failure"`
7071

72+
// Experimental: This configuration is at the early stage of development and may change without backward compatibility
73+
// until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
74+
BatcherConfig exporterbatcher.Config `mapstructure:"batcher"`
75+
7176
// LogDataEnabled can be used to disable sending logs by the exporter.
7277
LogDataEnabled bool `mapstructure:"log_data_enabled"`
7378

exporter/splunkhecexporter/config_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"go.opentelemetry.io/collector/config/configretry"
1717
"go.opentelemetry.io/collector/config/configtls"
1818
"go.opentelemetry.io/collector/confmap/confmaptest"
19+
"go.opentelemetry.io/collector/exporter/exporterbatcher"
1920
"go.opentelemetry.io/collector/exporter/exporterhelper"
2021

2122
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/splunkhecexporter/internal/metadata"
@@ -90,6 +91,16 @@ func TestLoadConfig(t *testing.T) {
9091
NumConsumers: 2,
9192
QueueSize: 10,
9293
},
94+
BatcherConfig: exporterbatcher.Config{
95+
Enabled: true,
96+
FlushTimeout: time.Second,
97+
MinSizeConfig: exporterbatcher.MinSizeConfig{
98+
MinSizeItems: 1,
99+
},
100+
MaxSizeConfig: exporterbatcher.MaxSizeConfig{
101+
MaxSizeItems: 10,
102+
},
103+
},
93104
HecToOtelAttrs: splunk.HecToOtelAttrs{
94105
Source: "mysource",
95106
SourceType: "mysourcetype",

exporter/splunkhecexporter/factory.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"go.opentelemetry.io/collector/config/configretry"
1313
"go.opentelemetry.io/collector/consumer"
1414
"go.opentelemetry.io/collector/exporter"
15+
"go.opentelemetry.io/collector/exporter/exporterbatcher"
1516
"go.opentelemetry.io/collector/exporter/exporterhelper"
1617
conventions "go.opentelemetry.io/collector/semconv/v1.6.1"
1718

@@ -58,6 +59,9 @@ func NewFactory() exporter.Factory {
5859
}
5960

6061
func createDefaultConfig() component.Config {
62+
batcherCfg := exporterbatcher.NewDefaultConfig()
63+
batcherCfg.Enabled = false
64+
6165
defaultMaxConns := defaultMaxIdleCons
6266
defaultIdleConnTimeout := defaultIdleConnTimeout
6367
return &Config{
@@ -74,6 +78,7 @@ func createDefaultConfig() component.Config {
7478
SplunkAppName: defaultSplunkAppName,
7579
BackOffConfig: configretry.NewDefaultBackOffConfig(),
7680
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
81+
BatcherConfig: batcherCfg,
7782
DisableCompression: false,
7883
MaxContentLengthLogs: defaultContentLengthLogsLimit,
7984
MaxContentLengthMetrics: defaultContentLengthMetricsLimit,
@@ -119,7 +124,9 @@ func createTracesExporter(
119124
exporterhelper.WithRetry(cfg.BackOffConfig),
120125
exporterhelper.WithQueue(cfg.QueueSettings),
121126
exporterhelper.WithStart(c.start),
122-
exporterhelper.WithShutdown(c.stop))
127+
exporterhelper.WithShutdown(c.stop),
128+
exporterhelper.WithBatcher(cfg.BatcherConfig),
129+
)
123130

124131
if err != nil {
125132
return nil, err
@@ -152,7 +159,9 @@ func createMetricsExporter(
152159
exporterhelper.WithRetry(cfg.BackOffConfig),
153160
exporterhelper.WithQueue(cfg.QueueSettings),
154161
exporterhelper.WithStart(c.start),
155-
exporterhelper.WithShutdown(c.stop))
162+
exporterhelper.WithShutdown(c.stop),
163+
exporterhelper.WithBatcher(cfg.BatcherConfig),
164+
)
156165
if err != nil {
157166
return nil, err
158167
}
@@ -184,7 +193,9 @@ func createLogsExporter(
184193
exporterhelper.WithRetry(cfg.BackOffConfig),
185194
exporterhelper.WithQueue(cfg.QueueSettings),
186195
exporterhelper.WithStart(c.start),
187-
exporterhelper.WithShutdown(c.stop))
196+
exporterhelper.WithShutdown(c.stop),
197+
exporterhelper.WithBatcher(cfg.BatcherConfig),
198+
)
188199

189200
if err != nil {
190201
return nil, err

exporter/splunkhecexporter/testdata/config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ splunk_hec/allsettings:
2626
initial_interval: 10s
2727
max_interval: 60s
2828
max_elapsed_time: 10m
29+
batcher:
30+
enabled: true
31+
flush_timeout: 1s
32+
min_size_items: 1
33+
max_size_items: 10
2934
splunk_app_name: "OpenTelemetry-Collector Splunk Exporter"
3035
splunk_app_version: "v0.0.1"
3136
hec_metadata_to_otel_attrs:

0 commit comments

Comments
 (0)