-
Notifications
You must be signed in to change notification settings - Fork 651
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
Add support for additional Span Limits #2044
Conversation
b8c6ce2
to
6f25751
Compare
"Byte attribute could not be decoded for key `%s`.", | ||
key, | ||
) | ||
return |
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.
these checks were redundant as they're run by BoundedAttributes internally as well.
5c8ef2e
to
14d3e46
Compare
14d3e46
to
061e72c
Compare
OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT
OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT
, OTEL_LINK_ATTRIBUTE_COUNT_LIMIT
& OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT
OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT
, OTEL_LINK_ATTRIBUTE_COUNT_LIMIT
& OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT
self._resource._attributes = BoundedAttributes( | ||
self._span_limits.max_attributes, | ||
self._resource._attributes, | ||
max_value_len=self._span_limits.max_attribute_length, |
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.
This follows the existing pattern used with span events but technically mutates the resource as it'll end up truncating or dropping pre-existing attributes on a resource. I think in very strict terms it does mutate the resource but in practice this is what users would expect IMO. Curious to hear what other think about this.
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 kind of confused why span limits are used with resource. We don't want to mutate resource since it is prohibited by the spec and I interpreted Resource as its own entity different from span/metric/log. Did the spec introduce limits for Resources?
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.
Spec doesn't say anything about it AFAIK and I agree we can probably exclude resources completely. In practice the issues that limits solve don't really plague resources anyway. However, we were applying these limits (the default one at least) so far so this will be a behavioral change (128 max resource attributes to unlimited) although extremely unlikely to impact anyone. @lonewolf3739
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 personally don't find using span limits for resources to be good. Can we take this up in separate issue?
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 agree with you. Let's discuss in the SIG meeting.
|
||
|
||
_DEFAULT_LIMIT = 128 | ||
if limit is not None and isinstance(value, str): |
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.
Could the attribute length truncation technically apply to other value types as well?
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.
Spec limits it to only strings and arrays of strings where the limit applies to each element. https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/common.md#attribute-limits
if it is a string, if it exceeds that limit (counting any character in it as 1), SDKs MUST truncate that value, so that its length is at most equal to the limit,
if it is an array of strings, then apply the above rule to each of the values separately,
otherwise a value MUST NOT be truncated;
@@ -129,10 +148,10 @@ def __init__( | |||
) | |||
self.maxlen = maxlen | |||
self.dropped = 0 | |||
self.max_value_len = max_value_len |
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.
Might need some validation for: Empty value is treated as infinity. Non-integer and negative values are invalid.
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 know this is a small ask but I ended up fixing too many unrelated issues in this PR. Created an issue for this and will take care of it in a separate one tomorrow. #2052
@@ -630,8 +637,10 @@ def _from_env_if_absent( | |||
max_links=SpanLimits.UNSET, | |||
max_event_attributes=SpanLimits.UNSET, | |||
max_link_attributes=SpanLimits.UNSET, | |||
max_attribute_length=SpanLimits.UNSET, |
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.
For some reason this limit is the only one in the specs to have notes. Negative values are invalid apparently? What do we do in those cases.
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 sure that note applies to all limits and it was just a mistake by the author. I'll take care of negative/unset values in a new PR (created issue: #2052)
@lzchen @lonewolf3739 please review public API check and add the label if everything looks good. |
Public API check was approved on another PR with these changes so I'm self-approving the check here. |
Description
Added support for
OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT
,OTEL_LINK_ATTRIBUTE_COUNT_LIMIT
&OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT
, and fixes a number of bugs.Fixes #2045
Fixes #2043
Fixes #2042
Fixes #2041
Otel Specification: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#span-limits-
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Contrib Repo Change?
Checklist: