-
Notifications
You must be signed in to change notification settings - Fork 15
TracerFlare: save original log level as indication we are currently collecting #1272
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
base: main
Are you sure you want to change the base?
Conversation
5314358 to
88afef4
Compare
BenchmarksComparisonBenchmark execution time: 2025-10-24 14:05:36 Comparing candidate commit d10fff8 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 55 metrics, 2 unstable metrics. CandidateCandidate benchmark detailsGroup 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group 7
Group 8
Group 9
Group 10
Group 11
Group 12
Group 13
Group 14
Group 15
Group 16
Group 17
BaselineOmitted due to size. |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1272 +/- ##
==========================================
+ Coverage 71.82% 71.83% +0.01%
==========================================
Files 368 368
Lines 57967 57957 -10
==========================================
+ Hits 41633 41635 +2
+ Misses 16334 16322 -12
🚀 New features to boost your workflow:
|
49d542a to
512c624
Compare
…ep current log level
512c624 to
6cdb6e4
Compare
0b8b3db to
67e886f
Compare
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.
In the end after thinking about it and writing my comments I don't know anymore if keeping the current_log_level over collecting is that much of a better choice.
datadog-tracer-flare/src/lib.rs
Outdated
| } else if Ok(ReturnAction::None) != action { | ||
| // If action is Send, Unset or an error, we need to stop collecting | ||
| self.collecting.store(false, Ordering::Relaxed); | ||
| *self.current_log_level.lock_or_panic() = 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 you remove the current_log_level is the case of Send, you'll fall into the "Log level is not set" every time the zip_and_send function is called. With collecting only it was not a problem but with the log level you should split this case in two.
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 see what you mean, then maybe just putting getter/setters for the integration would work
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.
Okay I think the best way is indeed to just have both log_levels fields public, and have the collecting bool as before. That way we don't change anything to the ReturnAction we return, and the integrater can manage these to make it work out.
datadog-tracer-flare/src/lib.rs
Outdated
| *tracer_flare.current_log_level.lock_or_panic() = Some(log_level); | ||
| } else if let ReturnAction::Send(_) = state { | ||
| tracer_flare.collecting.store(false, Ordering::Relaxed); | ||
| *tracer_flare.current_log_level.lock_or_panic() = 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.
Same here you should not remove the current_log_level. It should be kept until the Send is done and then you can put it back as 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.
Yup good point that's my bad
datadog-tracer-flare/src/zip.rs
Outdated
| .current_log_level | ||
| .lock_or_panic() | ||
| .ok_or(FlareError::ZipError(String::from( | ||
| "Trying to send the flare when log_level is not set", |
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.
The case when you receive only an AGENT_TASK and thus only have to do a Send action is possible. In that case we still want to send the flare. So we either have the choice to use the tracer actual log_level or we do as Python and Java and putting by default the log_level which is Debug. I think putting Debug would be the best option but it's also more complicated to handle in a design way.
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 don't think it complicates anything. Maybe we can make the field public so that the integrater can set it if it is not set correctly, but it should make things automagic most of the time
…re for the integrater only
60ad4cc to
476b25d
Compare
476b25d to
5ddde0f
Compare
What does this PR do?
Change the collecting boolean field to an Option (inside a Mutex for reasons, but that's beside the point) in the TracerFlareManager. Also adding a
original_log_levelfield that is managed by the integrater code.Motivation
Basically, the integration will have to restore original log level after the Flare is sent, which is impractical because it therefore needs to be saved in a "global" state somewhere. But the TracerFlareManager already has this global scope requirement, thus storing the original log level in it makes sens. The change of the
collectingfield is just about simplifying the API, since now functions likezip_and_sendtake less arguments and stuff.Additional Notes
Anticipating what's going through FFIs once it's implemented could be interesting.
How to test the change?
cargo test(it's still the design phase, it's not integrated anywhere).