Skip to content

Commit

Permalink
Change default otlp exporter GRPC load balancer to round robin (#10319)
Browse files Browse the repository at this point in the history
#### Description
Updates the default `pick_first` load balancer to `round_robin`, which
allows for better resource allocation and less chances of throttling
data being sent to addresses.

#### Link to tracking issue
Fixes #10298 (has full context of this PR)

#### Testing
Edited tests to allow round_robin load balancing.

---------

Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
Co-authored-by: Juraci Paixão Kröhling <juraci.github@kroehling.de>
  • Loading branch information
3 people committed Jul 2, 2024
1 parent 428d3f8 commit 6ad6b86
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
24 changes: 24 additions & 0 deletions .chloggen/load-balancer-round-robin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: configgrpc

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Update the default load balancer strategy to round_robin

# One or more tracking issues or pull requests related to the change
issues: [10319]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: To restore the behavior that was previously the default, set `balancer_name` to `pick_first`.

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
change_logs: [user]
4 changes: 2 additions & 2 deletions config/configgrpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ configuration parameters are also defined under `tls` like server
configuration. For more information, see [configtls
README](../configtls/README.md).

- [`balancer_name`](https://github.com/grpc/grpc-go/blob/master/examples/features/load_balancing/README.md)
- `compression` Compression type to use among `gzip`, `snappy`, `zstd`, and `none`.
- [`balancer_name`](https://github.com/grpc/grpc-go/blob/master/examples/features/load_balancing/README.md): Default before v0.103.0 is `pick_first`, default for v0.103.0 is `round_robin`. See [issue](https://github.com/open-telemetry/opentelemetry-collector/issues/10298). To restore the previous behavior, set `balancer_name` to `pick_first`.
- `compression`: Compression type to use among `gzip`, `snappy`, `zstd`, and `none`.
- `endpoint`: Valid value syntax available [here](https://github.com/grpc/grpc/blob/master/doc/naming.md)
- [`tls`](../configtls/README.md)
- `headers`: name/value pairs added to the request
Expand Down
12 changes: 9 additions & 3 deletions config/configgrpc/configgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func NewDefaultKeepaliveClientConfig() *KeepaliveClientConfig {
}
}

// BalancerName returns a string with default load balancer value
func BalancerName() string {
return "round_robin"
}

// ClientConfig defines common settings for a gRPC client configuration.
type ClientConfig struct {
// The target to which the exporter is going to send traces or metrics,
Expand Down Expand Up @@ -102,9 +107,10 @@ type ClientConfig struct {
// NewDefaultClientConfig returns a new instance of ClientConfig with default values.
func NewDefaultClientConfig() *ClientConfig {
return &ClientConfig{
TLSSetting: configtls.NewDefaultClientConfig(),
Keepalive: NewDefaultKeepaliveClientConfig(),
Auth: configauth.NewDefaultAuthentication(),
TLSSetting: configtls.NewDefaultClientConfig(),
Keepalive: NewDefaultKeepaliveClientConfig(),
Auth: configauth.NewDefaultAuthentication(),
BalancerName: BalancerName(),
}
}

Expand Down
9 changes: 5 additions & 4 deletions config/configgrpc/configgrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ func TestNewDefaultKeepaliveClientConfig(t *testing.T) {

func TestNewDefaultClientConfig(t *testing.T) {
expected := &ClientConfig{
TLSSetting: configtls.NewDefaultClientConfig(),
Keepalive: NewDefaultKeepaliveClientConfig(),
Auth: configauth.NewDefaultAuthentication(),
TLSSetting: configtls.NewDefaultClientConfig(),
Keepalive: NewDefaultKeepaliveClientConfig(),
Auth: configauth.NewDefaultAuthentication(),
BalancerName: BalancerName(),
}

result := NewDefaultClientConfig()
Expand Down Expand Up @@ -215,7 +216,7 @@ func TestAllGrpcClientSettings(t *testing.T) {
ReadBufferSize: 1024,
WriteBufferSize: 1024,
WaitForReady: true,
BalancerName: "configgrpc_balancer_test",
BalancerName: "round_robin",
Authority: "pseudo-authority",
Auth: &configauth.Authentication{AuthenticatorID: testAuthID},
},
Expand Down

0 comments on commit 6ad6b86

Please sign in to comment.