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

Add derived gauges#498

Merged
c24t merged 10 commits intocensus-instrumentation:masterfrom
c24t:derived-gauges
Feb 15, 2019
Merged

Add derived gauges#498
c24t merged 10 commits intocensus-instrumentation:masterfrom
c24t:derived-gauges

Conversation

@c24t
Copy link
Copy Markdown
Member

@c24t c24t commented Feb 12, 2019

This PR follows #494 and adds derived gauge classes DerivedLongGauge, DerivedDoubleGauge, and DerivedGaugePoint similar to the corresponding classes in the java client. It also changes TimeSeries to allow null-valued points to deal with derived gauges tracking functions that have been garbage collected.

c24t added 4 commits February 11, 2019 22:14
Slightly more correct, but shouldn't make a difference in practice since
WeakMethod should only be used in python 2, where this is equivalent to
raise.
@c24t c24t mentioned this pull request Feb 13, 2019
@c24t
Copy link
Copy Markdown
Member Author

c24t commented Feb 14, 2019

@reyang I'd be interested to hear your feedback on this PR too, in particular your thoughts on the Gauge type hierarchy -- whether we should use abstract classes (GaugePoint) as ersatz interfaces, whether it's worth using parent types (BaseGauge) to avoid duplicating code in the children, whether you think we'll be doomed to object-oriented hell for using multiple inheritance (*GaugeMixin), etc.

@c24t c24t requested a review from reyang February 14, 2019 00:06
"""Get a weak reference to bound or unbound `func`.

If `func` is unbound (i.e. has no __self__ attr) get a weakref.ref,
otherwise get a wrapper that simulates simulates weakref.ref.
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.

minor: remove duplicated simulates

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed.

return ts_list


class GaugePoint(object):
Copy link
Copy Markdown
Contributor

@reyang reyang Feb 14, 2019

Choose a reason for hiding this comment

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

We could probably put the __repr__ implementation in the base class.

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.

Probably extract the lock initialization in to GaugePoint.__init__ as well?

class GaugePoint(object):
    def __init__(self):
        self._value_lock = threading.Lock()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I didn't do this because I wanted DerivedGaugePoint to be a GaugePoint too, and this would mean that we couldn't call its parent's constructor (or create an unused lock if we did).

I think there's good reason to have abstract classes like these where all the methods are unimplemented, but you can argue that classes should either be abstract or concrete -- and not like Gauge and BaseGauge that implement some methods and not others. What do you think?

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.

I see, makes sense.

I don't have strong opinion here, both approaches have their valid reasons and I don't see a clear winner. Go with your choice :)

@c24t c24t merged commit 02b2a70 into census-instrumentation:master Feb 15, 2019
@c24t c24t deleted the derived-gauges branch February 15, 2019 20:03
@c24t c24t mentioned this pull request Apr 22, 2019
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