Skip to content

Fix Prometheus in-flight metric handling#1948

Open
asmogo wants to merge 7 commits into
cashubtc:mainfrom
asmogo:feat/prometheus-metrics
Open

Fix Prometheus in-flight metric handling#1948
asmogo wants to merge 7 commits into
cashubtc:mainfrom
asmogo:feat/prometheus-metrics

Conversation

@asmogo
Copy link
Copy Markdown
Collaborator

@asmogo asmogo commented Apr 29, 2026

Description

added a small MintMetricGuard that increments on creation, decrements on drop, and records success/error once.

Bolt11 and Bolt12 quote paths now close in-flight metrics on every normal/error path; Bolt12 uses get_melt_bolt12_quote.

swap metrics are recorded once at the top-level result boundary; removed the saga compensation double-decrement.


Notes to the reviewers


Suggested CHANGELOG Updates

CHANGED

ADDED

REMOVED

FIXED


Checklist

  • I followed the code style guidelines
  • I ran just quick-check before committing
  • If the Wallet API was modified (added/removed/changed), I have reflected those changes in the FFI bindings (crates/cdk-ffi)

@github-project-automation github-project-automation Bot moved this to Backlog in CDK Apr 29, 2026
…etheus-metrics

# Conflicts:
#	crates/cdk/src/mint/melt/mod.rs
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 65.10417% with 201 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.28%. Comparing base (8ce06b1) to head (fb336ce).

Files with missing lines Patch % Lines
crates/cdk/src/mint/melt/mod.rs 57.26% 103 Missing ⚠️
crates/cdk-prometheus/src/server.rs 27.27% 80 Missing ⚠️
crates/cdk-sql-common/src/pool.rs 41.66% 7 Missing ⚠️
crates/cdk-common/src/payment.rs 0.00% 6 Missing ⚠️
crates/cdk-axum/src/metrics.rs 0.00% 2 Missing ⚠️
crates/cdk-prometheus/src/metrics.rs 99.37% 1 Missing ⚠️
crates/cdk/src/mint/melt/melt_saga/mod.rs 66.66% 1 Missing ⚠️
crates/cdk/src/mint/swap/mod.rs 96.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1948      +/-   ##
==========================================
+ Coverage   65.16%   65.28%   +0.11%     
==========================================
  Files         330      330              
  Lines       56742    57153     +411     
==========================================
+ Hits        36976    37311     +335     
- Misses      19766    19842      +76     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

asmogo added 3 commits May 11, 2026 22:53
…rics

# Conflicts:
#	crates/cdk-sql-common/src/mint/quotes.rs
#	crates/cdk-sql-common/src/pool.rs
@asmogo asmogo marked this pull request as ready for review May 12, 2026 08:43
@asmogo
Copy link
Copy Markdown
Collaborator Author

asmogo commented May 12, 2026

i have noticed a configuration issue with prometheus. the toml configuration to enable prometheus won't work. It's currently required to use the env variable CDK_MINTD_PROMETHEUS_ENABLED=true.

fixing this rn.

@asmogo
Copy link
Copy Markdown
Collaborator Author

asmogo commented May 12, 2026

i have noticed a configuration issue with prometheus

The issue is me having mixed toml and env configuration. my toml configuration does not include the postgres url. the parser is silently failing and falling back to env variables. I will address this in another PR that handles the configuration merge.

asmogo added 2 commits May 13, 2026 10:34
- removed global metrics
- rename lightning_payment to payment.
- record lightning payment in make payment function.
Copy link
Copy Markdown
Collaborator Author

@asmogo asmogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • updated tokio listener
  • removed global metrics
  • rename lightning_payment to payment.
  • record lightning payment in make payment function.

We are not recording any fees.

Comment on lines +302 to +308
pub fn payment_method_label(&self) -> &str {
match self {
Self::Bolt11(_) => "bolt11",
Self::Bolt12(_) => "bolt12",
Self::Custom(options) => options.method.as_str(),
}
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this required ?

Comment thread crates/cdk/src/mint/melt/mod.rs
@thesimplekid thesimplekid self-requested a review May 13, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant