You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-29 23:07:45 +02:00
fix(2138): add guard to constructOTResources to return an empty resource (#2139)
* fix(2138): add guard to constructOTResources to return an empty resource when attributes are not supplied Fixes: https://github.com/open-telemetry/opentelemetry-go/issues/2138 * Update CHANGELOG.md Co-authored-by: Robert Pająk <pellared@hotmail.com> Co-authored-by: Robert Pająk <pellared@hotmail.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
@@ -72,6 +72,20 @@ func TestEmpty(t *testing.T) {
|
||||
assert.Equal(t, Empty(), res)
|
||||
}
|
||||
|
||||
func TestNoResourceAttributesSet(t *testing.T) {
|
||||
store, err := ottest.SetEnvVariables(map[string]string{
|
||||
svcNameKey: "bar",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
defer func() { require.NoError(t, store.Restore()) }()
|
||||
detector := &fromEnv{}
|
||||
res, err := detector.Detect(context.Background())
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, res, NewSchemaless(
|
||||
semconv.ServiceNameKey.String("bar"),
|
||||
))
|
||||
}
|
||||
|
||||
func TestMissingKeyError(t *testing.T) {
|
||||
store, err := ottest.SetEnvVariables(map[string]string{
|
||||
resourceAttrKey: "key=value,key",
|
||||
|
||||
Reference in New Issue
Block a user