-
Notifications
You must be signed in to change notification settings - Fork 644
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
use BoundedAttributes for attributes in link, event, resource, spans #1915
use BoundedAttributes for attributes in link, event, resource, spans #1915
Conversation
def __init__( | ||
self, | ||
maxlen: Optional[int] = _DEFAULT_LIMIT, | ||
attributes: types.Attributes = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attributes
makes sense in terms of what we are using BoundedDict
for, but for the class itself it doesn't make much sense. Should we have a different name instead of BoundedDict
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to make a separation from the SDK BoundedDict
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I considered for a minute making Attributes
a class to replace BoundedDict
, wasn't sure if this would be doable without breaking Attributes' current interface though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just BoundedAttributes
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -555,6 +561,16 @@ def __init__( | |||
OTEL_SPAN_LINK_COUNT_LIMIT, | |||
_DEFAULT_OTEL_SPAN_LINK_COUNT_LIMIT, | |||
) | |||
self.max_event_attributes = self._from_env_if_absent( | |||
max_event_attributes, | |||
OTEL_SPAN_LINK_COUNT_LIMIT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these placeholders until this is merged? Would be good to have a TODO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Captured the work in an issue #1918
The functionality seems very specific to |
if key in self._dict: | ||
del self._dict[key] | ||
elif self.maxlen is not None and len(self._dict) == self.maxlen: | ||
del self._dict[next(iter(self._dict.keys()))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._dict.popitem(last=False)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious what people's thoughts on this are. It's confusing to me that if the attributes dict is full, we delete an existing item from the dictionary in favour of the new item. Any thoughts @lzchen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah my first impression when reading the specs is that the LATEST item that is attempting to be added would be dropped instead of popping the first item that was added. If we decide on changing the functionality, you could leave that for a separate PR if you wish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do other SIGs do? And also spec says There SHOULD be a log emitted to indicate to the user that an attribute, event, or link was discarded due to such a limit. To prevent excessive logging, the log should not be emitted once per span, or per discarded attribute, event, or links. https://github.com/open-telemetry/opentelemetry-specification/blob/b46bcab5fb709381f1fd52096a19541370c7d1b3/specification/trace/sdk.md#span-limits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like go does the same thing as we do currently. https://github.com/open-telemetry/opentelemetry-go/blob/c1f460e097d395fa7cd02acc4a6096d6c6f14b08/sdk/trace/attributesmap.go#L45-L62
I agree that for now it probably doesn't make sense to change the behaviour
Description
Continuing towards making attributes consistent across Span, Link, Event and Resource by utilizing BoundedDict everywhere. Added
BoundedDict
to the API to make it available forLink
which is defined in the API. MarkedBoundedDict
in the SDK as deprecated as a result. This is getting us one step closer to supporting dropped attribute counts in the exporters. One question I have for reviewers is whether the BoundedDict should be inopentelemetry.attributes
or not, it could live in utils or something like that instead.Fixes #1906
Type of change
Please delete options that are not relevant.
Does This PR Require a Contrib Repo Change?
Checklist: