Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override insecure when endpoint URL is set #5944

Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,7 @@ func WithEndpointURL(v string) GenericOption {

cfg.Metrics.Endpoint = u.Host
cfg.Metrics.URLPath = u.Path
if u.Scheme != "https" {
cfg.Metrics.Insecure = true
}
cfg.Metrics.Insecure = u.Scheme != "https"
pellared marked this conversation as resolved.
Show resolved Hide resolved

return cfg
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ func TestConfigs(t *testing.T) {
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
},
},
{
name: "Test With WithEndpointURL secure when Environment Endpoint is set insecure",
env: map[string]string{
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://env.endpoint/prefix",
},
opts: []GenericOption{
WithEndpointURL("https://someendpoint/somepath"),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, "someendpoint", c.Metrics.Endpoint)
assert.Equal(t, "/somepath", c.Metrics.URLPath)
assert.False(t, c.Metrics.Insecure)
},
},
{
name: "Test Environment Endpoint",
env: map[string]string{
Expand Down
Loading