harness / gitness

Gitness is an Open Source developer platform with Source Control management, Continuous Integration and Continuous Delivery.
https://gitness.com
Apache License 2.0
32.09k stars 2.8k forks source link

add http prometheus metrics #3432

Closed maxknee closed 8 months ago

maxknee commented 9 months ago

This will add metrics to http endpoints to measure latency and to see if other parts of infra are working

This will close #2421

CLAassistant commented 9 months ago

CLA assistant check
All committers have signed the CLA.

maxknee commented 9 months ago

@jimsheldon would we be able to get some eyes on this?

maxknee commented 8 months ago

I had a look at this, and based on the documentation for chi-prometheus: You add the middleware. But it looks like you need to add a handle for the endpoint to be active https://github.com/766b/chi-prometheus/blob/master/example/main.go#L23 Am i missing something from the documentation ?

Since there's already a /metrics endpoint, we don't need to add a handler. since chi will use that endpoint already:

running on a locally built version:

# HELP chi_requests_total How many HTTP requests processed, partitioned by status code, method and HTTP path.
# TYPE chi_requests_total counter
chi_requests_total{code="OK",method="GET",path="/",service="server"} 1
chi_requests_total{code="OK",method="GET",path="/",service="web"} 1
chi_requests_total{code="OK",method="GET",path="/api/user",service="api"} 2
chi_requests_total{code="OK",method="GET",path="/api/user",service="server"} 2
chi_requests_total{code="OK",method="GET",path="/api/user/repos",service="api"} 1
chi_requests_total{code="OK",method="GET",path="/api/user/repos",service="server"} 1
chi_requests_total{code="OK",method="GET",path="/favicon.png",service="server"} 1
chi_requests_total{code="OK",method="GET",path="/favicon.png",service="web"} 1
chi_requests_total{code="OK",method="GET",path="/manifest.json",service="server"} 1
chi_requests_total{code="OK",method="GET",path="/manifest.json",service="web"} 1
chi_requests_total{code="OK",method="GET",path="/static/css/2.abad2096.chunk.css",service="server"} 1
chi_requests_total{code="OK",method="GET",path="/static/css/2.abad2096.chunk.css",service="web"} 1
chi_requests_total{code="OK",method="GET",path="/static/css/main.3b0f8240.chunk.css",service="server"} 1
chi_requests_total{code="OK",method="GET",path="/static/css/main.3b0f8240.chunk.css",service="web"} 1
chi_requests_total{code="OK",method="GET",path="/static/js/2.ec852595.chunk.js",service="server"} 1
chi_requests_total{code="OK",method="GET",path="/static/js/2.ec852595.chunk.js",service="web"} 1
chi_requests_total{code="OK",method="GET",path="/static/js/main.316b22ac.chunk.js",service="server"} 1
chi_requests_total{code="OK",method="GET",path="/static/js/main.316b22ac.chunk.js",service="web"} 1
chi_requests_total{code="OK",method="GET",path="/static/media/Inter-Medium.18b8c68e.ttf",service="server"} 1
chi_requests_total{code="OK",method="GET",path="/static/media/Inter-Medium.18b8c68e.ttf",service="web"} 1
chi_requests_total{code="OK",method="GET",path="/static/media/Inter-Regular.9cd7588f.ttf",service="server"} 1
chi_requests_total{code="OK",method="GET",path="/static/media/Inter-Regular.9cd7588f.ttf",service="web"} 1
chi_requests_total{code="OK",method="GET",path="/static/media/logo.76c744d4.svg",service="server"} 1
chi_requests_total{code="OK",method="GET",path="/static/media/logo.76c744d4.svg",service="web"} 1
maxknee commented 8 months ago

The metrics endpoint already declared: https://github.com/harness/gitness/pull/3432/files#diff-18f1f0e1c5973f4caeda8a50df35e925c9a92ffe265e7d77a75da01494188796R68

tphoney commented 8 months ago

thanks @maxknee merged !!

maxknee commented 8 months ago

@tphoney do we have an idea when there will be a new release?

tphoney commented 8 months ago

@tphoney do we have an idea when there will be a new release?

https://hub.docker.com/r/drone/drone/tags

maxknee commented 8 months ago

Oh wow. Awesome!

On Tue, Jan 2, 2024, 10:57 AM TP Honey @.***> wrote:

@tphoney https://github.com/tphoney do we have an idea when there will be a new release?

https://hub.docker.com/r/drone/drone/tags

— Reply to this email directly, view it on GitHub https://github.com/harness/gitness/pull/3432#issuecomment-1874209487, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABVGWAAYNKIF55KYXAOPATYMQU6HAVCNFSM6AAAAABABVIFQCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZUGIYDSNBYG4 . You are receiving this because you were mentioned.Message ID: @.***>

pankdev commented 8 months ago

Hi guys. I've learned about this amazing project, and while reviewing the release notes, I found this particular PR.

From what I can see, your project still uses a very old version of the Chi router, currently at version v5.0.12. This PR introduces a very outdated, abandoned dependency that lacks Go modules support. Moreover, these dependencies are based on an old version of Chi.

I might be misunderstanding this, but don't you think there could be issues with updating Chi because of this outdated dependency?

xoxys commented 7 months ago

@maxknee @tphoney This has flooded our Prometheus server with millions of metrics, causing massive performance issues. While we can drop and filter the chi metrics in Prometheus, enabling this by default without an option to disable it in drone might not be the best way. Would you consider adding an option to disable chi metrics in drone?

maxknee commented 7 months ago

@maxknee @tphoney This has flooded our Prometheus server with millions of metrics, causing massive performance issues. While we can drop and filter the chi metrics in Prometheus, enabling this by default without an option to disable it in drone might not be the best way. Would you consider adding an option to disable chi metrics in drone?

Yes - working on optimizing it

maxknee commented 7 months ago

@xoxys I have this PR up: https://github.com/harness/gitness/pull/3451