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

Prometheus metrics #1446

Closed
wants to merge 26 commits into from
Closed

Prometheus metrics #1446

wants to merge 26 commits into from

Conversation

kminehart
Copy link
Contributor

@kminehart kminehart commented May 20, 2019

Related issue

#1176
ory/x#49

Proposed changes

I've changed my approach since the last PR that was made.

This is in-tandem with ory/x#49.

The general idea is to wrap the central types with a Metrics... struct, which can be used interchangeably with whatever it wraps.

A good example is seen with the consent/metrics.go or client/metrics.go file. This nice thing about this approach is that it keeps the metric collection fairly central, though there are a few places where WithMetrics(NewSQLManager) must be used instead of just NewSQLManager(...).

Not all the metrics requested were added in here. I figured since i was changing directions so many times, it would be worth checking out the approach for the current metrics I have now before I proceeded to implement this for the Strategy interface.

Checklist

  • I have read the contributing guidelines
  • I confirm that this pull request does not address a security vulnerability. If this pull request addresses a security
    vulnerability, I confirm that I got green light (please contact hi@ory.sh) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works
    • Tests are definitely doable here but will probably cause a lot of headache. I'll keep looking into this.
  • I have added necessary documentation within the code base (if appropriate)
  • I have documented my changes in the developer guide (if appropriate)

Further comments

See the other discussion comments in ory/x#49 for more implementation details about how metrics are collected.

Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Signed-off-by: Kevin Minehart <kmineh0151@gmail.com>
Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

I love this! This is amazing, so clear and clean. Just some minor things but it's pretty much good to go IMO!

client/metrics.go Outdated Show resolved Hide resolved
client/metrics.go Show resolved Hide resolved
cmd/cli/handler_migrate.go Outdated Show resolved Hide resolved
@ghost
Copy link

ghost commented Jun 4, 2019

I think this should fix current undefined: metricsx.Observer errors on the broken tests:

diff --git a/client/metrics.go b/client/metrics.go
index 9404ac25..a4b2d3db 100644
--- a/client/metrics.go
+++ b/client/metrics.go
@@ -11,7 +11,6 @@ import (

 type Metrics struct {
        prometheus.Collector
-       metricsx.Observer
        Manager

        Clients              prometheus.Gauge
diff --git a/consent/metrics.go b/consent/metrics.go
index 6fd01aee..48fa4eb9 100644
--- a/consent/metrics.go
+++ b/consent/metrics.go
@@ -11,7 +11,6 @@ import (

 type MetricsManager struct {
        Manager
-       metricsx.Observer
        ConsentRequestsHandled  metricsx.CounterVec
        ConsentRequestScopes    metricsx.CounterVec
        ConsentRequestAudiences metricsx.CounterVec
diff --git a/jwk/metrics.go b/jwk/metrics.go
index 123c1262..d8fb9482 100644
--- a/jwk/metrics.go
+++ b/jwk/metrics.go
@@ -10,7 +10,6 @@ import (

 type MetricManager struct {
        Manager
-       metricsx.Observer
        JWKs prometheus.Gauge
 }

@kminehart
Copy link
Contributor Author

kminehart commented Jun 4, 2019

I didn't even look at the tests since they require this PR to be merged in first:

ory/x#49

which adds those undefined types.

@tutman96
Copy link
Contributor

Is there an update to when we can expect this to land in master? More insights into the running instance of Hydra would be very helpful to narrow down some issues.

@aeneasr
Copy link
Member

aeneasr commented Apr 16, 2020

Is there an update to when we can expect this to land in master? More insights into the running instance of Hydra would be very helpful to narrow down some issues.

Unfortunately not right now. We support Jaeger / OpenTracing though which should probably help more than these prometheus stats :) Basic prometheus exporter is also supported in Hydra already.

@tutman96
Copy link
Contributor

I am looking for more per-client metrics (number of token requests vs failed token requests) etc more than pure timings for the different paths. The metrics that are already exposed, while helpful, only show Go stats, and nothing specific to Hydra.

@kminehart kminehart closed this Sep 24, 2020
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.

None yet

3 participants