Skip to content

Commit

Permalink
Add Resource.schema_url to dunder eq and hash
Browse files Browse the repository at this point in the history
  • Loading branch information
dgetu committed May 24, 2021
1 parent 1b03a5c commit 8d7f8d1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,13 @@ def merge(self, other: "Resource") -> "Resource":
def __eq__(self, other: object) -> bool:
if not isinstance(other, Resource):
return False
return self._attributes == other._attributes
return (
self._attributes == other._attributes
and self._schema_url == other._schema_url
)

def __hash__(self):
return hash(dumps(self._attributes, sort_keys=True))
return hash(dumps(self._attributes, sort_keys=True) + self._schema_url)


_EMPTY_RESOURCE = Resource({}, "")
Expand Down

0 comments on commit 8d7f8d1

Please sign in to comment.