Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The next release will require at least [Go 1.26].
- Name span events created from OpenTracing logs after the `event` log field, falling back to `log`, instead of always using an empty name in `go.opentelemetry.io/otel/bridge/opentracing`. (#8648)
- Count exception attributes omitted due to the attribute count limit as dropped in `go.opentelemetry.io/otel/sdk/log`. (#8796)
- Encode `NaN` and infinite double attribute values as strings in OTLP/HTTP JSON requests from `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`. (#8775)
- Ignore HTTP(S) paths when deriving gRPC trace exporter endpoints from `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`.
Comment thread
RedZapdos123 marked this conversation as resolved.
Outdated
- Prevent log record and instrumentation scope attributes with empty keys from reaching processors and exporters in `go.opentelemetry.io/otel/sdk/log`. (#8797)
- Fix a data race when span attributes are read concurrently in `go.opentelemetry.io/otel/sdk/trace`. (#8706)
- Prevent a panic in `(*Set).Filter` when called on a nil receiver in `go.opentelemetry.io/otel/attribute`. (#8792)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,20 @@ func withEndpointScheme(u *url.URL) GenericOption {
}

func withEndpointForGRPC(u *url.URL) func(cfg Config) Config {
target := u.String()
switch strings.ToLower(u.Scheme) {
case "http", "https":
target = u.Host
case "":
if u.Host != "" {
target = path.Join(u.Host, u.Path)
}
}

return func(cfg Config) Config {
// For OTLP/gRPC endpoints, this is the target to which the
// exporter is going to send telemetry.
cfg.Traces.Endpoint = path.Join(u.Host, u.Path)
cfg.Traces.Endpoint = target
return cfg
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,27 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) { //nolint:revive // interface compliance
assert.False(t, c.Traces.Insecure)
if grpcOption {
assert.Equal(t, "env.endpoint/prefix", c.Traces.Endpoint)
assert.Equal(t, "env.endpoint", c.Traces.Endpoint)
} else {
assert.Equal(t, "env.endpoint", c.Traces.Endpoint)
assert.Equal(t, "/prefix/v1/traces", c.Traces.URLPath)
}
},
},
{
name: "Test Environment Signal Specific Endpoint With Path",
env: map[string]string{
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://overrode.by.signal.specific/env/var",
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT": "http://env.traces.endpoint/prefix",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) { //nolint:revive // interface compliance
assert.True(t, c.Traces.Insecure)
assert.Equal(t, "env.traces.endpoint", c.Traces.Endpoint)
if !grpcOption {
assert.Equal(t, "/prefix", c.Traces.URLPath)
}
},
},
{
name: "Test Environment Signal Specific Endpoint",
env: map[string]string{
Expand All @@ -200,6 +214,18 @@ func TestConfigs(t *testing.T) {
}
},
},
{
name: "Test Environment Unix Endpoint",
env: map[string]string{
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT": "unix:///tmp/otel.sock",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) { //nolint:revive // interface compliance
assert.True(t, c.Traces.Insecure)
if grpcOption {
assert.Equal(t, "unix:///tmp/otel.sock", c.Traces.Endpoint)
}
},
},
{
name: "Test Mixed Environment and With Endpoint",
opts: []GenericOption{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,20 @@ func withEndpointScheme(u *url.URL) GenericOption {
}

func withEndpointForGRPC(u *url.URL) func(cfg Config) Config {
target := u.String()
switch strings.ToLower(u.Scheme) {
case "http", "https":
target = u.Host
case "":
if u.Host != "" {
target = path.Join(u.Host, u.Path)
}
}

return func(cfg Config) Config {
// For OTLP/gRPC endpoints, this is the target to which the
// exporter is going to send telemetry.
cfg.Traces.Endpoint = path.Join(u.Host, u.Path)
cfg.Traces.Endpoint = target
return cfg
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,27 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) { //nolint:revive // interface compliance
assert.False(t, c.Traces.Insecure)
if grpcOption {
assert.Equal(t, "env.endpoint/prefix", c.Traces.Endpoint)
assert.Equal(t, "env.endpoint", c.Traces.Endpoint)
} else {
assert.Equal(t, "env.endpoint", c.Traces.Endpoint)
assert.Equal(t, "/prefix/v1/traces", c.Traces.URLPath)
}
},
},
{
name: "Test Environment Signal Specific Endpoint With Path",
env: map[string]string{
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://overrode.by.signal.specific/env/var",
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT": "http://env.traces.endpoint/prefix",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) { //nolint:revive // interface compliance
assert.True(t, c.Traces.Insecure)
assert.Equal(t, "env.traces.endpoint", c.Traces.Endpoint)
if !grpcOption {
assert.Equal(t, "/prefix", c.Traces.URLPath)
}
},
},
{
name: "Test Environment Signal Specific Endpoint",
env: map[string]string{
Expand All @@ -200,6 +214,18 @@ func TestConfigs(t *testing.T) {
}
},
},
{
name: "Test Environment Unix Endpoint",
env: map[string]string{
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT": "unix:///tmp/otel.sock",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) { //nolint:revive // interface compliance
assert.True(t, c.Traces.Insecure)
if grpcOption {
assert.Equal(t, "unix:///tmp/otel.sock", c.Traces.Endpoint)
}
},
},
{
name: "Test Mixed Environment and With Endpoint",
opts: []GenericOption{
Expand Down
12 changes: 11 additions & 1 deletion internal/shared/otlp/otlptrace/otlpconfig/envconfig.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,20 @@ func withEndpointScheme(u *url.URL) GenericOption {
}

func withEndpointForGRPC(u *url.URL) func(cfg Config) Config {
target := u.String()
switch strings.ToLower(u.Scheme) {
case "http", "https":
target = u.Host
Comment thread
RedZapdos123 marked this conversation as resolved.
case "":
if u.Host != "" {
target = path.Join(u.Host, u.Path)
Comment thread
RedZapdos123 marked this conversation as resolved.
}
}

return func(cfg Config) Config {
// For OTLP/gRPC endpoints, this is the target to which the
// exporter is going to send telemetry.
cfg.Traces.Endpoint = path.Join(u.Host, u.Path)
cfg.Traces.Endpoint = target
return cfg
}
}
Expand Down
28 changes: 27 additions & 1 deletion internal/shared/otlp/otlptrace/otlpconfig/options_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,27 @@ func TestConfigs(t *testing.T) {
asserts: func(t *testing.T, c *Config, grpcOption bool) { //nolint:revive // interface compliance
assert.False(t, c.Traces.Insecure)
if grpcOption {
assert.Equal(t, "env.endpoint/prefix", c.Traces.Endpoint)
assert.Equal(t, "env.endpoint", c.Traces.Endpoint)
} else {
assert.Equal(t, "env.endpoint", c.Traces.Endpoint)
assert.Equal(t, "/prefix/v1/traces", c.Traces.URLPath)
}
},
},
{
name: "Test Environment Signal Specific Endpoint With Path",
env: map[string]string{
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://overrode.by.signal.specific/env/var",
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT": "http://env.traces.endpoint/prefix",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) { //nolint:revive // interface compliance
assert.True(t, c.Traces.Insecure)
assert.Equal(t, "env.traces.endpoint", c.Traces.Endpoint)
if !grpcOption {
assert.Equal(t, "/prefix", c.Traces.URLPath)
}
},
},
{
name: "Test Environment Signal Specific Endpoint",
env: map[string]string{
Expand All @@ -200,6 +214,18 @@ func TestConfigs(t *testing.T) {
}
},
},
{
name: "Test Environment Unix Endpoint",
env: map[string]string{
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT": "unix:///tmp/otel.sock",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) { //nolint:revive // interface compliance
assert.True(t, c.Traces.Insecure)
if grpcOption {
assert.Equal(t, "unix:///tmp/otel.sock", c.Traces.Endpoint)
}
},
},
{
name: "Test Mixed Environment and With Endpoint",
opts: []GenericOption{
Expand Down
Loading