Skip to content

Commit 367d5a3

Browse files
committed
chore(instrumentation): Reduce noise from instrumented functions
1 parent 3604c1e commit 367d5a3

File tree

15 files changed

+80
-51
lines changed

15 files changed

+80
-51
lines changed

rust/stackable-cockpit/src/engine/docker/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub enum Error {
1919
}
2020

2121
/// Checks if Docker is running on the system
22-
#[instrument]
22+
#[instrument(skip_all)]
2323
pub async fn check_if_docker_is_running() -> Result<()> {
2424
debug!("Checking if Docker is running");
2525

rust/stackable-cockpit/src/engine/kind/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Cluster {
6464
}
6565

6666
/// Create a new local cluster by calling the kind binary.
67-
#[instrument]
67+
#[instrument(skip_all)]
6868
pub async fn create(&self) -> Result<()> {
6969
info!("Creating local cluster using kind");
7070

@@ -109,7 +109,7 @@ impl Cluster {
109109
}
110110

111111
/// Creates a kind cluster if it doesn't exist already.
112-
#[instrument]
112+
#[instrument(skip_all)]
113113
pub async fn create_if_not_exists(&self) -> Result<()> {
114114
info!("Creating cluster if it doesn't exist using kind");
115115

@@ -131,7 +131,7 @@ impl Cluster {
131131
}
132132

133133
/// Check if a kind cluster with the provided name already exists.
134-
#[instrument]
134+
#[instrument(skip_all)]
135135
async fn check_if_cluster_exists(cluster_name: &str) -> Result<bool> {
136136
debug!("Checking if kind cluster exists");
137137

rust/stackable-cockpit/src/engine/minikube/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl Cluster {
4141
}
4242

4343
/// Create a new local cluster by calling the Minikube binary
44-
#[instrument]
44+
#[instrument(skip_all)]
4545
pub async fn create(&self) -> Result<(), Error> {
4646
info!("Creating local cluster using Minikube");
4747

@@ -70,7 +70,7 @@ impl Cluster {
7070
}
7171

7272
/// Creates a Minikube cluster if it doesn't exist already.
73-
#[instrument]
73+
#[instrument(skip_all)]
7474
pub async fn create_if_not_exists(&self) -> Result<(), Error> {
7575
info!("Creating cluster if it doesn't exist using Minikube");
7676

@@ -92,7 +92,7 @@ impl Cluster {
9292
}
9393

9494
/// Check if a kind cluster with the provided name already exists.
95-
#[instrument]
95+
#[instrument(skip_all)]
9696
async fn check_if_cluster_exists(cluster_name: &str) -> Result<bool, Error> {
9797
debug!("Checking if Minikube cluster exists");
9898

rust/stackable-cockpit/src/helm.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub struct ChartVersion<'a> {
182182
///
183183
/// This function expects the fully qualified Helm release name. In case of our
184184
/// operators this is: `<PRODUCT_NAME>-operator`.
185-
#[instrument]
185+
#[instrument(skip(values_yaml), fields(with_values = values_yaml.is_some()))]
186186
pub fn install_release_from_repo_or_registry(
187187
release_name: &str,
188188
ChartVersion {
@@ -239,8 +239,8 @@ pub fn install_release_from_repo_or_registry(
239239
let chart_version = chart_version.unwrap_or(HELM_DEFAULT_CHART_VERSION);
240240

241241
debug!(
242-
"Installing Helm release {} ({}) from chart {}",
243-
release_name, chart_version, full_chart_name
242+
release_name,
243+
chart_version, full_chart_name, "Installing Helm release"
244244
);
245245

246246
install_release(
@@ -260,6 +260,7 @@ pub fn install_release_from_repo_or_registry(
260260
///
261261
/// This function expects the fully qualified Helm release name. In case of our
262262
/// operators this is: `<PRODUCT_NAME>-operator`.
263+
#[instrument(fields(with_values = values_yaml.is_some()))]
263264
fn install_release(
264265
release_name: &str,
265266
chart_name: &str,
@@ -388,10 +389,10 @@ pub fn add_repo(repository_name: &str, repository_url: &str) -> Result<(), Error
388389
}
389390

390391
/// Retrieves the Helm index file from the repository URL.
391-
#[instrument]
392+
#[instrument(skip_all, fields(%repo_url))]
392393
pub async fn get_helm_index<T>(repo_url: T) -> Result<ChartSourceMetadata, Error>
393394
where
394-
T: AsRef<str> + std::fmt::Debug,
395+
T: AsRef<str> + std::fmt::Display + std::fmt::Debug,
395396
{
396397
debug!("Get Helm repo index file");
397398

rust/stackable-cockpit/src/platform/demo/spec.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ impl DemoSpec {
134134
Ok(())
135135
}
136136

137+
#[instrument(skip_all, fields(
138+
stack_name = %self.stack,
139+
operator_namespace = %install_parameters.operator_namespace,
140+
product_namespace = %install_parameters.product_namespace,
141+
))]
137142
pub async fn install(
138143
&self,
139144
stack_list: StackList,
@@ -177,7 +182,11 @@ impl DemoSpec {
177182
.await
178183
}
179184

180-
#[instrument(skip_all)]
185+
#[instrument(skip_all, fields(
186+
stack_name = %self.stack,
187+
operator_namespace = %install_params.operator_namespace,
188+
product_namespace = %install_params.product_namespace,
189+
))]
181190
async fn prepare_manifests(
182191
&self,
183192
install_params: DemoInstallParameters,

rust/stackable-cockpit/src/platform/manifests.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub enum Error {
6262

6363
pub trait InstallManifestsExt {
6464
// TODO (Techassi): This step shouldn't care about templating the manifests nor fetching them from remote
65-
#[instrument(skip_all)]
65+
#[instrument(skip_all, fields(%product_namespace))]
6666
#[allow(async_fn_in_trait)]
6767
async fn install_manifests(
6868
manifests: &[ManifestSpec],
@@ -72,12 +72,12 @@ pub trait InstallManifestsExt {
7272
client: &Client,
7373
transfer_client: &xfer::Client,
7474
) -> Result<(), Error> {
75-
debug!("Installing demo / stack manifests");
75+
debug!("Installing manifests");
7676

7777
for manifest in manifests {
7878
match manifest {
7979
ManifestSpec::HelmChart(helm_file) => {
80-
debug!("Installing manifest from Helm chart {}", helm_file);
80+
debug!(helm_file, "Installing manifest from Helm chart");
8181

8282
// Read Helm chart YAML and apply templating
8383
let helm_file = helm_file.into_path_or_url().context(ParsePathOrUrlSnafu {
@@ -89,10 +89,7 @@ pub trait InstallManifestsExt {
8989
.await
9090
.context(FileTransferSnafu)?;
9191

92-
info!(
93-
"Installing Helm chart {} ({})",
94-
helm_chart.name, helm_chart.version
95-
);
92+
info!(helm_chart.name, helm_chart.version, "Installing Helm chart",);
9693

9794
// Assumption: that all manifest helm charts refer to repos not registries
9895
helm::add_repo(&helm_chart.repo.name, &helm_chart.repo.url).context(
@@ -122,7 +119,7 @@ pub trait InstallManifestsExt {
122119
})?;
123120
}
124121
ManifestSpec::PlainYaml(manifest_file) => {
125-
debug!("Installing YAML manifest from {}", manifest_file);
122+
debug!(manifest_file, "Installing YAML manifest");
126123

127124
// Read YAML manifest and apply templating
128125
let path_or_url =

rust/stackable-cockpit/src/platform/operator/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,14 @@ impl OperatorSpec {
178178
}
179179

180180
/// Installs the operator using Helm.
181-
#[instrument(skip_all)]
181+
#[instrument(skip_all, fields(
182+
%namespace,
183+
name = %self.name,
184+
// NOTE (@NickLarsenNZ): Option doesn't impl Display, so we need to call
185+
// display for the inner type if it exists. Otherwise we gte the Debug
186+
// impl for the whole Option.
187+
version = self.version.as_ref().map(|v| tracing::field::display(v)),
188+
))]
182189
pub fn install(
183190
&self,
184191
namespace: &str,
@@ -213,10 +220,10 @@ impl OperatorSpec {
213220
}
214221

215222
/// Uninstalls the operator using Helm.
216-
#[instrument]
223+
#[instrument(skip_all, fields(%namespace))]
217224
pub fn uninstall<T>(&self, namespace: T) -> Result<(), helm::Error>
218225
where
219-
T: AsRef<str> + std::fmt::Debug,
226+
T: AsRef<str> + std::fmt::Display + std::fmt::Debug,
220227
{
221228
match helm::uninstall_release(&self.helm_name(), namespace.as_ref(), true) {
222229
Ok(status) => {

rust/stackable-cockpit/src/platform/release/spec.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use indexmap::IndexMap;
33
use serde::{Deserialize, Serialize};
44
use snafu::{ResultExt, Snafu};
55
use tokio::task::JoinError;
6-
use tracing::{info, instrument};
6+
use tracing::{info, instrument, Instrument, Span};
77

88
#[cfg(feature = "openapi")]
99
use utoipa::ToSchema;
@@ -50,7 +50,7 @@ pub struct ReleaseSpec {
5050

5151
impl ReleaseSpec {
5252
/// Installs a release by installing individual operators.
53-
#[instrument(skip_all)]
53+
#[instrument(skip_all, fields(%namespace, product.included = tracing::field::Empty, product.excluded = tracing::field::Empty))]
5454
pub async fn install(
5555
&self,
5656
include_products: &[String],
@@ -60,6 +60,13 @@ impl ReleaseSpec {
6060
) -> Result<()> {
6161
info!("Installing release");
6262

63+
include_products.iter().for_each(|product| {
64+
Span::current().record("product.included", product);
65+
});
66+
exclude_products.iter().for_each(|product| {
67+
Span::current().record("product.excluded", product);
68+
});
69+
6370
let namespace = namespace.to_string();
6471
futures::stream::iter(self.filter_products(include_products, exclude_products))
6572
.map(|(product_name, product)| {

rust/stackable-cockpit/src/platform/stack/spec.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,13 @@ impl StackSpec {
151151
}
152152

153153
// TODO (Techassi): Can we get rid of the release list and just use the release spec instead
154-
#[instrument(skip(self, release_list, client, transfer_client))]
154+
#[instrument(skip_all, fields(
155+
stack_name = %install_parameters.stack_name,
156+
// NOTE (@NickLarsenNZ): Option doesn't impl Display, so we need to call
157+
// display for the inner type if it exists. Otherwise we gte the Debug
158+
// impl for the whole Option.
159+
demo_name = install_parameters.demo_name.as_ref().map(|v| tracing::field::display(v)),
160+
))]
155161
pub async fn install(
156162
&self,
157163
release_list: release::ReleaseList,
@@ -192,12 +198,12 @@ impl StackSpec {
192198
.await
193199
}
194200

195-
#[instrument(skip(self, release_list))]
201+
#[instrument(skip_all, fields(release = %self.release, %operator_namespace))]
196202
pub async fn install_release(
197203
&self,
198204
release_list: release::ReleaseList,
199205
operator_namespace: &str,
200-
product_namespace: &str,
206+
_product_namespace: &str, // TODO (@NickLarsenNZ): remove this field
201207
chart_source: &ChartSourceType,
202208
) -> Result<(), Error> {
203209
info!("Trying to install release {}", self.release);

rust/stackable-cockpit/src/utils/check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub fn binary_present<T: AsRef<OsStr>>(name: T) -> bool {
99
}
1010

1111
/// Returns if ALL binaries in the list are present in the $PATH.
12-
#[instrument]
12+
#[instrument(skip_all)]
1313
pub fn binaries_present(names: &[&str]) -> bool {
1414
debug!("Checking if required binaries are present on the system");
1515

@@ -24,7 +24,7 @@ pub fn binaries_present(names: &[&str]) -> bool {
2424

2525
/// Returns [`None`] if all binaries in the list are present in the $PATH and
2626
/// if not, returns [`Some`] containing the name of the missing binary.
27-
#[instrument]
27+
#[instrument(skip_all)]
2828
pub fn binaries_present_with_name(names: &[&str]) -> Option<String> {
2929
debug!("Checking if required binaries are present on the system");
3030

0 commit comments

Comments
 (0)