[extension/jaegerremotesampling] disable grpc#48440
Conversation
- Enhanced Validate() method to check for port conflicts between HTTP and gRPC servers - Added extractPort() helper function to parse endpoint strings - Added comprehensive unit tests for validation logic - Validation fails fast with clear, actionable error messages Fixes open-telemetry#45944
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib. Important reminders:
|
There was a problem hiding this comment.
Pull request overview
Makes the jaegerremotesampling extension's gRPC server optional by wrapping GRPCServerConfig in configoptional.Optional, removing the always-on default that bound port 14250 and conflicted with jaegerreceiver. The gRPC server is now only started when the user explicitly configures grpc: in their YAML; validation still requires at least one of HTTP or gRPC to be set.
Changes:
- Type
Config.GRPCServerConfigswitched from*configgrpc.ServerConfigtoconfigoptional.Optional[configgrpc.ServerConfig], with defaultconfigoptional.None[...](). Startnow usesHasValue()/Get()instead of nil-checking the pointer;Validateupdated accordingly.- Tests adjusted to construct optional gRPC configs via
configoptional.Some(...); added duplicateTestConfigValidateand a chloggen entry.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| extension/jaegerremotesampling/config.go | Make GRPCServerConfig optional and update validation to use HasValue(). |
| extension/jaegerremotesampling/factory.go | Drop default gRPC endpoint; initialize with configoptional.None. |
| extension/jaegerremotesampling/extension.go | Start gRPC server only when HasValue() is true. |
| extension/jaegerremotesampling/config_test.go | Update expected configs; add new TestConfigValidate cases. |
| extension/jaegerremotesampling/factory_test.go | Update default-config expectation to configoptional.None. |
| extension/jaegerremotesampling/extension_test.go | Construct gRPC config via configoptional.Some in test helpers. |
| .chloggen/jaegerremotesampling-port-validation.yaml | Add changelog entry (note does not match actual change). |
Comments suppressed due to low confidence (1)
.chloggen/jaegerremotesampling-port-validation.yaml:11
- The changelog note describes adding "validation to detect port conflicts between HTTP and gRPC servers," but the PR does not introduce any port conflict detection. The actual change makes the gRPC server optional and disabled by default. The note and subtext should accurately describe what this PR does (disabling gRPC by default / making it opt-in) so users reading the release notes understand the behavior change.
note: Add validation to detect port conflicts between HTTP and gRPC servers
issues: [45944]
subtext: |
The jaegerremotesampling extension now validates that HTTP and gRPC servers
are configured on different ports during configuration loading. This prevents
runtime port binding failures and provides clear, actionable error messages
when misconfigurations are detected.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| func TestConfigValidate(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| config Config | ||
| expectedErr error | ||
| }{ | ||
| { | ||
| name: "valid config with both protocols", | ||
| config: Config{ | ||
| HTTPServerConfig: &confighttp.ServerConfig{ | ||
| NetAddr: confignet.AddrConfig{ | ||
| Endpoint: "0.0.0.0:5778", | ||
| }, | ||
| }, | ||
| GRPCServerConfig: configoptional.Some(configgrpc.ServerConfig{ | ||
| NetAddr: confignet.AddrConfig{ | ||
| Endpoint: "0.0.0.0:14250", | ||
| }, | ||
| }), | ||
| Source: Source{ | ||
| File: "/etc/strategies.json", | ||
| }, | ||
| }, | ||
| expectedErr: nil, | ||
| }, | ||
| { | ||
| name: "valid config with only gRPC", | ||
| config: Config{ | ||
| GRPCServerConfig: configoptional.Some(configgrpc.ServerConfig{ | ||
| NetAddr: confignet.AddrConfig{ | ||
| Endpoint: "0.0.0.0:14250", | ||
| }, | ||
| }), | ||
| Source: Source{ | ||
| Remote: &configgrpc.ClientConfig{}, | ||
| }, | ||
| }, | ||
| expectedErr: nil, | ||
| }, | ||
| { | ||
| name: "valid config with only HTTP", | ||
| config: Config{ | ||
| HTTPServerConfig: &confighttp.ServerConfig{ | ||
| NetAddr: confignet.AddrConfig{ | ||
| Endpoint: "0.0.0.0:5778", | ||
| }, | ||
| }, | ||
| Source: Source{ | ||
| File: "/etc/strategies.json", | ||
| }, | ||
| }, | ||
| expectedErr: nil, | ||
| }, | ||
| { | ||
| name: "invalid: no protocols configured", | ||
| config: Config{ | ||
| Source: Source{ | ||
| File: "/etc/strategies.json", | ||
| }, | ||
| }, | ||
| expectedErr: errAtLeastOneProtocol, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| err := tt.config.Validate() | ||
| if tt.expectedErr != nil { | ||
| require.Error(t, err) | ||
| assert.ErrorIs(t, err, tt.expectedErr) | ||
| } else { | ||
| require.NoError(t, err) | ||
| } | ||
| }) | ||
| } | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Fixes #45944
Problem
The
jaegerremotesamplingextension always starts a gRPC server on a default port, even when not needed. This causes port conflicts with other components likejaegerreceiverthat bind the same port, with no way to disable it via config.Changes
GRPCServerConfiginconfigoptional.Optionalso users can omit the gRPC server entirelyconfigoptional.None— only starts when explicitly configuredHasValue()gofmtTesting