Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

metrics: Obtain request count #13

Merged
merged 8 commits into from
Jul 27, 2020
Merged

metrics: Obtain request count #13

merged 8 commits into from
Jul 27, 2020

Conversation

gvso
Copy link
Contributor

@gvso gvso commented Jul 21, 2020

This adds a function to the Metrics interface and adds an implementation in stackdriver to obtain the number of requests for a given offset.

@gvso gvso requested a review from ahmetb July 22, 2020 18:07
internal/metrics/metrics.go Outdated Show resolved Hide resolved
@ahmetb
Copy link
Contributor

ahmetb commented Jul 22, 2020

cc: @grayside if you have any experience with Stackdriver RPCs, might be good to take a look. otherwise no worries.

gvso and others added 6 commits July 24, 2020 14:50
This adds a function to the Metrics interface and adds an implementation in
stackdriver to obtain the number of requests for a given offset.

Signed-off-by: Getulio Valentin Sánchez <valentin2507@gmail.com>
Signed-off-by: Getulio Valentin Sánchez <valentin2507@gmail.com>
Signed-off-by: Getulio Valentin Sánchez <gvso@google.com>
Signed-off-by: Getulio Valentin Sánchez <gvso@google.com>
Signed-off-by: Getulio Valentin Sánchez <gvso@google.com>
Signed-off-by: Getulio Valentin Sánchez <gvso@google.com>
AggregationGroupByFields("resource.labels.service_name").
AggregationCrossSeriesReducer("REDUCE_SUM")

logger.Debug("querying request count from Cloud Monitoring API")
Copy link
Contributor

Choose a reason for hiding this comment

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

you might find it useful to add values here.
imagine we query latency for a service 3 times.
but you see same log 3 times, you won't show what the each query was for.
but if you add some specifics (e.g. reducer, or aligner), you can have a better time distinguishing them.

Copy link
Contributor Author

@gvso gvso Jul 24, 2020

Choose a reason for hiding this comment

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

Since reducer and aligner are very "abstract" concepts about how Cloud Monitoring works (and are always the same), what about using intervalStartTime and intervalEndTime, which are more useful and change depending on when you call the function?

I'll add percentile in the case of latency, btw. But that will be in some other PR, keeping track at #24

Signed-off-by: Getulio Valentin Sánchez <gvso@google.com>
// aligner and cross series reducer. The result is in milliseconds.
//
// Error rate gets all the server responses. It calculates the error rate by
// performing the operation (5xx responses / all responses).
type Metrics interface {

Choose a reason for hiding this comment

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

From the standpoint of making the metrics in use flexible, I'm surprised to see Metrics as an interface.

I expected to see:

var metrics []Metric
type Metric interface
type RequestCount Metric

Will leave this as a future consideration, on second glance it looks like this was a previous decision :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah imo this should be named MetricsProvider, as it is meant to be an interface for Stackdriver and Prometheus like apis

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I think the naming is what make it confusing. The interface is meant to facilitate the creation of different types of metrics providers (Stackdriver, Prometheus, etc). Might be worth renaming this interface. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like @ahmetb commented at the same time as me. I've created an issue about this #25 . I will rename this interface in a different PR

Signed-off-by: Getulio Valentin Sánchez <gvso@google.com>
@gvso gvso requested a review from ahmetb July 27, 2020 15:10
@ahmetb ahmetb merged commit 041d052 into GoogleCloudPlatform:main Jul 27, 2020
@gvso gvso deleted the request-metrics branch July 27, 2020 19:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants