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

Document and check resource comparability #6272

Merged
merged 9 commits into from
Feb 12, 2025
Merged
9 changes: 9 additions & 0 deletions sdk/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ import (
// Resources should be passed and stored as pointers
// (`*resource.Resource`). The `nil` value is equivalent to an empty
// Resource.
//
// While Resource is comparable, its comparison should not be relied on when
// checking equality. The [Resource.Equal] method should be used to check
// equality between two resources and the [attribute.Distinct] returned from
// [Resource.Equivalent] should be used for map keys instead. No guantee of the
dashpole marked this conversation as resolved.
Show resolved Hide resolved
// correctness of direct comparisons is provided.
type Resource struct {
attrs attribute.Set
schemaURL string
}

// Compile-time check that the Resource remains comparable.
var _ map[Resource]struct{} = nil

var (
defaultResource *Resource
defaultResourceOnce sync.Once
Expand Down
Loading