Skip to content

Commit

Permalink
Merge pull request #242 from ngutech21/feat-tracing-with-jaeger
Browse files Browse the repository at this point in the history
 jaeger support
  • Loading branch information
ngutech21 authored Feb 22, 2024
2 parents 8625fe9 + 34f9401 commit 589318d
Show file tree
Hide file tree
Showing 11 changed files with 265 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ MINT_LND_TLS_CERT_BASE64="base64 encoded tls cert"
#MINT_BTC_ONCHAIN_BACKEND_MAX_AMOUNT=1000000
#MINT_BTC_ONCHAIN_BACKEND_MIN_CONFIRMATIONS=1

# (optional) enable tracing with jaeger
#MINT_TRACING_JAEGER_ENDPOINT="127.0.0.1:6831"

### environment variables for the fedimint-cli
CLI_FEDIMINT_CONNECTION="fed...."
169 changes: 168 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
version: "3"

#docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 -p14268:14268 jaegertracing/all-in-one:latest

services:
database:
image: "postgres:16.2"
Expand All @@ -9,6 +11,18 @@ services:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: moksha-mint
jaeger:
image: jaegertracing/all-in-one:latest
environment:
- COLLECTOR_OTLP_ENABLED=true
ports:
- 16686:16686
- 4317:4317
- 4318:4318
- 14268:14268
- 6831:6831/udp
- 6832:6832/udp
restart: always
app:
image: "docker.io/ngutech21/moksha-mint:latest"
#image: "moksha-mint:latest" # for local testing
Expand Down
11 changes: 8 additions & 3 deletions moksha-mint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ hyper = "0.14.28"
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.108"
tokio = { version = "1.36.0", features = ["full"] }
tower-http = { version = "0.5.0", features = ["trace", "cors", "fs", "set-header"] }
tower-http = { version = "0.5.0", features = ["cors", "fs", "set-header"] }
tower-service = { version = "0.3.2" }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

secp256k1 = { version = "0.28.1", default-features = false, features = ["rand", "serde"] }
thiserror = "1.0.50"
moksha-core = { path = "../moksha-core", version = "0.2.1" }
Expand All @@ -49,6 +48,12 @@ bitcoin_hashes = "0.13.0"
tonic = { version = "0.8", features = ["transport", "tls"] }
serde_yaml = "0.9.31"

tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] }
opentelemetry-jaeger = { version = "0.19.0" }
opentelemetry = { version = "0.20.0", features = ["trace", "rt-tokio"] }
tracing-opentelemetry = "0.20.0"

[dev-dependencies]
tempfile = "3.8.1"
tower = { version = "0.4.13", features = ["util"] }
Expand Down
2 changes: 2 additions & 0 deletions moksha-mint/src/bin/moksha-mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub async fn main() -> anyhow::Result<()> {
database,
btconchain_backend,
lightning_backend,
tracing,
} = MintConfig::read_config_with_defaults();

let mint = MintBuilder::new()
Expand All @@ -37,6 +38,7 @@ pub async fn main() -> anyhow::Result<()> {
.with_lightning(lightning_backend.expect("lightning not set"))
.with_btc_onchain(btconchain_backend)
.with_fee(Some(lightning_fee))
.with_tracing(tracing)
.build()
.await;

Expand Down
13 changes: 13 additions & 0 deletions moksha-mint/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub struct Opts {

#[clap(long, env = "MINT_BTC_ONCHAIN_BACKEND")]
pub btconchain_backend: Option<BtcOnchainTypeVariant>,

#[clap(flatten)]
pub tracing: Option<TracingConfig>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -56,6 +59,12 @@ impl FromStr for LightningTypeVariant {
}
}

#[derive(Debug, Clone, Default, Parser)]
pub struct TracingConfig {
#[clap(long, env = "MINT_TRACING_JAEGER_ENDPOINT")]
pub jaeger_endpoint: Option<String>,
}

#[derive(Debug, Clone, Default)]
pub struct MintConfig {
pub privatekey: String,
Expand All @@ -66,6 +75,7 @@ pub struct MintConfig {
pub database: DatabaseConfig,
pub btconchain_backend: Option<BtcOnchainConfig>,
pub lightning_backend: Option<LightningType>,
pub tracing: Option<TracingConfig>,
}

impl From<(Opts, LightningType, Option<BtcOnchainConfig>)> for MintConfig {
Expand All @@ -79,6 +89,7 @@ impl From<(Opts, LightningType, Option<BtcOnchainConfig>)> for MintConfig {
database: opts.database,
btconchain_backend: btc,
lightning_backend: Some(ln),
tracing: opts.tracing,
}
}
}
Expand Down Expand Up @@ -121,6 +132,7 @@ impl MintConfig {
database: DatabaseConfig,
btconchain_backend: Option<BtcOnchainConfig>,
lightning_backend: Option<LightningType>,
tracing: Option<TracingConfig>,
) -> Self {
Self {
privatekey: private_key,
Expand All @@ -131,6 +143,7 @@ impl MintConfig {
database,
btconchain_backend,
lightning_backend,
tracing,
}
}
}
Expand Down
Loading

0 comments on commit 589318d

Please sign in to comment.