Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

stats worker as metric producer.#1078

Merged
rghetia merged 4 commits intocensus-instrumentation:masterfrom
rghetia:view_as_metric_producer
Mar 27, 2019
Merged

stats worker as metric producer.#1078
rghetia merged 4 commits intocensus-instrumentation:masterfrom
rghetia:view_as_metric_producer

Conversation

@rghetia
Copy link
Copy Markdown
Contributor

@rghetia rghetia commented Mar 22, 2019

This change provides stats data (view data model) as metric data. Stats worker registers as a metric producer with global producer manager. Read() function is then invoked by Readers.

@rghetia rghetia requested review from a team and rakyll as code owners March 22, 2019 20:34

func rowToTimeseries(row *Row, now time.Time, startTime time.Time) *metricdata.TimeSeries {
return &metricdata.TimeSeries{
Points: []metricdata.Point{row.Data.toPoint(now)},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You need to convert metric types here. For example SumData is always converted to Float64 point: https://github.com/census-instrumentation/opencensus-go/pull/1078/files#diff-a282032fe900298505848fd4d08399a2R96. But when measure is of type Int64Measure, metric type will be CumulativeInt64: https://github.com/census-instrumentation/opencensus-go/pull/1078/files#diff-0ac84b9d221fc10ebe99482beb04a4fbR45. This will be an error since the type of point doesn't match with metric type.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed.
comparing serialized version made the test pass incorrectly. Removed the serialized comparision.

… type.

fixed test. Specifically removed json comparision.
@rghetia
Copy link
Copy Markdown
Contributor Author

rghetia commented Mar 25, 2019

@songy23 PTAL.

case metricdata.TypeCumulativeInt64:
return metricdata.NewInt64Point(t, a.Value)
case metricdata.TypeCumulativeFloat64:
return metricdata.NewFloat64Point(t, float64(a.Value))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Count should always be Int64.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed.

case "By":
return metricdata.UnitBytes
}
return metricdata.UnitDimensionless
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why convert all other units to "1"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll open a new PR to fix this.

@rghetia
Copy link
Copy Markdown
Contributor Author

rghetia commented Mar 26, 2019

@songy23 PTAL

Copy link
Copy Markdown
Contributor

@songy23 songy23 left a comment

Choose a reason for hiding this comment

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

LGTM overall

}

func (a *DistributionData) toPoint(metricType metricdata.Type, t time.Time) metricdata.Point {
buckets := []metricdata.Bucket{}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: you can also check metricType here (expect to be cumulative distribution).


gotMetric := viewToMetric(tc.vi, now, startTime)
if !reflect.DeepEqual(gotMetric, tc.wantMetric) {
// JSON format is strictly for checking the content when test fails. Do not use JSON
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also replaced reflect.DeepEqual with cmp.Equal
@rghetia rghetia merged commit ec71c97 into census-instrumentation:master Mar 27, 2019
songy23 pushed a commit that referenced this pull request Apr 3, 2019
* stats worker as metric producer.

* fixed the conversion based on measure type in addition to aggregation type.
fixed test. Specifically removed json comparision.

* fixed review comments related to count float64.

* add check for metricType in toPoint func for distribution
Also replaced reflect.DeepEqual with cmp.Equal

(cherry picked from commit ec71c97)
@rghetia rghetia deleted the view_as_metric_producer branch April 15, 2019 20:43
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.

2 participants