Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metrics api #466

Merged
merged 47 commits into from
Oct 31, 2023
Merged

Metrics api #466

merged 47 commits into from
Oct 31, 2023

Conversation

al8n
Copy link
Contributor

@al8n al8n commented Oct 17, 2023

Add metrics-related API for new HTTP service.

@al8n al8n added the enhancement New feature or request label Oct 17, 2023
@al8n al8n added this to the Nomos testnet (playground) milestone Oct 17, 2023
@al8n al8n self-assigned this Oct 17, 2023
@al8n al8n changed the base branch from master to http-api-axum-backend October 17, 2023 09:26
use std::hash::Hash;

#[derive(Clone, Debug, Serialize, Deserialize, Hash, PartialEq, Eq)]
pub struct Tx(pub String);
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we reuse the definitions from nomos-core?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This Tx comes from nomos-node, I copied it from there. I am not sure if we want to use the Tx from nomos-core or do we want to make it generic over the Transaction trait in this service?

Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't go there, I don't like the idea that an http service defines the type of what's inside the mempool (while this was fine in a binary). Either we make it generic or reuse the definitions from nomos-core.

cc @danielSanchezQ

Copy link
Collaborator

Choose a reason for hiding this comment

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

uhm, At some point we used to have a custom Tx on nomos node binary if that is what @al8n refers. But yeah, the http-api should use generic types if possible. Otherwise just the types to be used by the nomos node itself. The second option should be ok imo as this service is completely ad-hoc to be used in the nomos binary. And no way types should be in this module/

@danielSanchezQ
Copy link
Collaborator

This is becoming inevitably tied to the end binary, since it has to use the same services definitions. Should we move it in the nodes folder?

cc @danielSanchezQ

yes, I think it is the case, in the same fashion as the new http-api. I would say we should move it.

Base automatically changed from http-api-axum-backend to master October 20, 2023 06:10
#[cfg_attr(
feature = "openapi",
schema(
example = "e.g. [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we talked about this, but can this be hex instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

handle: &overwatch_rs::overwatch::handle::OverwatchHandle,
items: Vec<<Blob as blob::Blob>::Hash>,
) -> Result<Vec<Status>, super::DynError> {
let relay = handle.relay::<DaMempoolService>().connect().await.unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

We return an error here, let's not unwrap instead maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, ? is better.

+ Debug
+ Hash
+ Serialize
+ for<'de> Deserialize<'de>
Copy link
Collaborator

Choose a reason for hiding this comment

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

DeserializeOwned instead should be ok as well.

let app = Router::new()
.merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", ApiDoc::openapi()))
.route("/da/metrics", routing::get(da_metrics))
.route("/da/status", routing::post(routing::post(da_status)))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.route("/da/status", routing::post(routing::post(da_status)))
.route("/da/status", routing::post(da_status))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks!

@al8n al8n merged commit 9b3c675 into master Oct 31, 2023
7 checks passed
@al8n al8n deleted the metrics-api branch October 31, 2023 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants