Skip to content
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

Merged
merged 12 commits into from
Aug 24, 2021

Conversation

owais
Copy link
Contributor

@owais owais commented Aug 18, 2021

Description

Fixes #2051

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Manually
  • Added/updated tests

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@owais owais requested review from a team, codeboten and NathanielRN and removed request for a team August 18, 2021 22:47
@owais
Copy link
Contributor Author

owais commented Aug 18, 2021

Builds on top of #2044. Should be rebased and reviewed after 2044 is merged.

Comment on lines 598 to 612
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,
)
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

@owais owais Aug 19, 2021

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.
Copy link
Contributor

@lzchen lzchen Aug 23, 2021

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?

  1. Model specific if set
  2. Global if set
  3. Model default
  4. Global default

Copy link
Contributor Author

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"
"""
Copy link
Contributor

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(
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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 :)

Copy link
Contributor

@lzchen lzchen left a 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 :)

@owais owais requested review from srikanthccv and lzchen August 24, 2021 13:56
@@ -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(
Copy link
Member

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?

Copy link
Contributor Author

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.

@srikanthccv srikanthccv added the Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary label Aug 24, 2021
@owais owais merged commit 4250078 into open-telemetry:main Aug 24, 2021
@owais owais deleted the fix-2051 branch August 24, 2021 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support global attribute limits
3 participants