-
Notifications
You must be signed in to change notification settings - Fork 672
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 span collection limit via env vars #1377
Add support for span collection limit via env vars #1377
Conversation
90a5f86
to
9def1dc
Compare
Exporter builds do not pass because a test asserting to True logs an errors... I'm not sure I get why it happens while related code has not been updated since mid-october 🤷♂️ |
@@ -429,8 +427,10 @@ def __init__( | |||
instrumentation_info: InstrumentationInfo = None, | |||
record_exception: bool = True, | |||
set_status_on_exception: bool = True, | |||
attribute_count_limit: int = 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.
I believe tracer.start_as_current_span()
and tracer.start_span()
needs to have these parameters as well, since that is the suggested way to construct spans through our api.
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.
that is an interesting question. If we do that it will violate the API.
There isn't actually a requirement to expose this configuration via the span methods: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk.md#limits-on-span-collections.
This configuration could be handled in the constructor of the TracerProvider, which forwards those values to the Span.
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.
Or we can limit configuration to be only done through environment variables, similarly to propagators.
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.
that's fine, although something I generally am not a huge fan of. My personal taste for programmatic APIs is not a blocker :)
FWIW my preference comes from the desire for linter / syntax checkers to verify that the method I'm calling exists. It's hard to know whether an environment variable is still supported or not programmatically: you just hope there's no backwards incompatible changes.
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, as a user I would find it difficult to find out what env vars are available. Perhaps more can be discussed here. For now, I am fine with leaving the programmatic part out of this PR.
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.
Thanks for the changes! Overall the idea looks good. I think we do need some way to allow the user to manually wire in the values (sdk.TraceProvider would be good), and if possible we only have to query configuration once in the lifetime of the application to change that setting.
@@ -429,8 +427,10 @@ def __init__( | |||
instrumentation_info: InstrumentationInfo = None, | |||
record_exception: bool = True, | |||
set_status_on_exception: bool = True, | |||
attribute_count_limit: int = 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.
that is an interesting question. If we do that it will violate the API.
There isn't actually a requirement to expose this configuration via the span methods: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk.md#limits-on-span-collections.
This configuration could be handled in the constructor of the TracerProvider, which forwards those values to the Span.
9def1dc
to
b7f367e
Compare
Hi! Settled down with:
Up for review, do not hesitate if this implementaion is not satisfying (yet!) |
I think from this comment, we only want these configurations to be modified through environment variables, not through the parameters of the constructor. |
But aren't tracers and spans supposed to only be created through dedicated methods like ( If that is not satisfying, do you think an okay approach would be to simply change those three lines to retrieve from env? https://github.com/open-telemetry/opentelemetry-python/blob/master/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py#L52 |
|
You are correct, however adding these as parameters to those functions will break the api definitions as [mentioned above](#1377 (comment). I think the consensus is to not expose these at all to be manually configured through the constructors, but only configured through environment variables similar to [propagators](https://github.com/open-telemetry/opentelemetry-python/blob/master/opentelemetry-api/src/opentelemetry/propagators/__init__.py#L129. |
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.
LGTM! Thanks.
@@ -907,6 +915,16 @@ def __init__( | |||
if shutdown_on_exit: | |||
self._atexit_handler = atexit.register(self.shutdown) | |||
|
|||
self.span_attribute_count_limit = Configuration().get( |
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.
at this point, you've almost done all the work to make this programmatically configurable: just make each of these defaults customizable, or some combination there of.
But not an issue if you choose not to do so.
b7f367e
to
110011f
Compare
Hi @lzchen ! Sorry, I have not taken the time to get back to this.
Understood! I have tried to write something like this, which basically is like replacing doing that if I'm not mistaken:
It makes the feature clunky to test, I don't feel comfortable shipping that but maybe I simply did not understand your suggestion 😐. I believe that a way to implement those limitations in the code without violating the API is to use intermediary classes. That allows us to leverage the TracerProvider, as @toumorokoshi suggested. According to the spec, I understand that this is where this kind of configuration should live:
I've updated the PR with that, tell me what you think about it. The style does not pass, but I'd really like a feedback before investing more time in either fixing the style or finding a better way to implement the "global" solution |
@LetzNico
is what I was referring to and is correct. If you need guidance on how to test this, you can patch the the environment variables and pass in your own values like here. |
This adds support for the following env variables: * OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT (Maximum allowed span attribute count) * OTEL_SPAN_EVENT_COUNT_LIMIT (Maximum allowed span event count) * OTEL_SPAN_LINK_COUNT_LIMIT (Maximum allowed span link count)
110011f
to
894e4a7
Compare
This adds support for the following env variables: * OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT (Maximum allowed span attribute count) * OTEL_SPAN_EVENT_COUNT_LIMIT (Maximum allowed span event count) * OTEL_SPAN_LINK_COUNT_LIMIT (Maximum allowed span link count)
894e4a7
to
138cb45
Compare
This adds support for the following env variables: * OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT (Maximum allowed span attribute count) * OTEL_SPAN_EVENT_COUNT_LIMIT (Maximum allowed span event count) * OTEL_SPAN_LINK_COUNT_LIMIT (Maximum allowed span link count)
138cb45
to
fd460de
Compare
fd460de
to
7096de6
Compare
Some of its tests set env vars so they can be retrieved in the Configuration; since some modules initialize it at load-time, it needs to be reset before and after tests
d4ef006
to
ee66977
Compare
I think we're good now @lzchen ! All of this time for... just that, sorry for the time it took :) |
This adds support for the following env variables:
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes #1364
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Unit tests added
Checklist: