Skip to content

Commit

Permalink
Deprecate SanitizedEndpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHelmuth committed Mar 18, 2024
1 parent 3b5aee0 commit eaf041d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/configgrpc/configgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ type ServerConfig struct {
}

// SanitizedEndpoint strips the prefix of either http:// or https:// from configgrpc.ClientConfig.Endpoint.
// Deprecated: [v0.97.0]
func (gcs *ClientConfig) SanitizedEndpoint() string {
switch {
case gcs.isSchemeHTTP():
Expand Down
14 changes: 13 additions & 1 deletion exporter/otlpexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package otlpexporter // import "go.opentelemetry.io/collector/exporter/otlpexpor

import (
"errors"
"strings"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configgrpc"
Expand All @@ -22,10 +23,21 @@ type Config struct {
}

func (c *Config) Validate() error {
if c.SanitizedEndpoint() == "" {
if c.sanitizedEndpoint() == "" {
return errors.New(`requires a non-empty "endpoint"`)
}
return nil
}

func (c *Config) sanitizedEndpoint() string {
switch {
case strings.HasPrefix(c.Endpoint, "http://"):
return strings.TrimPrefix(c.Endpoint, "http://")
case strings.HasPrefix(c.Endpoint, "https://"):
return strings.TrimPrefix(c.Endpoint, "https://")
default:
return c.Endpoint
}
}

var _ component.Config = (*Config)(nil)

0 comments on commit eaf041d

Please sign in to comment.