Add support for OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT env var#2056
Add support for OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT env var#2056owais merged 12 commits intoopen-telemetry:mainfrom
OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT env var#2056Conversation
|
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.
This block of code is confusing to me. I will pull this to local and check.
There was a problem hiding this comment.
Wow this whole limits stuff is confusing. Please check the L596-L610 once.
There was a problem hiding this comment.
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.
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.
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
| """ | ||
|
|
||
| OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT = "OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT" | ||
| """ |
There was a problem hiding this comment.
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.
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.
wouldn't that break the API (change behavior) if all arguments are passed as positional?
There was a problem hiding this comment.
Oh do you mean if someone were to call __repr__ directly?
There was a problem hiding this comment.
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.
I think @lzchen didn't mean to change the order in __init__ but just in the __repr__ string.
lzchen
left a comment
There was a problem hiding this comment.
Just a few comments about comments :)
| 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.
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.
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: