-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add gateway request latency Prometheus metric. #429
Conversation
Another metric per request ampproject#357.
packager/signer/signer.go
Outdated
) | ||
|
||
func (this *Signer) fetchURLAndMeasure(fetch *url.URL, serveHTTPReq *http.Request) (*http.Request, *http.Response, *util.HTTPError) { | ||
now := time.Now() |
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.
you might want to stub out 'now' so it's easier to inject your own now in tests.
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.
Thanks a lot, this is a very cool idea! I didn't do this for top level
requests because latencies are measured by a third-party (Prometheus :),
but it can be done here.
Done.
Thanks a lot, this is a very cool idea! I didn't do this for top level
requests because latencies are measured by a third-party (Prometheus :),
but it can be done here. Will do.
…On Thu, May 28, 2020 at 11:47 AM Allan Banaag ***@***.***> wrote:
***@***.**** approved this pull request.
------------------------------
In packager/signer/signer.go
<#429 (comment)>
:
> +// promGatewayRequestsLatency is a Prometheus summary that observes requests latencies.
+// Objectives key value pairs set target quantiles and respective allowed rank variance.
+// Upon query, for each Objective quantile (0.5, 0.9, 0.99) the summary returns
+// an actual observed latency value that is ranked close to the Objective value.
+// For more intuition on the Objectives see http://alexandrutopliceanu.ro/post/targeted-quantiles/.
+var promGatewayRequestsLatency = promauto.NewSummaryVec(
+ prometheus.SummaryOpts{
+ Name: "gateway_request_latencies_in_seconds",
+ Help: "Latencies (in seconds) of gateway requests to AMP document server - by HTTP response status code.",
+ Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
+ },
+ []string{"code"},
+)
+
+func (this *Signer) fetchURLAndMeasure(fetch *url.URL, serveHTTPReq *http.Request) (*http.Request, *http.Response, *util.HTTPError) {
+ now := time.Now()
you might want to stub out 'now' so it's easier to inject your own now in
tests.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#429 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAD6UM4DHSZH4H3YIOS6BFDRT2WSVANCNFSM4NNKG46Q>
.
--
Mike Rybak | SWE on AMP Conduit team | g <http://go/amphtml-conduit>
o/amphtml-conduit <http://go/amphtml-conduit>
|
packager/signer/signer.go
Outdated
@@ -142,14 +143,14 @@ func noRedirects(req *http.Request, via []*http.Request) error { | |||
|
|||
func New(certHandler certcache.CertHandler, key crypto.PrivateKey, urlSets []util.URLSet, | |||
rtvCache *rtv.RTVCache, shouldPackage func() error, overrideBaseURL *url.URL, | |||
requireHeaders bool, forwardedRequestHeaders []string) (*Signer, error) { | |||
requireHeaders bool, forwardedRequestHeaders []string, timeNowFunc func() time.Time) (*Signer, error) { |
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.
The list of constructor args is getting pretty long. We should (passively) start thinking of ways to split up responsibility of this class. I don't have any ideas; this is just me creating entropy. :P
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.
SG!
packager/signer/signer.go
Outdated
@@ -134,6 +134,7 @@ type Signer struct { | |||
overrideBaseURL *url.URL | |||
requireHeaders bool | |||
forwardedRequestHeaders []string | |||
timeNowFunc func() time.Time |
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.
(opt) Maybe remove "Func" from the name? It's kind of implied, as a non-func Time couldn't be "now".
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.
Done.
Another metric per request #357.