Skip to content

Commit

Permalink
refactor: add tracing to remote DAL calls
Browse files Browse the repository at this point in the history
I needed to move the internal `tracing` module to `trace` to prevent a
clash with the `tracing` library.
  • Loading branch information
chesedo committed Jan 29, 2024
1 parent dd4c000 commit 8989dfa
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion auth/src/main.rs
@@ -1,7 +1,7 @@
use std::io;

use clap::Parser;
use shuttle_common::{backends::tracing::setup_tracing, claims::AccountTier, log::Backend};
use shuttle_common::{backends::trace::setup_tracing, claims::AccountTier, log::Backend};
use sqlx::migrate::Migrator;
use tracing::trace;

Expand Down
2 changes: 1 addition & 1 deletion builder/src/main.rs
Expand Up @@ -5,7 +5,7 @@ use shuttle_builder::{args::Args, Service};
use shuttle_common::{
backends::{
auth::{AuthPublicKey, JwtAuthenticationLayer},
tracing::{setup_tracing, ExtractPropagationLayer},
trace::{setup_tracing, ExtractPropagationLayer},
},
log::Backend,
};
Expand Down
2 changes: 2 additions & 0 deletions common/src/backends/client/gateway.rs
@@ -1,5 +1,6 @@
use headers::Authorization;
use http::{Method, Uri};
use tracing::instrument;

use crate::models;

Expand Down Expand Up @@ -55,6 +56,7 @@ pub trait ProjectsDal {
}

impl ProjectsDal for Client {
#[instrument(skip_all)]
async fn get_user_projects(
&self,
user_token: &str,
Expand Down
2 changes: 2 additions & 0 deletions common/src/backends/client/resource_recorder.rs
@@ -1,4 +1,5 @@
use async_trait::async_trait;
use tracing::instrument;

use crate::{database, resource};

Expand Down Expand Up @@ -41,6 +42,7 @@ impl<T> ResourceDal for &mut T
where
T: ResourceDal,
{
#[instrument(skip_all, fields(shuttle.project_id = project_id))]
async fn get_project_resources(
&mut self,
project_id: &str,
Expand Down
5 changes: 4 additions & 1 deletion common/src/backends/mod.rs
@@ -1,3 +1,5 @@
use tracing::instrument;

use crate::claims::{Claim, Scope};

use self::client::{ProjectsDal, ResourceDal};
Expand All @@ -9,7 +11,7 @@ mod future;
pub mod headers;
pub mod metrics;
mod otlp_tracing_bridge;
pub mod tracing;
pub mod trace;

#[allow(async_fn_in_trait)]
pub trait ClaimExt {
Expand All @@ -34,6 +36,7 @@ impl ClaimExt for Claim {
self.is_admin() || self.limits.project_limit() > current_count
}

#[instrument(skip_all)]
async fn can_provision_rds<G: ProjectsDal, R: ResourceDal>(
&self,
projects_dal: &G,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion deployer/src/main.rs
Expand Up @@ -2,7 +2,7 @@ use std::process::exit;

use clap::Parser;
use shuttle_common::{
backends::tracing::setup_tracing,
backends::trace::setup_tracing,
claims::{ClaimLayer, InjectPropagationLayer},
log::{Backend, DeploymentLogLayer},
};
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/main.rs
Expand Up @@ -2,7 +2,7 @@ use async_posthog::ClientOptions;
use clap::Parser;
use futures::prelude::*;

use shuttle_common::backends::tracing::setup_tracing;
use shuttle_common::backends::trace::setup_tracing;
use shuttle_common::log::Backend;
use shuttle_gateway::acme::{AcmeClient, CustomDomain};
use shuttle_gateway::api::latest::{ApiBuilder, SVC_DEGRADED_THRESHOLD};
Expand Down
2 changes: 1 addition & 1 deletion logger/src/main.rs
Expand Up @@ -4,7 +4,7 @@ use clap::Parser;
use shuttle_common::{
backends::{
auth::{AuthPublicKey, JwtAuthenticationLayer},
tracing::{setup_tracing, ExtractPropagationLayer},
trace::{setup_tracing, ExtractPropagationLayer},
},
log::Backend,
};
Expand Down
2 changes: 1 addition & 1 deletion provisioner/src/main.rs
Expand Up @@ -4,7 +4,7 @@ use clap::Parser;
use shuttle_common::{
backends::{
auth::{AuthPublicKey, JwtAuthenticationLayer},
tracing::{setup_tracing, ExtractPropagationLayer},
trace::{setup_tracing, ExtractPropagationLayer},
},
log::Backend,
};
Expand Down
2 changes: 1 addition & 1 deletion resource-recorder/src/main.rs
Expand Up @@ -4,7 +4,7 @@ use clap::Parser;
use shuttle_common::{
backends::{
auth::{AuthPublicKey, JwtAuthenticationLayer},
tracing::{setup_tracing, ExtractPropagationLayer},
trace::{setup_tracing, ExtractPropagationLayer},
},
log::Backend,
};
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/alpha/mod.rs
Expand Up @@ -14,7 +14,7 @@ use core::future::Future;
use shuttle_common::{
backends::{
auth::{AuthPublicKey, JwtAuthenticationLayer},
tracing::ExtractPropagationLayer,
trace::ExtractPropagationLayer,
},
claims::{Claim, ClaimLayer, InjectPropagationLayer},
resource,
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/bin/shuttle-next.rs
Expand Up @@ -3,7 +3,7 @@ use std::{
time::Duration,
};

use shuttle_common::backends::tracing::ExtractPropagationLayer;
use shuttle_common::backends::trace::ExtractPropagationLayer;
use shuttle_proto::runtime::runtime_server::RuntimeServer;
use shuttle_runtime::__internals::{print_version, AxumWasm, NextArgs};
use tonic::transport::Server;
Expand Down

0 comments on commit 8989dfa

Please sign in to comment.