Skip to content

Add /metrics endpoint#99

Open
tankyleo wants to merge 6 commits intolightningdevkit:mainfrom
tankyleo:2026-05-health-check
Open

Add /metrics endpoint#99
tankyleo wants to merge 6 commits intolightningdevkit:mainfrom
tankyleo:2026-05-health-check

Conversation

@tankyleo
Copy link
Copy Markdown
Contributor

@tankyleo tankyleo commented May 6, 2026

Compatible with prometheus

tankyleo added 2 commits May 6, 2026 01:10
We now read `vss.proto` from the local repository instead of dowloading
it from a previous commit on github.

We also update the checked-in `types.rs` file to match the one generated
with the `genproto` flag, and now skip any formatting of this
auto-generated file.
This endpoint allows clients to check the version of the VSS API that
the server is serving.

It also serves as a health check.
@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented May 6, 2026

👋 Thanks for assigning @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@tankyleo tankyleo requested a review from tnull May 6, 2026 01:25
Comment thread rust/api/src/lib.rs Outdated
pub mod kv_store;

/// Contains request/response types generated from the API definition of VSS.
#[rustfmt::skip]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why skip rather than formatting post-generation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So that we don't need to run format post-generation ? Happy to drop if you prefer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, it's always a debate whether to format or not format auto-generated code. I always lean towards yes, others towards no.

In the end it doesn't matter much, so I'd say I'd leave it up to you / your preference. Feel free to leave as-is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See below, I removed the skip and now format this file too.

Comment thread rust/api/build.rs
#[cfg(genproto)]
fn generate_protos() {
download_file(
"https://raw.githubusercontent.com/lightningdevkit/vss-server/7f492fcac0c561b212f49ca40f7d16075822440f/app/src/main/proto/vss.proto",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AFAIU, the original intention here was to pin the protocol version to a specific commit. But you're right that we probably should do that via the new protocol versioning, and proper vss-server tags/releases.

Comment thread rust/api/Cargo.toml

[target.'cfg(genproto)'.build-dependencies]
prost-build = { version = "0.11.3" }
reqwest = { version = "0.11.13", default-features = false, features = ["rustls-tls", "blocking"] }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎉

Comment thread rust/server/src/vss_service.rs Outdated
let prefix_stripped_path = path.strip_prefix(BASE_PATH_PREFIX).unwrap_or_default();

match prefix_stripped_path {
"/version" => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adding this endpoint is great, but shouldn't we also add a (I guess optional, for backwards compat) protocol_version field to all other messages? Otherwise, if we require the client to always manually first call this endpoint and wait on the response a) it's error prone b) it would require another full RTT on startup which is not great. So maybe we make version negotiation implicit and only fail the flow on mismatch? Thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See below, I add a vss-protocol-version header to every response, clients can read the protocol version from any response they get back from the server.

Copy link
Copy Markdown
Contributor

@tnull tnull May 7, 2026

Choose a reason for hiding this comment

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

Cool. Now that we did this, maybe the endpoint could be a more general /health or /status endpoint? Or maybe this shouldn't even be a VSS-style proto response but rather a prometheus-compatible endpoint then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See below, I remove /version, and add /metrics, which offers a prometheus-style gauge for now

@tankyleo tankyleo requested a review from tnull May 6, 2026 16:44
@tankyleo tankyleo changed the title Add /version endpoint Add /metrics endpoint May 7, 2026
@tankyleo tankyleo self-assigned this May 7, 2026
@tankyleo tankyleo moved this to Goal: Merge in Weekly Goals May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Goal: Merge

Development

Successfully merging this pull request may close these issues.

3 participants