-
Notifications
You must be signed in to change notification settings - Fork 440
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
feat: add max_attributes_per_event and max_attributes_per_link. #521
Conversation
ad9a7e3
to
3bb440b
Compare
Codecov Report
@@ Coverage Diff @@
## main #521 +/- ##
=======================================
+ Coverage 51.1% 52.3% +1.1%
=======================================
Files 95 96 +1
Lines 8395 8503 +108
=======================================
+ Hits 4296 4448 +152
+ Misses 4099 4055 -44
Continue to review full report at Codecov.
|
3bb440b
to
d73a4b5
Compare
Nice to add the additional limit config 👍, I wonder if there may be a better way to enforce at event creation (or if we need to change the event creation api to support limits better) |
I do think we should make members of But in order to enforce the rules. |
@TommyCpp looks like the current config struct was renamed to span limits in open-telemetry/opentelemetry-specification#1416, what do you think about the idea of having spans storing their limits directly to avoid the tracer provider lookup (e.g. the go version) |
We could do that, it increases the size of a span a little but we can avoid upgrading weak pointer in the tracer. But we still need to enforce the limit when adding events or links. |
|
||
/// Span limit configuration to keep attributes, events and links to a span in a reasonable number. | ||
#[derive(Copy, Clone, Debug)] | ||
pub struct SpanLimit { |
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 the spec wants this pluralized
pub struct SpanLimit { | |
pub struct SpanLimits { |
if let Some(link_options) = &mut link_options { | ||
for link in link_options.iter_mut() { |
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.
Do we still need to do this? going through append_vec
below will call push_back
which should already handle the limits configured above
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.
If I understand correctly, the append_vec
only enforces the limit on the number of links. Not the number of attributes of a link
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 sorry I see what's happening nvm
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.
It may make sense to redesign how we create a link to enforce the limit when we creating one 🤔 in the future. Gonna have to use EvictedQueue
to store the attributes too
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.
Yeah can rethink he we store dropped count and others in a follow up PR perhaps
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 current plan is to add fields in SpanLimits
to allow us to store the dropped number in it.
Also need to print the warning message when the dropped number reaches some threshold. Cannot really warn whenever we drop because the spec says don't be too noisy on this issue.
opentelemetry/src/sdk/trace/span.rs
Outdated
@@ -51,11 +53,19 @@ impl Span { | |||
span_context: SpanContext, | |||
data: Option<SpanData>, | |||
tracer: sdk::trace::Tracer, | |||
span_limit: Option<SpanLimits>, |
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.
Does this need to be optional? Could switch tests to use Default::default()
instead of 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.
If the span_limit
is None
. Then we will try to get the span limit from the tracer provider. If there isn't a tracer provider connected with the tracer, we will use the default.
Sometimes we may change the span_limit
during the span building(For example, we may record the number of dropped entities in the future) so we may pass modified span_limit. But we want to keep the span limit the same as the tracer provider, we can pass 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.
Hm yeah we should store them somewhere. Maybe best path is to have SpanLimits
not be optional here and add dropped counts to SpanData
? keeps things simple and tracks attribute drops without having to upgrade the provider.
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.
Sounds reasonable. I removed the option around SpanLimits
. I probably would open another PR to address how to record and expose the number of dropped entities.
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.
Ok good place to start
Added
max_attributes_per_event
andmax_attributes_per_link
.We enforced those rules in tracer or spans rather than having an
EvictedQueue
is because we cannot get the max_attributes when we create links or events. We cannot assume the users are using a tracer created by the global tracer provider as in theory users can have multiple tracer providers.Need to add unit tests