Skip to content

Commit

Permalink
Implement get_attribute and set_attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Jul 31, 2020
1 parent 66905fc commit ca213af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions opentelemetry-api/src/opentelemetry/trace/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def set_attribute(self, key: str, value: types.AttributeValue) -> None:
Sets a single Attribute with the key and value passed as arguments.
"""

@abc.abstractmethod
def get_attribute(self, key: str) -> types.AttributeValue:
"""Gets an Attribute.
Gets a single Attribute with the key passed as argument.
"""

@abc.abstractmethod
def add_event(
self,
Expand Down Expand Up @@ -235,6 +242,9 @@ def end(self, end_time: typing.Optional[int] = None) -> None:
def set_attribute(self, key: str, value: types.AttributeValue) -> None:
pass

def get_attribute(self, key: str) -> types.AttributeValue:
pass

def add_event(
self,
name: str,
Expand Down
4 changes: 4 additions & 0 deletions opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,10 @@ def set_attribute(self, key: str, value: types.AttributeValue) -> None:
with self._lock:
self.attributes[key] = value

def get_attribute(self, key: str) -> types.AttributeValue:

return self.attributes[key]

@staticmethod
def _filter_attribute_values(attributes: types.Attributes):
if attributes:
Expand Down

0 comments on commit ca213af

Please sign in to comment.