-
Notifications
You must be signed in to change notification settings - Fork 269
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(ffi): move tracing setup from the final client to the ffi layer #4492
Conversation
@@ -245,12 +231,65 @@ pub struct TracingFileConfiguration { | |||
max_files: Option<u64>, | |||
} | |||
|
|||
#[derive(PartialEq, PartialOrd)] | |||
enum LogTarget { |
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 EXA has more target than that https://github.com/element-hq/element-x-android/blob/65ce91a8fbe287564bbdaa969ce9b925edacdb6c/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/tracing/TracingFilterConfiguration.kt#L48-L66
Would be nice to have a CustomTarget(rawString)
? that would allow to add a new target wihtout having to compile a custom sdk when developping?
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 EXA has more target than that
Seems so. The missing ones are matrix_sdk_ffi::uniffi_api
, matrix_sdk
and matrix_sdk::send_queue
. Not sure if we should include them or not to be honest ¯_(ツ)_/¯ Perhaps keep matrix_sdk
on info and not add the rest?
Would be nice to have a CustomTarget(rawString)?
Thought about exposing an optional filter
parameter that will just override everything but I figured it's best we keep the api simple as a first step. I'm not sure how often you'll want to debug something with custom tracing on the app side without having a custom sdk version as well, moment in which tweaking the logs becomes easy.
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.
Thought about exposing an optional filter parameter that will just override everything but I figured it's best we keep the api simple as a first step. I'm not sure how often you'll want to debug something with custom tracing on the app side without having a custom sdk version as well, moment in which tweaking the logs becomes easy.
Could the TracingConfiguration
include an extra_logs: Vec<(String, LogLevel)>
, that would be applied as such without any checks? Having some dynamic way to set some logs is definitely a recurring need, and will pay off super quick.
Then we wouldn't need the mandatory app_target
field in there, as it could be part of the extra logs. (And that gives you the possibility to use different spans if you'd like!)
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 yeah, nice idea, let's do it! 💪
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, so I had a play and ended up with passing in only an array of target
s as opposed to (target, level)
as doing the latter would force the final client to duplicate the level adjustment logic done here.
If we pass in only the targets we can keep using the same logic while offering just enough flexibility imho.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4492 +/- ##
==========================================
- Coverage 85.38% 85.36% -0.02%
==========================================
Files 284 284
Lines 31885 31885
==========================================
- Hits 27225 27220 -5
- Misses 4660 4665 +5 ☔ View full report in Codecov by Sentry. |
Having the final clients define the tracing filters / log levels proved to be tricky to keep in check resulting missing logs (e.g. recently introduced modules like the event cache) or unexpected behaviors (e.g. missing panics because we don't set a global filter). As such we decided to move the tracing setup and default definitions over to the rust side and let rust developers have full control over them. We will now take a general log level and the final client's target name and apply them on top of the rust side defined default. Targets that log more than the requested by default will remain unchanged while the others will increase their log levels to match. Certain targets like `hyper` will be ignored in this step as they're too verbose.
dcfc9d0
to
33e277f
Compare
…from the final client to the rust side. - relates to matrix-org/matrix-rust-sdk#4492
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 a bunch for doing this, you rock! My only blocking comment is about extra_logs
, the rest are mostly nits.
@@ -245,12 +231,65 @@ pub struct TracingFileConfiguration { | |||
max_files: Option<u64>, | |||
} | |||
|
|||
#[derive(PartialEq, PartialOrd)] | |||
enum LogTarget { |
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.
Thought about exposing an optional filter parameter that will just override everything but I figured it's best we keep the api simple as a first step. I'm not sure how often you'll want to debug something with custom tracing on the app side without having a custom sdk version as well, moment in which tweaking the logs becomes easy.
Could the TracingConfiguration
include an extra_logs: Vec<(String, LogLevel)>
, that would be applied as such without any checks? Having some dynamic way to set some logs is definitely a recurring need, and will pay off super quick.
Then we wouldn't need the mandatory app_target
field in there, as it could be part of the extra logs. (And that gives you the possibility to use different spans if you'd like!)
LogTarget::MatrixSDKBaseSlidingSync => "matrix_sdk_base::sliding_sync", | ||
LogTarget::MatrixSDKUITimeline => "matrix_sdk_ui::timeline", | ||
LogTarget::MatrixSDKEventCache => "matrix_sdk::event_cache", | ||
LogTarget::MatrixSDKEventCacheStore => "matrix_sdk_sqlite::event_cache_store", |
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.
For the event cache pack, we'd need also LogTarget::MatrixSdkBaseEventCache
. But I can do that as a follow-up, if you'd like :)
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've addedMatrixSdkBaseEventCache
that defaults to Info
like the others and I've also added an matrix_sdk
wide one that also defaults to info but won't drop lower than that.
…from the final client to the rust side. - relates to matrix-org/matrix-rust-sdk#4492
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 that this should have been merged at the same time matrix-org/complement-crypto#159 got merged, now our CI is busted 😢. |
Bah, didn't even cross my mind 😬 |
…from the final client to the rust side. - relates to matrix-org/matrix-rust-sdk#4492
Well complement-crypto was designed with this in mind and it did work out nicely in the past, I don't think we need to change this. |
Okay then perhaps we should not try to match the branches and instead always run complement crypto on |
The matching branches are here so you can develop the complement changes and double check that your changes in the SDK and in complement crypto pass the CI. It's a chicken and egg problem, if we run always against main of complement crypto then we're never able to get the CI green in the PR. Do note, if we merge the complement crypto PR and forget to merge the SDK PR, then we also get a CI failure. Sadly, I don't see any better way of doing this. |
Ah right, didn't think about that. Well I guess we'll just have to do to the best with what we have. |
Having the final clients define the tracing filters / log levels proved to be tricky to keep in check resulting missing logs (e.g. recently introduced modules like the event cache) or unexpected behaviors (e.g. missing panics because we don't set a global filter). As such we decided to move the tracing setup and default definitions over to the rust side and let rust developers have full control over them.
We will now take a general log level and the final client's target name and apply them on top of the rust side defined default. Targets that log more than the requested by default will remain unchanged while the others will increase their log levels to match. Certain targets like
hyper
will be ignored in this step as they're too verbose.