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

Add tracing to requests #307

Merged
merged 2 commits into from
Feb 25, 2023
Merged

Add tracing to requests #307

merged 2 commits into from
Feb 25, 2023

Conversation

goodspark
Copy link
Contributor

@goodspark goodspark commented Feb 24, 2023

Make it a feature so people can opt-in Decided to simplify

src/lib.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated
@@ -48,6 +49,7 @@ wiremock = "0.5.3"
[features]
default = ["native-tls"]
rustls = ["rustls-tls"] # Leagcy support (<=0.17.0)
trace = ["tracing"]
Copy link
Owner

Choose a reason for hiding this comment

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

This shouldn't be needed as by default making tracing optional creates a feature called tracing.

Suggested change
trace = ["tracing"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to just remove the feature and make it part of the library. Would that be OK?

src/lib.rs Outdated
@@ -893,6 +899,38 @@ impl Octocrab {
}
}

#[cfg(feature = "trace")]
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
#[cfg(feature = "trace")]
#[cfg(feature = "tracing")]

src/lib.rs Outdated
Comment on lines 182 to 185
#[cfg(feature = "trace")]
use tracing::{self, field};

#[cfg(feature = "trace")]
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
#[cfg(feature = "trace")]
use tracing::{self, field};
#[cfg(feature = "trace")]
#[cfg(feature = "tracing")]
use tracing::{self, field};
#[cfg(feature = "tracing")]

src/lib.rs Outdated
result
}

#[cfg(not(feature = "trace"))]
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
#[cfg(not(feature = "trace"))]
#[cfg(not(feature = "tracing"))]

Make it a feature so people can opt-in
}
};
result
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to pull things out to a sep async function because span would've moved if I used .instrument(span), which then prevents recording fields after the request.

@goodspark
Copy link
Contributor Author

Also, sorry about the few force pushes. Thought I still had some time to do some last minute tweaks.

@XAMPPRocky
Copy link
Owner

Thank you for your PR!

@XAMPPRocky XAMPPRocky merged commit 15cb998 into XAMPPRocky:master Feb 25, 2023
@goodspark goodspark deleted the tracing branch February 27, 2023 18:49
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.

3 participants