Skip to content

Commit d2ed276

Browse files
Enable batch sender in oltpexporter (#10846)
#### Description This PR adds opt-in support to oltp exporter for the experimental batch sender (#8122). By default batch sender is not enabled. Similar: * open-telemetry/opentelemetry-collector-contrib#34238 * open-telemetry/opentelemetry-collector-contrib#32563 #### Link to tracking issue Resolves #10834 #### Testing `exporter/otlpexporter/config_test.go` #### Documentation Updated the `oltpexporter` README to point to `exporterhelper` README for batching. --------- Co-authored-by: Dmitrii Anoshin <[email protected]>
1 parent 8506809 commit d2ed276

File tree

6 files changed

+57
-2
lines changed

6 files changed

+57
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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. otlpreceiver)
7+
component: exporter/otlp
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Add batching option to otlp exporter"
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [8122]
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+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [user]

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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"go.opentelemetry.io/collector/component"
1515
"go.opentelemetry.io/collector/config/configgrpc"
1616
"go.opentelemetry.io/collector/config/configretry"
17+
"go.opentelemetry.io/collector/exporter/exporterbatcher"
1718
"go.opentelemetry.io/collector/exporter/exporterhelper"
1819
)
1920

@@ -23,6 +24,10 @@ type Config struct {
2324
QueueConfig exporterhelper.QueueSettings `mapstructure:"sending_queue"`
2425
RetryConfig configretry.BackOffConfig `mapstructure:"retry_on_failure"`
2526

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

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: 200 * time.Millisecond,
60+
MinSizeConfig: exporterbatcher.MinSizeConfig{
61+
MinSizeItems: 1000,
62+
},
63+
MaxSizeConfig: exporterbatcher.MaxSizeConfig{
64+
MaxSizeItems: 10000,
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
@@ -56,8 +61,10 @@ func createTracesExporter(
5661
exporterhelper.WithTimeout(oCfg.TimeoutSettings),
5762
exporterhelper.WithRetry(oCfg.RetryConfig),
5863
exporterhelper.WithQueue(oCfg.QueueConfig),
64+
exporterhelper.WithBatcher(oCfg.BatcherConfig),
5965
exporterhelper.WithStart(oce.start),
60-
exporterhelper.WithShutdown(oce.shutdown))
66+
exporterhelper.WithShutdown(oce.shutdown),
67+
)
6168
}
6269

6370
func createMetricsExporter(
@@ -73,6 +80,7 @@ func createMetricsExporter(
7380
exporterhelper.WithTimeout(oCfg.TimeoutSettings),
7481
exporterhelper.WithRetry(oCfg.RetryConfig),
7582
exporterhelper.WithQueue(oCfg.QueueConfig),
83+
exporterhelper.WithBatcher(oCfg.BatcherConfig),
7684
exporterhelper.WithStart(oce.start),
7785
exporterhelper.WithShutdown(oce.shutdown),
7886
)
@@ -91,6 +99,7 @@ func createLogsExporter(
9199
exporterhelper.WithTimeout(oCfg.TimeoutSettings),
92100
exporterhelper.WithRetry(oCfg.RetryConfig),
93101
exporterhelper.WithQueue(oCfg.QueueConfig),
102+
exporterhelper.WithBatcher(oCfg.BatcherConfig),
94103
exporterhelper.WithStart(oce.start),
95104
exporterhelper.WithShutdown(oce.shutdown),
96105
)

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: 200ms
20+
min_size_items: 1000
21+
max_size_items: 10000
1722
auth:
1823
authenticator: nop
1924
headers:

0 commit comments

Comments
 (0)