Skip to content

Commit

Permalink
Instrument core code paths with tracing spans
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Jan 24, 2022
1 parent d50cfd7 commit f70af7a
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ thiserror = "1.0"
time = { version = "0.3.5", features = ["serde"] }
tokio = { version = "1.1", features = ["fs", "sync"] }
tracing = "0.1.29"
tracing-futures = "0.2.5"
url = "2"
which = "4.2"

Expand Down
1 change: 1 addition & 0 deletions src/authentication_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl AuthenticationManager {
/// if it succeeds, use the default service account as the token source.
/// 4. Look for credentials in `.config/gcloud/application_default_credentials.json`;
/// if found, use these credentials to request refresh tokens.
#[tracing::instrument]
pub async fn new() -> Result<Self, Error> {
tracing::debug!("Initializing gcp_auth");
if let Some(service_account) = CustomServiceAccount::from_env()? {
Expand Down
1 change: 1 addition & 0 deletions src/custom_service_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl ServiceAccount for CustomServiceAccount {
self.tokens.read().unwrap().get(&key).cloned()
}

#[tracing::instrument]
async fn refresh_token(&self, client: &HyperClient, scopes: &[&str]) -> Result<Token, Error> {
use crate::jwt::Claims;
use crate::jwt::GRANT_TYPE;
Expand Down
1 change: 1 addition & 0 deletions src/default_authorized_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl DefaultAuthorizedUser {
.unwrap()
}

#[tracing::instrument]
async fn get_token(client: &HyperClient) -> Result<Token, Error> {
tracing::debug!("Loading user credentials file");
let mut home = dirs_next::home_dir().ok_or(Error::NoHomeDir)?;
Expand Down
1 change: 1 addition & 0 deletions src/default_service_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl DefaultServiceAccount {
.unwrap()
}

#[tracing::instrument]
async fn get_token(client: &HyperClient) -> Result<Token, Error> {
tracing::debug!("Getting token from GCP instance metadata server");
let req = Self::build_token_request(Self::DEFAULT_TOKEN_GCP_URI);
Expand Down

0 comments on commit f70af7a

Please sign in to comment.