-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Refactor metrics/make API use binaries (#2735)
## What ❔ Add metric-emitting middleware for ExternalProofIntegrationAPI Make API return binaries/allow uploading binaries for verification ## Why ❔ For better UX ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`.
- Loading branch information
1 parent
46a75d4
commit 8ed086a
Showing
8 changed files
with
199 additions
and
102 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
core/node/external_proof_integration_api/src/middleware.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use tokio::time::Instant; | ||
|
||
use crate::metrics::{CallOutcome, Method, METRICS}; | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct MetricsMiddleware { | ||
method: Method, | ||
started_at: Instant, | ||
} | ||
|
||
impl MetricsMiddleware { | ||
pub fn new(method: Method) -> MetricsMiddleware { | ||
MetricsMiddleware { | ||
method, | ||
started_at: Instant::now(), | ||
} | ||
} | ||
|
||
pub fn observe(&self, outcome: CallOutcome) { | ||
METRICS.call_latency[&(self.method, outcome)].observe(self.started_at.elapsed()); | ||
} | ||
} |
Oops, something went wrong.