forked from moby/buildkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
detect: use newer semconv for resource and add unit test
We upgraded a dependency that upgraded otel and also changed the semconv schema for us to a newer version. We forgot to upgrade our own semconv. In the future, we may want to find a way to have a detector that doesn't require us to manually specify a semconv so we don't have to remember this. For now, I've added a test to catch when this happens so it doesn't happen again. Signed-off-by: Jonathan A. Sternberg <[email protected]>
- Loading branch information
1 parent
9d81766
commit 323be17
Showing
3 changed files
with
31 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) | ||
} |
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