-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
detect: sever semconv relationship to otel sdk
Copies over the telemetry sdk detection to utilize our own version of semconv rather than mix the versions between different packages. This will keep a consistent schema url instead of constantly chasing whichever one the otel sdk is using. The only thing left from the otel sdk is `WithFromEnv` which is schemaless and won't conflict for that reason so we can continue to use it.
- Loading branch information
1 parent
9d81766
commit e4b442a
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package detect | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"go.opentelemetry.io/otel" | ||
) | ||
|
||
func TestResource(t *testing.T) { | ||
prevHandler := otel.GetErrorHandler() | ||
t.Cleanup(func() { | ||
otel.SetErrorHandler(prevHandler) | ||
}) | ||
|
||
var resourceErr error | ||
otel.SetErrorHandler(otel.ErrorHandlerFunc(func(err error) { | ||
resourceErr = err | ||
})) | ||
|
||
res := Resource() | ||
|
||
// Should not have an empty schema url. Only happens when | ||
// there is a schema conflict. | ||
require.NotEqual(t, "", res.SchemaURL()) | ||
|
||
// No error should have been invoked. | ||
require.NoError(t, resourceErr) | ||
} |