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 9c5ad08
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .chloggen/deprecate-SanatizedEndpoints.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: deprecation

# 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: Deprecate `SanitizedEndpoint`

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

# (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: []
1 change: 1 addition & 0 deletions config/configgrpc/configgrpc.go
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
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://")

Check warning on line 37 in exporter/otlpexporter/config.go

View check run for this annotation

Codecov / codecov/patch

exporter/otlpexporter/config.go#L36-L37

Added lines #L36 - L37 were not covered by tests
default:
return c.Endpoint
}
}

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

0 comments on commit 9c5ad08

Please sign in to comment.