Skip to content

Commit

Permalink
Remove deprecated functions/structs
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHelmuth committed Feb 21, 2024
1 parent f11c5bb commit a47e5fe
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 45 deletions.
25 changes: 25 additions & 0 deletions .chloggen/configgrpc-remove-deprecated-items.yaml
Original file line number Diff line number Diff line change
@@ -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 `GRPCClientSettings`, `GRPCServerSettings`, `ServerConfig.ToListenerContext` and `ClientConfig.SanitizedEndpoint`.

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

# (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: []
34 changes: 1 addition & 33 deletions config/configgrpc/configgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"crypto/tls"
"errors"
"fmt"
"net"
"strings"
"time"

Expand Down Expand Up @@ -47,10 +46,6 @@ type KeepaliveClientConfig struct {
PermitWithoutStream bool `mapstructure:"permit_without_stream"`
}

// GRPCClientSettings defines common settings for a gRPC client configuration.
// Deprecated: [v0.94.0] Use ClientConfig instead
type GRPCClientSettings = ClientConfig

// 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 @@ -120,10 +115,6 @@ type KeepaliveEnforcementPolicy struct {
PermitWithoutStream bool `mapstructure:"permit_without_stream"`
}

// GRPCServerSettings defines common settings for a gRPC server configuration.
// Deprecated: [v0.94.0] Use ServerConfig instead
type GRPCServerSettings = ServerConfig

// ServerConfig defines common settings for a gRPC server configuration.
type ServerConfig struct {
// Server net.Addr config. For transport only "tcp" and "unix" are valid options.
Expand Down Expand Up @@ -159,23 +150,6 @@ type ServerConfig struct {
IncludeMetadata bool `mapstructure:"include_metadata"`
}

// SanitizedEndpoint strips the prefix of either http:// or https:// from configgrpc.ClientConfig.Endpoint.
// Deprecated: [v0.95.0] Trim the prefix from configgrpc.ClientConfig.Endpoint directly.
func (gcs *ClientConfig) SanitizedEndpoint() string {
switch {
case gcs.isSchemeHTTP():
return strings.TrimPrefix(gcs.Endpoint, "http://")
case gcs.isSchemeHTTPS():
return strings.TrimPrefix(gcs.Endpoint, "https://")
default:
return gcs.Endpoint
}
}

func (gcs *ClientConfig) isSchemeHTTP() bool {
return strings.HasPrefix(gcs.Endpoint, "http://")
}

func (gcs *ClientConfig) isSchemeHTTPS() bool {
return strings.HasPrefix(gcs.Endpoint, "https://")
}
Expand All @@ -190,7 +164,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.Endpoint, opts...)
}

func (gcs *ClientConfig) toDialOptions(host component.Host, settings component.TelemetrySettings) ([]grpc.DialOption, error) {
Expand Down Expand Up @@ -277,12 +251,6 @@ func validateBalancerName(balancerName string) bool {
return balancer.Get(balancerName) != nil
}

// ToListenerContext returns the net.Listener constructed from the settings.
// Deprecated: [v0.95.0] Call Listen directly on the NetAddr field.
func (gss *ServerConfig) ToListenerContext(ctx context.Context) (net.Listener, error) {
return gss.NetAddr.Listen(ctx)
}

func (gss *ServerConfig) ToServer(host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) {
opts, err := gss.toServerOption(host, settings)
if err != nil {
Expand Down
14 changes: 4 additions & 10 deletions config/configgrpc/configgrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,8 @@ func TestGRPCServerSettings_ToListener_Error(t *testing.T) {
Endpoint: "127.0.0.1:1234567",
Transport: "tcp",
},
TLSSetting: &configtls.TLSServerSetting{
TLSSetting: configtls.TLSSetting{
CertFile: "/doesnt/exist",
},
},
Keepalive: nil,
}
_, err := settings.ToListenerContext(context.Background())
_, err := settings.NetAddr.Listen(context.Background())
assert.Error(t, err)
}

Expand Down Expand Up @@ -622,7 +616,7 @@ func TestHttpReception(t *testing.T) {
},
TLSSetting: test.tlsServerCreds,
}
ln, err := gss.ToListenerContext(context.Background())
ln, err := gss.NetAddr.Listen(context.Background())
assert.NoError(t, err)
s, err := gss.ToServer(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
assert.NoError(t, err)
Expand Down Expand Up @@ -669,7 +663,7 @@ func TestReceiveOnUnixDomainSocket(t *testing.T) {
Transport: "unix",
},
}
ln, err := gss.ToListenerContext(context.Background())
ln, err := gss.NetAddr.Listen(context.Background())
assert.NoError(t, err)
srv, err := gss.ToServer(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
assert.NoError(t, err)
Expand Down Expand Up @@ -871,7 +865,7 @@ func TestClientInfoInterceptors(t *testing.T) {

defer srv.Stop()

l, err = gss.ToListenerContext(context.Background())
l, err = gss.NetAddr.Listen(context.Background())
require.NoError(t, err)

go func() {
Expand Down
2 changes: 1 addition & 1 deletion exporter/otlpexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Config struct {
}

func (c *Config) Validate() error {
if c.SanitizedEndpoint() == "" {
if c.Endpoint == "" {
return errors.New(`requires a non-empty "endpoint"`)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion receiver/otlpreceiver/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (r *otlpReceiver) startGRPCServer(host component.Host) error {

r.settings.Logger.Info("Starting GRPC server", zap.String("endpoint", r.cfg.GRPC.NetAddr.Endpoint))
var gln net.Listener
if gln, err = r.cfg.GRPC.ToListenerContext(context.Background()); err != nil {
if gln, err = r.cfg.GRPC.NetAddr.Listen(context.Background()); err != nil {
return err
}

Expand Down

0 comments on commit a47e5fe

Please sign in to comment.