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

feat: include support for metrics #131

Merged
merged 4 commits into from
Feb 16, 2024
Merged

Conversation

acuarica
Copy link
Contributor

@acuarica acuarica commented Feb 7, 2024

Description:

This PR adds another endpoint, /metrics, where you can fetch service metrics to be ingested by Prometheus/Grafana.

Using for instance the NodeJS Application Dashboard you can see NodeJS metrics

image

It also exports requests and events (response) triggered during verification. All requests made to the service (e.g. https://server-verify.hashscan.io/api-docs) will be included, for example

sourcify_http_request_duration_seconds_bucket{le="0.003",status_code="200",method="POST",path="/verify"} 3
sourcify_http_request_duration_seconds_bucket{le="0.03",status_code="200",method="POST",path="/verify"} 4
sourcify_http_request_duration_seconds_bucket{le="0.1",status_code="200",method="POST",path="/verify"} 5
sourcify_http_request_duration_seconds_bucket{le="0.3",status_code="200",method="POST",path="/verify"} 5
sourcify_http_request_duration_seconds_bucket{le="1.5",status_code="200",method="POST",path="/verify"} 6
sourcify_http_request_duration_seconds_bucket{le="10",status_code="200",method="POST",path="/verify"} 6
sourcify_http_request_duration_seconds_bucket{le="+Inf",status_code="200",method="POST",path="/verify"} 6
sourcify_http_request_duration_seconds_sum{status_code="200",method="POST",path="/verify"} 0.632749876
sourcify_http_request_duration_seconds_count{status_code="200",method="POST",path="/verify"} 6

# HELP sourcify_up 1 = up, 0 = not up
# TYPE sourcify_up gauge
sourcify_up 1

# HELP sourcify_event_count events that happened during verification labeled with: event and chainId
# TYPE sourcify_event_count counter
sourcify_event_count{event="Verification.MatchStored",chainId="298"} 2

Note that the sourcify_ prefix is used all metrics to easily differentiate in Grafana.

The events exported are

  "Verification.MatchStored": [],
  "Server.SourcifyChains.Warn": [],
  // [...]
  "SourceFetcher.UsingFallback": [],
  "SourceFetcher.NewSubscription": [],
  "SourceFetcher.Cleanup": [],
  "SourceFetcher.FetchFailed": [],
  "SourceFetcher.FetchingSuccessful": [],

(the ones omitted [...] are Monitor.* related not used at the moment)

Related issue(s):

Fixes #

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@acuarica acuarica linked an issue Feb 7, 2024 that may be closed by this pull request
@acuarica acuarica changed the title 40 add metric support for services feat: include support for metrics Feb 7, 2024
Signed-off-by: Luis Mastrangelo <[email protected]>
@acuarica acuarica marked this pull request as ready for review February 9, 2024 20:14
@acuarica acuarica requested review from a team as code owners February 9, 2024 20:14
@acuarica acuarica requested review from quiet-node, Sheng-Long, svienot and ericleponner and removed request for a team February 9, 2024 20:14
Copy link
Collaborator

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

LG
Just naming suggestion

src/server/server.ts Outdated Show resolved Hide resolved
Copy link

@AlfredoG87 AlfredoG87 left a comment

Choose a reason for hiding this comment

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

LGTM, nice work!

I like that you used the express-prom-bundle and did not had to do things from scratch! 💯

Copy link
Contributor

@svienot svienot left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@acuarica acuarica merged commit 57946ac into main Feb 16, 2024
10 checks passed
@acuarica acuarica deleted the 40-add-metric-support-for-services branch February 16, 2024 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add metric support for services
4 participants