Skip to content

Commit

Permalink
[configgrpc] remove deprecated funcs (#9836)
Browse files Browse the repository at this point in the history
Closes
#9482
Closes
#9812
  • Loading branch information
TylerHelmuth committed Apr 3, 2024
1 parent 26ee291 commit 4f56509
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 34 deletions.
25 changes: 25 additions & 0 deletions .chloggen/configgrpc-remove-deprecated-funcs-2.yaml
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

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

# 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: Remove deprecated `ToServerContext`, use `ToServer` instead.

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

# (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:

# 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.
# Default: '[user]'
change_logs: [api]
25 changes: 25 additions & 0 deletions .chloggen/configgrpc-remove-deprecated-funcs.yaml
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

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

# 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: Remove deprecated `SanitizedEndpoint`.

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

# (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:

# 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.
# Default: '[user]'
change_logs: [api]
13 changes: 3 additions & 10 deletions config/configgrpc/configgrpc.go
Expand Up @@ -150,9 +150,8 @@ type ServerConfig struct {
IncludeMetadata bool `mapstructure:"include_metadata"`
}

// SanitizedEndpoint strips the prefix of either http:// or https:// from configgrpc.ClientConfig.Endpoint.
// Deprecated: [v0.97.0]
func (gcs *ClientConfig) SanitizedEndpoint() string {
// sanitizedEndpoint strips the prefix of either http:// or https:// from configgrpc.ClientConfig.Endpoint.
func (gcs *ClientConfig) sanitizedEndpoint() string {
switch {
case gcs.isSchemeHTTP():
return strings.TrimPrefix(gcs.Endpoint, "http://")
Expand Down Expand Up @@ -181,7 +180,7 @@ func (gcs *ClientConfig) ToClientConn(ctx context.Context, host component.Host,
return nil, err
}
opts = append(opts, extraOpts...)
return grpc.DialContext(ctx, gcs.SanitizedEndpoint(), opts...)
return grpc.DialContext(ctx, gcs.sanitizedEndpoint(), opts...)
}

func (gcs *ClientConfig) toDialOptions(host component.Host, settings component.TelemetrySettings) ([]grpc.DialOption, error) {
Expand Down Expand Up @@ -278,12 +277,6 @@ func (gss *ServerConfig) ToServer(_ context.Context, host component.Host, settin
return grpc.NewServer(opts...), nil
}

// ToServerContext returns a grpc.Server for the configuration
// Deprecated: [v0.97.0] Use ToServer instead.
func (gss *ServerConfig) ToServerContext(ctx context.Context, host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) {
return gss.ToServer(ctx, host, settings, extraOpts...)
}

func (gss *ServerConfig) toServerOption(host component.Host, settings component.TelemetrySettings) ([]grpc.ServerOption, error) {
switch gss.NetAddr.Transport {
case confignet.TransportTypeTCP, confignet.TransportTypeTCP4, confignet.TransportTypeTCP6, confignet.TransportTypeUDP, confignet.TransportTypeUDP4, confignet.TransportTypeUDP6:
Expand Down
27 changes: 4 additions & 23 deletions config/configgrpc/configgrpc_test.go
Expand Up @@ -224,25 +224,6 @@ func TestAllGrpcServerSettingsExceptAuth(t *testing.T) {
}

func TestGrpcServerAuthSettings(t *testing.T) {
gss := &ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "0.0.0.0:1234",
},
}
gss.Auth = &configauth.Authentication{
AuthenticatorID: mockID,
}
host := &mockHost{
ext: map[component.ID]component.Component{
mockID: auth.NewServer(),
},
}
srv, err := gss.ToServerContext(context.Background(), host, componenttest.NewNopTelemetrySettings())
assert.NoError(t, err)
assert.NotNil(t, srv)
}

func TestGrpcServerAuthSettings_Deprecated(t *testing.T) {
gss := &ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "0.0.0.0:1234",
Expand Down Expand Up @@ -500,7 +481,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
}
for _, test := range tests {
t.Run(test.err, func(t *testing.T) {
_, err := test.settings.ToServerContext(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
_, err := test.settings.ToServer(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
assert.Regexp(t, test.err, err)
})
}
Expand Down Expand Up @@ -637,7 +618,7 @@ func TestHttpReception(t *testing.T) {
}
ln, err := gss.NetAddr.Listen(context.Background())
assert.NoError(t, err)
s, err := gss.ToServerContext(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
s, err := gss.ToServer(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
assert.NoError(t, err)
ptraceotlp.RegisterGRPCServer(s, &grpcTraceServer{})

Expand Down Expand Up @@ -684,7 +665,7 @@ func TestReceiveOnUnixDomainSocket(t *testing.T) {
}
ln, err := gss.NetAddr.Listen(context.Background())
assert.NoError(t, err)
srv, err := gss.ToServerContext(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
srv, err := gss.ToServer(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
assert.NoError(t, err)
ptraceotlp.RegisterGRPCServer(srv, &grpcTraceServer{})

Expand Down Expand Up @@ -878,7 +859,7 @@ func TestClientInfoInterceptors(t *testing.T) {
Transport: confignet.TransportTypeTCP,
},
}
srv, err := gss.ToServerContext(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
srv, err := gss.ToServer(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
require.NoError(t, err)
ptraceotlp.RegisterGRPCServer(srv, mock)

Expand Down
2 changes: 1 addition & 1 deletion receiver/otlpreceiver/otlp.go
Expand Up @@ -83,7 +83,7 @@ func (r *otlpReceiver) startGRPCServer(host component.Host) error {
}

var err error
if r.serverGRPC, err = r.cfg.GRPC.ToServerContext(context.Background(), host, r.settings.TelemetrySettings); err != nil {
if r.serverGRPC, err = r.cfg.GRPC.ToServer(context.Background(), host, r.settings.TelemetrySettings); err != nil {
return err
}

Expand Down

0 comments on commit 4f56509

Please sign in to comment.