Implement axum_extra query rejection tracing #2527
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request aims to implement rejection tracing for
axum_extra::extract::Query
. Currently, the rejection tracing feature works well for other axum extractor types when using the env_filter feature, but it is not implemented foraxum_extra::extract::Query
.The expected behavior is that rejections from axum_extra::extract::Query should be traced to the terminal when using the rejection tracing feature in Axum.
To address this issue, I have thoroughly investigated how rejection tracing is implemented for the
axum::extract::Query
type. I discovered that a macro fromaxum_core
is used for this purpose. However, due to the presence of private fields in some of the generated types, it is not possible to simply import them. As a solution, I have created a newaxum_extra::extract::rejection
submodule and carefully copied the relevant macro calls fromaxum::extract::rejection
.Additionally, I have observed that proper tracing will only occur if the rejection tracing feature is enabled as an optional feature, as indicated by the
#[cfg(feature = "tracing")]
inaxum_core
crate (conditional compilation used):With the changes that have been made, the tracing of rejections from
axum_extra::extract::Query
works now ("query" and "tracing" features should be enabled inaxum_extra
).I have conducted thorough testing by running
cargo test
, and I am pleased to report that all tests have passed successfully.Furthermore, I have noticed that rejection tracing is not implemented for some types within the
axum_extra
library. If you believe that my approach is on the right track, I would be more than happy to extend this implementation to cover all relevant types.Thank you for your consideration.