Skip to content
This repository was archived by the owner on Feb 21, 2026. It is now read-only.

Commit a687b5a

Browse files
committed
See description
- Support observability - Change project structure
1 parent 5f01074 commit a687b5a

10 files changed

Lines changed: 315 additions & 20 deletions

File tree

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ POSTGRES_PASSWORD=postgres
33
POSTGRES_USER=postgres
44
POSTGRES_DB=zero2prod
55
DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}/${POSTGRES_DB}"
6+
7+
RUST_LOG=debug

Cargo.lock

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

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@ reqwest = "0.12.23"
1515

1616
[dependencies]
1717
actix-web = "4"
18+
tracing-actix-web = { version = "0.7", features = ["uuid_v7"] }
1819
tokio = { version = "1", features = ["full"] }
1920
serde = { version = "1", features = ["derive"] }
2021
config = "0.15"
2122
uuid = { version = "1", features = ["v7"] }
23+
tracing = { version = "0.1" }
24+
tracing-subscriber = { version = "0.3", features = ["env-filter", "registry"] }
25+
tracing-bunyan-formatter = "0.3"
26+
tracing-log = "0.2"
27+
once_cell = "1"
28+
secrecy = { version = "0.10", features = ["serde"] }
2229

2330
[dependencies.sqlx]
2431
version = "0.8"

src/config.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use secrecy::{ExposeSecret, SecretString};
2+
13
#[derive(serde::Deserialize)]
24
pub struct Settings {
35
pub service: Service,
@@ -12,7 +14,7 @@ pub struct Service {
1214
#[derive(serde::Deserialize)]
1315
pub struct Database {
1416
pub username: String,
15-
pub password: String,
17+
pub password: SecretString,
1618
pub host: String,
1719
pub port: String,
1820
pub database_name: String,
@@ -27,17 +29,28 @@ pub fn get_config() -> Result<Settings, config::ConfigError> {
2729
}
2830

2931
impl Database {
30-
pub fn conn_str(&self) -> String {
31-
format!(
32-
"postgres://{}:{}@{}:{}/{}",
33-
self.username, self.password, self.host, self.port, self.database_name
32+
pub fn conn_str(&self) -> SecretString {
33+
SecretString::new(
34+
format!(
35+
"postgres://{}:{}@{}:{}/{}",
36+
self.username,
37+
self.password.expose_secret(),
38+
self.host,
39+
self.port,
40+
self.database_name
41+
)
42+
.into(),
3443
)
3544
}
3645

37-
pub fn conn_str_without_db(&self) -> String {
46+
pub fn conn_str_without_db(&self) -> SecretString {
3847
format!(
3948
"postgres://{}:{}@{}:{}",
40-
self.username, self.password, self.host, self.port
49+
self.username,
50+
self.password.expose_secret(),
51+
self.host,
52+
self.port
4153
)
54+
.into()
4255
}
4356
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pub mod config;
22
pub mod routes;
33
pub mod startup;
4+
pub mod telemetry;

0 commit comments

Comments
 (0)