Skip to content

Commit 68dc711

Browse files
committed
feat(variables): Trace variables host component
Signed-off-by: Caleb Schoepp <[email protected]>
1 parent b5c497d commit 68dc711

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/variables/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ thiserror = "1"
1717
tokio = { version = "1", features = ["rt-multi-thread"] }
1818
vaultrs = "0.6.2"
1919
serde = "1.0.188"
20+
tracing = { workspace = true }
2021

2122
[dev-dependencies]
2223
toml = "0.5"
24+
25+
[lints]
26+
workspace = true

crates/variables/src/provider/env.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use anyhow::{Context, Result};
44
use async_trait::async_trait;
55

66
use spin_expressions::{Key, Provider};
7+
use tracing::{instrument, Level};
78

89
const DEFAULT_ENV_PREFIX: &str = "SPIN_VARIABLE";
910
const LEGACY_ENV_PREFIX: &str = "SPIN_CONFIG";
@@ -84,6 +85,7 @@ impl EnvProvider {
8485

8586
#[async_trait]
8687
impl Provider for EnvProvider {
88+
#[instrument(name = "spin_variables.get_from_env", skip(self), err(level = Level::INFO))]
8789
async fn get(&self, key: &Key) -> Result<Option<String>> {
8890
tokio::task::block_in_place(|| self.get_sync(key))
8991
}

crates/variables/src/provider/vault.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use anyhow::{Context, Result};
22
use async_trait::async_trait;
33
use serde::{Deserialize, Serialize};
4+
use tracing::{instrument, Level};
45
use vaultrs::{
56
client::{VaultClient, VaultClientSettingsBuilder},
67
error::ClientError,
@@ -41,6 +42,7 @@ struct Secret {
4142

4243
#[async_trait]
4344
impl Provider for VaultProvider {
45+
#[instrument(name = "spin_variables.get_from_vault", skip(self), err(level = Level::INFO), fields(otel.kind = "client"))]
4446
async fn get(&self, key: &Key) -> Result<Option<String>> {
4547
let client = VaultClient::new(
4648
VaultClientSettingsBuilder::default()

0 commit comments

Comments
 (0)