Replies: 4 comments 3 replies
-
@open-telemetry/python-approvers @open-telemetry/python-maintainers ^ |
Beta Was this translation helpful? Give feedback.
-
following the zen of Python where it says to keep things as easy and straight as possible from the developer perspective, could potentially prefer |
Beta Was this translation helpful? Give feedback.
-
Other otel implementations implement this with classes/structs but all of them use |
Beta Was this translation helpful? Give feedback.
-
Proposal implemented here: #1877 |
Beta Was this translation helpful? Give feedback.
-
Today we support the following configurable limits via environment variables:
It would be useful if TracerProvider could allow users to set limits through code as well in addition to env vars. I propose we add a new
SpanLimits
class that can be used to set limits with code or load them from env, and update TracerProvider to accept an instance of this new class. TracerProvider already acceptsResource
,Sampler
andIdGenerator
objects today. AddingSpanLimits
would be consistent with the existing interface. Usage would look like:Alternatively, TracerProvider could accept each limit individually instead of passing all limits as a class. Usage would look like:
Both interfaces work equally well but I think having a class has some advantages such as:
self._limits.max_attributes(self)
. SpanLimits could then return different values based on some heuristics.It is easy to imagine many use cases that a class could enable in the future. Today both approaches are somewhat similar but using a class keeps the doors open for more features/changes in the future.
One downside to using a class is that Spans/Resources will probably need an extra attribute lookup for each limit but this can be easily optimized for performance later if required.
I realize the benefits are probably not enormous but they're definitely not negligible.
Happy to hear thoughts on these two approaches or any other ideas.
Update: Other otel implementations implement this with classes/structs but all of them use SpanLimits name instead of Limits for this. I feel Limits is better as we can it on Resource attributes as well and may be use it to configure limits for metrics as well in future but in order to stay consistent with other SDKs, I'm changing the proposal to propose SpanLimits instead. We can add a different API to configure Meter limits in future. We can still use SpanLimits with resource attributes even if the name suggests otherwise or we can completely ignore Resources when it comes to limits as they usually are not susceptible to very large number or size of attributes unlike spans.
References from other SDKs:
Java
Node/JS
Go
Rust
Swift
Rust also allows setting individual limit values in addition to a struct.
Beta Was this translation helpful? Give feedback.
All reactions