-
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 OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT
env var
#2056
Conversation
Builds on top of #2044. Should be rebased and reviewed after 2044 is merged. |
OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, | ||
) | ||
|
||
self.max_attribute_length = self._from_env_if_absent( | ||
max_attribute_length, | ||
OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT, | ||
) | ||
self.max_span_attribute_length = self._from_env_if_absent( | ||
max_span_attribute_length, | ||
OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, | ||
# use global attribute length limit as default | ||
self.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 block of code is confusing to me. I will pull this to local and check.
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.
Wow this whole limits stuff is confusing. Please check the L596-L610 once.
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.
My bad. I think it happened due to a bad rebase on github. Fixed now.
|
||
- If a model specific limit is set, it will be used. | ||
- Else if the model specific limit has a default value, the default value will be used. | ||
- Else if model specific limit has a corresponding global limit, the global limit will be used. |
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.
Shouldn't 543 and 542 be switched?
- Model specific if set
- Global if set
- Model default
- Global default
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.
They way I understood the spec, I think model default takes precedence over global user provided value and it sure is counter-intuitive. Spec says the following:
An SDK MAY implement model-specific limits, for example SpanAttributeCountLimit. If both a general and a model-specific limit are implemented, then the SDK MUST first attempt to use the model-specific limit, if it isn't set and doesn't have a default, then the SDK MUST attempt to use the general limit.
Am I reading it wrong?
Also created a spec issue here to get clarification: open-telemetry/opentelemetry-specification#1878
|
||
The :envvar:`OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT` represents the maximum allowed attribute length. | ||
""" | ||
|
||
OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT = "OTEL_EVENT_ATTRIBUTE_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.
Could you modify the docstring for OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT
to say that it is specific for attributes on span? AS well, it takes precedence over OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT
specifically for span attributes.
) | ||
|
||
def __repr__(self): | ||
return "{}(max_attributes={}, max_events={}, max_links={}, max_event_attributes={}, max_link_attributes={}, max_attribute_length={})".format( | ||
return "{}(max_attributes={}, max_events={}, max_links={}, max_event_attributes={}, max_link_attributes={}, max_attribute_length={}, max_span_attribute_length={})".format( |
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.
Nit: Can we switch the ordering of span_attribute
and attribute
? I'd like to see the model specific be defined first.
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.
wouldn't that break the API (change behavior) if all arguments are passed as positional?
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.
Oh do you mean if someone were to call __repr__
directly?
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.
No, I mean if we swap max_span_attributes with max_attributes the signature will look like:
SpanLimits(max_span_attributes, max_events, max_links, max_event_attributes, max_link_attributes, max_attributes)
which would be model
, global
, global
, model
, model
, global
. That doesn't look very nice. At least all max_*_attributes
should be together. If we change the signature to
SpanLimits(max_span_attributes, max_event_attributes, max_link_attributes, max_attributes, max_links, max_events)
Then any users calling the function today as SpanLimits(1, 2, 3, 4, 5)
will get unexpected behavior that'll be hard to detect as we changed the position of arguments.
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 think @lzchen didn't mean to change the order in __init__
but just in the __repr__
string.
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.
Oh, I see it now :)
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.
Just a few comments about comments :)
@@ -1562,3 +1589,105 @@ def test_dropped_attributes(self): | |||
self.assertEqual(2, span.events[0].attributes.dropped) | |||
self.assertEqual(2, span.links[0].attributes.dropped) | |||
self.assertEqual(2, span.resource.attributes.dropped) | |||
|
|||
def _test_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.
Is this because of bad rebase? Why is it showing as new addition if not used anywhere in this diff?
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.
Yes. I had moved them to the bottom but looks like rebase added them back to the original place? Fixed now.
Description
Fixes #2051
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Contrib Repo Change?
Checklist: