Skip to content

Commit 98ec533

Browse files
committed
Enable batch sender in oltpexporter
1 parent ecbe02e commit 98ec533

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

exporter/otlpexporter/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ Several helper files are leveraged to provide additional capabilities automatica
5959

6060
- [gRPC settings](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configgrpc/README.md)
6161
- [TLS and mTLS settings](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configtls/README.md)
62-
- [Queuing, retry and timeout settings](https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/exporterhelper/README.md)
62+
- [Queuing, batching, retry and timeout settings](https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/exporterhelper/README.md)

exporter/otlpexporter/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ type Config struct {
2323
QueueConfig exporterhelper.QueueSettings `mapstructure:"sending_queue"`
2424
RetryConfig configretry.BackOffConfig `mapstructure:"retry_on_failure"`
2525

26+
// Experimental: This configuration is at the early stage of development and may change without backward compatibility
27+
// until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
28+
BatcherConfig exporterbatcher.Config `mapstructure:"batcher"`
29+
2630
configgrpc.ClientConfig `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
2731
}
2832

exporter/otlpexporter/config_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"go.opentelemetry.io/collector/config/configtls"
2020
"go.opentelemetry.io/collector/confmap"
2121
"go.opentelemetry.io/collector/confmap/confmaptest"
22+
"go.opentelemetry.io/collector/exporter/exporterbatcher"
2223
"go.opentelemetry.io/collector/exporter/exporterhelper"
2324
)
2425

@@ -53,6 +54,16 @@ func TestUnmarshalConfig(t *testing.T) {
5354
NumConsumers: 2,
5455
QueueSize: 10,
5556
},
57+
BatcherConfig: exporterbatcher.Config{
58+
Enabled: true,
59+
FlushTimeout: time.Second,
60+
MinSizeConfig: exporterbatcher.MinSizeConfig{
61+
MinSizeItems: 1,
62+
},
63+
MaxSizeConfig: exporterbatcher.MaxSizeConfig{
64+
MaxSizeItems: 10,
65+
},
66+
},
5667
ClientConfig: configgrpc.ClientConfig{
5768
Headers: map[string]configopaque.String{
5869
"can you have a . here?": "F0000000-0000-0000-0000-000000000000",

exporter/otlpexporter/factory.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"go.opentelemetry.io/collector/config/configretry"
1414
"go.opentelemetry.io/collector/consumer"
1515
"go.opentelemetry.io/collector/exporter"
16+
"go.opentelemetry.io/collector/exporter/exporterbatcher"
1617
"go.opentelemetry.io/collector/exporter/exporterhelper"
1718
"go.opentelemetry.io/collector/exporter/otlpexporter/internal/metadata"
1819
)
@@ -29,10 +30,14 @@ func NewFactory() exporter.Factory {
2930
}
3031

3132
func createDefaultConfig() component.Config {
33+
batcherCfg := exporterbatcher.NewDefaultConfig()
34+
batcherCfg.Enabled = false
35+
3236
return &Config{
3337
TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(),
3438
RetryConfig: configretry.NewDefaultBackOffConfig(),
3539
QueueConfig: exporterhelper.NewDefaultQueueSettings(),
40+
BatcherConfig: batcherCfg,
3641
ClientConfig: configgrpc.ClientConfig{
3742
Headers: map[string]configopaque.String{},
3843
// Default to gzip compression
@@ -57,7 +62,9 @@ func createTracesExporter(
5762
exporterhelper.WithRetry(oCfg.RetryConfig),
5863
exporterhelper.WithQueue(oCfg.QueueConfig),
5964
exporterhelper.WithStart(oce.start),
60-
exporterhelper.WithShutdown(oce.shutdown))
65+
exporterhelper.WithShutdown(oce.shutdown),
66+
exporterhelper.WithBatcher(cfg.BatcherConfig),
67+
)
6168
}
6269

6370
func createMetricsExporter(
@@ -75,6 +82,7 @@ func createMetricsExporter(
7582
exporterhelper.WithQueue(oCfg.QueueConfig),
7683
exporterhelper.WithStart(oce.start),
7784
exporterhelper.WithShutdown(oce.shutdown),
85+
exporterhelper.WithBatcher(cfg.BatcherConfig),
7886
)
7987
}
8088

@@ -93,5 +101,6 @@ func createLogsExporter(
93101
exporterhelper.WithQueue(oCfg.QueueConfig),
94102
exporterhelper.WithStart(oce.start),
95103
exporterhelper.WithShutdown(oce.shutdown),
104+
exporterhelper.WithBatcher(cfg.BatcherConfig),
96105
)
97106
}

exporter/otlpexporter/testdata/config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ retry_on_failure:
1414
multiplier: 1.3
1515
max_interval: 60s
1616
max_elapsed_time: 10m
17+
batcher:
18+
enabled: true
19+
flush_timeout: 1s
20+
min_size_items: 1
21+
max_size_items: 10
1722
auth:
1823
authenticator: nop
1924
headers:

0 commit comments

Comments
 (0)