Skip to content
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

Make tracing dependencies optional #374

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

sagebind
Copy link
Owner

@sagebind sagebind commented Feb 15, 2022

Fixes #293.

@sagebind sagebind added this to the 2.0.0 milestone Feb 15, 2022
@codecov
Copy link

codecov bot commented Feb 15, 2022

Codecov Report

Base: 52.47% // Head: 52.49% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (a25239c) compared to base (6917903).
Patch coverage: 48.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #374      +/-   ##
==========================================
+ Coverage   52.47%   52.49%   +0.02%     
==========================================
  Files          53       53              
  Lines        5795     5781      -14     
==========================================
- Hits         3041     3035       -6     
+ Misses       2754     2746       -8     
Impacted Files Coverage Δ
src/agent/selector.rs 75.94% <0.00%> (ø)
src/cookies/interceptor.rs 73.91% <0.00%> (ø)
src/redirect.rs 78.35% <0.00%> (ø)
src/text.rs 81.39% <0.00%> (ø)
src/trailer.rs 58.92% <0.00%> (ø)
src/cookies/psl/mod.rs 95.08% <33.33%> (ø)
src/handler.rs 81.04% <47.61%> (+0.22%) ⬆️
src/client.rs 79.33% <50.00%> (-2.96%) ⬇️
src/agent/mod.rs 77.77% <58.06%> (ø)
src/cookies/jar.rs 83.57% <75.00%> (ø)
... and 6 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

macro_rules! trace {
($($t:tt)+) => {{
#[cfg(feature = "tracing")]
::tracing::trace!($($t)*);
Copy link

@Xuanwo Xuanwo Aug 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since tracing has the tracing_log to convert log entry to tracing event. How about always using log::debug in our code?

This change will also makes other libs / apps to integrate with isahc (because nearly all logging libs supports/compatible to log). And of course, makes our code more understandable.

Copy link
Owner Author

@sagebind sagebind Sep 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the problem with that is that tracing_log can only expose the limited data that the log crate provides for each event into a trace event. If we exclusively use the log crate, then we cannot provide the following information to tracing users:

  • Structured log fields
  • Spans that group log events by the request they are associated with

Both are pretty valuable, and the reason why Isahc switched to tracing in the first place. But the Promised Land of tracing integrating with log in a seamless, backward-compatible way seems to have failed somewhat. If we use log then tracing users won't be happy, and if we use tracing then log users won't be happy.

Honestly if we can't use the structured features of tracing, then we might as well not bother supporting tracing at all.

So the idea here is to throw together an abstraction layer between the two that allows us to continue exposing structured data as well as spans, which fall back to no-ops when using log.

@@ -419,15 +432,18 @@ impl AgentContext {
Ok(())
}

#[tracing::instrument(level = "trace", skip(self))]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can use #[cfg_attr(feature="tracing", tracing::instrument)] instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't enable tracing features by default
2 participants