Skip to content

Commit

Permalink
[exporter/otlp] Allow DNS scheme to be used in endpoint (open-telemet…
Browse files Browse the repository at this point in the history
…ry#10010)

Fixes open-telemetry#4274

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
  • Loading branch information
jpkrohling authored and andrzej-stencel committed May 27, 2024
1 parent d32c443 commit eeb2e9f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .chloggen/4274-allow-dns-as-scheme-for-endpoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Use this changelog template to create an entry for release notes.

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

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: exporter/otlp

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Allow DNS scheme to be used in endpoint

# One or more tracking issues or pull requests related to the change
issues: [4274]
2 changes: 2 additions & 0 deletions exporter/otlpexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ func (c *Config) sanitizedEndpoint() string {
return strings.TrimPrefix(c.Endpoint, "http://")
case strings.HasPrefix(c.Endpoint, "https://"):
return strings.TrimPrefix(c.Endpoint, "https://")
case strings.HasPrefix(c.Endpoint, "dns:///"):
return strings.TrimPrefix(c.Endpoint, "dns:///")
default:
return c.Endpoint
}
Expand Down
7 changes: 7 additions & 0 deletions exporter/otlpexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,10 @@ func TestUnmarshalInvalidConfig(t *testing.T) {
}

}

func TestValidDNSEndpoint(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)
cfg.Endpoint = "dns:///backend.example.com:4317"
assert.NoError(t, cfg.Validate())
}

0 comments on commit eeb2e9f

Please sign in to comment.