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

[coordinator] Send metric type only if metric type storing is enabled #3033

Closed
wants to merge 9 commits into from

Conversation

gediminasgu
Copy link
Collaborator

What this PR does / why we need it:
This PR is a minor fix to do not send metric types to aggregator if metric type storing is not enabled.

Special notes for your reviewer:

Does this PR introduce a user-facing and/or backwards incompatible change?:

NONE

Does this PR require updating code package or user-facing documentation?:

NONE

@@ -496,7 +499,7 @@ func (d *downsamplerAndWriter) writeAggregatedBatch(
}

for _, dp := range value.Datapoints {
if value.Attributes.PromType != ts.PromMetricTypeUnknown {
if d.storeMetricType && value.Attributes.PromType != ts.PromMetricTypeUnknown {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: What happens if d.storeMetricType is false and there is no value.Attributes.M3Type - won't that end up in the unknown m3type code path?

Or do we rely on the default value of M3Type being gauge to select gauge? (from the proto M3_GAUGE = 0;)

If we're relying on that behavior perhaps add a comment as such?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will check the logic here. My intention here was just to disable the logic which I have added here: https://github.com/m3db/m3/pull/2941/files#diff-bd39ac14b90a7e77e48b860a55e1927d98fd3378a61676da3b11c8b4a7698958R499

@@ -496,7 +499,7 @@ func (d *downsamplerAndWriter) writeAggregatedBatch(
}

for _, dp := range value.Datapoints {
if value.Attributes.PromType != ts.PromMetricTypeUnknown {
if d.storeMetricType && value.Attributes.PromType != ts.PromMetricTypeUnknown {
switch value.Attributes.PromType {
case ts.PromMetricTypeCounter:
err = result.SamplesAppender.AppendCounterTimedSample(dp.Timestamp, int64(dp.Value))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm I'm a little concerned about sending Prometheus counters to the aggregator with AppendCounterTimedSample since Prometheus counters can actually be in increments that aren't int64 FYI.

i.e. it's totally valid to increment a counter by 0.5 in Prometheus. Notice the API here:
https://godoc.org/github.com/prometheus/client_golang/prometheus#Counter

type Counter interface {
    Metric
    Collector

    // Inc increments the counter by 1. Use Add to increment it by arbitrary
    // non-negative values.
    Inc()
    // Add adds the given value to the counter. It panics if the value is <
    // 0.
    Add(float64)
}

Maybe out of scope of this PR, but we'll have to think about how to pass the metric type to the aggregator without using the AppendCounterTimedSample (and continue to use AppendGaugeTimedSample) I think somehow in the future.

Copy link
Collaborator

@robskillington robskillington left a comment

Choose a reason for hiding this comment

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

LGTM other than adding a comment about relying on default M3Type to be gauge, the other comment about using AppendCounterTimedSample perhaps we should review together at another time

@codecov
Copy link

codecov bot commented Jan 8, 2021

Codecov Report

Merging #3033 (6746e4f) into master (6746e4f) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3033   +/-   ##
=======================================
  Coverage    72.2%    72.2%           
=======================================
  Files        1084     1084           
  Lines      100091   100091           
=======================================
  Hits        72297    72297           
  Misses      22763    22763           
  Partials     5031     5031           
Flag Coverage Δ
aggregator 75.8% <0.0%> (ø)
cluster 84.8% <0.0%> (ø)
collector 84.3% <0.0%> (ø)
dbnode 78.7% <0.0%> (ø)
m3em 74.4% <0.0%> (ø)
m3ninx 73.1% <0.0%> (ø)
metrics 20.0% <0.0%> (ø)
msg 74.2% <0.0%> (ø)
query 67.0% <0.0%> (ø)
x 80.3% <0.0%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6746e4f...ff1505f. Read the comment docs.

@gediminasgu
Copy link
Collaborator Author

Closing this PR in favour of a new PR which takes a different approach: #2941

@gediminasgu gediminasgu deleted the gg/aggregator-metric-type-fix branch January 19, 2021 14:21
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