Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Add stats and metrics reprs#479

Merged
c24t merged 2 commits intocensus-instrumentation:masterfrom
c24t:add-stats-reprs-rebase
Feb 5, 2019
Merged

Add stats and metrics reprs#479
c24t merged 2 commits intocensus-instrumentation:masterfrom
c24t:add-stats-reprs-rebase

Conversation

@c24t
Copy link
Copy Markdown
Member

@c24t c24t commented Jan 31, 2019

This PR adds __repr__ methods for a few stats and metrics classes in the style of @reyang's changes in #259.

>>> metric
Metric(descriptor.name="sum by oslang")

>>> metric.descriptor
MetricDescriptor(name="sum by oslang", description="Sum of something by os, lang", unit=kW/s, type=ValueDouble)

>>> metric.time_series[0]
TimeSeries(points=[Point(value=ValueDouble(12.34), timestamp=2019-01-31 11:28:58.553910)], label_values=[LabelValue(android), LabelValue(en_us)], start_timestamp=2019-01-31T19:28:38.383422Z)

>>> metric.time_series[0].points[0]
Point(value=ValueDouble(12.34), timestamp=2019-01-31 11:28:58.553910)

>>> vd.view.aggregation.aggregation_data
SumAggregationDataFloat(0.0)

>>> metric.time_series[0].points[0]
Point(value=ValueDouble(12.34), timestamp=2019-01-31 11:28:58.553910)

Not all reprs include all the attributes of the class, and in general don't allow the user to reconstruct the object by evaling it. I'd prefer for reprs to be short and human-readable, and not an exhaustive description of the object, but this is potentially confusing if the user doesn't realize that not every attribute is reflected in the repr. I'm interested to hear other reviewers' opinions.

This PR doesn't include reprs for all classes, just ones that were helpful while writing #476. If you agree with this style we can add reprs to new objects going forward.

@c24t c24t added the style label Jan 31, 2019
@c24t c24t requested a review from reyang January 31, 2019 20:10
@c24t c24t merged commit e12909e into census-instrumentation:master Feb 5, 2019
@c24t c24t deleted the add-stats-reprs-rebase branch February 5, 2019 19:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants