-
Notifications
You must be signed in to change notification settings - Fork 194
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
Revamp metrics to account the status code #320
Changes from 3 commits
cb5dc45
3bd7b47
8ed0afd
383a199
cf30c87
28677a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ func NewMetrics(httpPort string, logger common.Logger) *Metrics { | |
Name: "requests_total", | ||
Help: "the number of blob requests", | ||
}, | ||
[]string{"status", "quorum", "method"}, | ||
[]string{"status_code", "status", "quorum", "method"}, | ||
), | ||
BlobSize: promauto.With(reg).NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
|
@@ -82,9 +82,10 @@ func (g *Metrics) ObserveLatency(method string, latencyMs float64) { | |
// IncrementSuccessfulBlobRequestNum increments the number of successful blob requests | ||
func (g *Metrics) IncrementSuccessfulBlobRequestNum(quorum string, method string) { | ||
g.NumBlobRequests.With(prometheus.Labels{ | ||
"status": "success", | ||
"quorum": quorum, | ||
"method": method, | ||
"status_code": "200", | ||
"status": "success", | ||
"quorum": quorum, | ||
"method": method, | ||
}).Inc() | ||
} | ||
|
||
|
@@ -99,17 +100,18 @@ func (g *Metrics) HandleSuccessfulRequest(quorum string, blobBytes int, method s | |
} | ||
|
||
// IncrementFailedBlobRequestNum increments the number of failed blob requests | ||
func (g *Metrics) IncrementFailedBlobRequestNum(quorum string, method string) { | ||
func (g *Metrics) IncrementFailedBlobRequestNum(statusCode string, quorum string, method string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should have these http status codes typed somewhere and use that type instead of taking raw string. Something like
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The HTTP code is already quite standard (probably it's the standard) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is. My point isn't whether it's the standard or not. It's that we shouldn't take raw string in this method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same reason why quorum isn't a uint8 which you don't even need a library. |
||
g.NumBlobRequests.With(prometheus.Labels{ | ||
"status": "failed", | ||
"quorum": quorum, | ||
"method": method, | ||
"status_code": statusCode, | ||
"status": "failed", | ||
"quorum": quorum, | ||
"method": method, | ||
}).Inc() | ||
} | ||
|
||
// HandleFailedRequest updates the number of failed requests and the size of the blob | ||
func (g *Metrics) HandleFailedRequest(quorum string, blobBytes int, method string) { | ||
g.IncrementFailedBlobRequestNum(quorum, method) | ||
func (g *Metrics) HandleFailedRequest(statusCode string, quorum string, blobBytes int, method string) { | ||
g.IncrementFailedBlobRequestNum(statusCode, quorum, method) | ||
g.BlobSize.With(prometheus.Labels{ | ||
"status": "failed", | ||
"quorum": quorum, | ||
|
@@ -120,9 +122,10 @@ func (g *Metrics) HandleFailedRequest(quorum string, blobBytes int, method strin | |
// HandleBlobStoreFailedRequest updates the number of requests failed to store blob and the size of the blob | ||
func (g *Metrics) HandleBlobStoreFailedRequest(quorum string, blobBytes int, method string) { | ||
g.NumBlobRequests.With(prometheus.Labels{ | ||
"status": StoreBlobFailure, | ||
"quorum": quorum, | ||
"method": method, | ||
"status_code": "500", | ||
"status": StoreBlobFailure, | ||
"quorum": quorum, | ||
"method": method, | ||
}).Inc() | ||
g.BlobSize.With(prometheus.Labels{ | ||
"status": StoreBlobFailure, | ||
|
@@ -134,9 +137,10 @@ func (g *Metrics) HandleBlobStoreFailedRequest(quorum string, blobBytes int, met | |
// HandleSystemRateLimitedRequest updates the number of system rate limited requests and the size of the blob | ||
func (g *Metrics) HandleSystemRateLimitedRequest(quorum string, blobBytes int, method string) { | ||
g.NumBlobRequests.With(prometheus.Labels{ | ||
"status": SystemRateLimitedFailure, | ||
"quorum": quorum, | ||
"method": method, | ||
"status_code": "429", | ||
"status": SystemRateLimitedFailure, | ||
"quorum": quorum, | ||
"method": method, | ||
}).Inc() | ||
g.BlobSize.With(prometheus.Labels{ | ||
"status": SystemRateLimitedFailure, | ||
|
@@ -148,9 +152,10 @@ func (g *Metrics) HandleSystemRateLimitedRequest(quorum string, blobBytes int, m | |
// HandleAccountRateLimitedRequest updates the number of account rate limited requests and the size of the blob | ||
func (g *Metrics) HandleAccountRateLimitedRequest(quorum string, blobBytes int, method string) { | ||
g.NumBlobRequests.With(prometheus.Labels{ | ||
"status": AccountRateLimitedFailure, | ||
"quorum": quorum, | ||
"method": method, | ||
"status_code": "429", | ||
"status": AccountRateLimitedFailure, | ||
"quorum": quorum, | ||
"method": method, | ||
}).Inc() | ||
g.BlobSize.With(prometheus.Labels{ | ||
"status": AccountRateLimitedFailure, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was wrong accounting: the
checkRateLimitsAndAddRates
will error out and return upon the first error (e.g. first quorum), but this accounting increments metrics for each quorum