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

refactor Prometheus metrics. Less metrics, more labels #384

Merged
merged 2 commits into from
Mar 14, 2018
Merged

refactor Prometheus metrics. Less metrics, more labels #384

merged 2 commits into from
Mar 14, 2018

Conversation

mthenw
Copy link
Contributor

@mthenw mthenw commented Mar 13, 2018

No description provided.

@mthenw mthenw requested a review from alexdebrie March 13, 2018 09:50
@@ -7,20 +7,10 @@ import (
func init() {
prometheus.MustRegister(metricFunctionRegistered)
prometheus.MustRegister(metricFunctionDeleted)
Copy link
Contributor

Choose a reason for hiding this comment

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

@mthenw Would it be better to have a single metricFunctions that is just a gauge of registered functions for a Space?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense!

prometheus.MustRegister(metricFunctionDeleteRequests)
prometheus.MustRegister(metricFunctionUpdateRequests)
prometheus.MustRegister(metricFunctionListRequests)

prometheus.MustRegister(metricSubscriptionCreated)
prometheus.MustRegister(metricSubscriptionDeleted)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question as above, but with metricSubscriptions

@@ -62,7 +62,7 @@ func (h HTTPAPI) getFunction(w http.ResponseWriter, r *http.Request, params http
encoder.Encode(fn)
}

metricFunctionGetRequests.WithLabelValues(space).Inc()
metricConfigRequests.WithLabelValues(space, "function", "get").Inc()
}

func (h HTTPAPI) getFunctions(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nit, but is it worth making these handler names line up with the labels put in the metrics? listFunctions, createFunction, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True story.

@@ -59,7 +59,7 @@ func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// isHTTPEvent checks if a request carries HTTP event. It also accepts pre-flight CORS requests because CORS is
// resolved downstream.
if isHTTPEvent(r) {
metricEventsHTTPReceived.Inc()
metricEventsReceived.WithLabelValues("", "http").Inc()

event, _, err := router.eventFromRequest(r)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be easier to put metricEventsProcessed.WithLabelValues(space, "http").Inc() after line 72 below, rather than in the handleHTTPEvent method? Follows the pattern of how the invoke event is done, plus it keeps it together a little better.

Wouldn't let me comment on line 72 directly since it wasn't in the diff.

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, that would make sense but I don't want to return space from handleHTTPEvent. There is some refactoring needed here. Metrics reporting could also be moved to inside those handle* functions but again there will be exception for HTTP event. Let's leave it as it is right now as there is no ideal solution.

@mthenw mthenw merged commit cd92090 into master Mar 14, 2018
@mthenw mthenw deleted the prom branch March 14, 2018 08:58
@mthenw mthenw mentioned this pull request Mar 27, 2018
3 tasks
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.

2 participants