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

Add ObserverEffect and Nil* metrics. #17

Merged
merged 2 commits into from
Oct 8, 2013
Merged

Add ObserverEffect and Nil* metrics. #17

merged 2 commits into from
Oct 8, 2013

Conversation

rcrowley
Copy link
Owner

See the comment on ObserverEffect in metrics.go for more.

Note that this changes the signature of New* for all metrics to return the interface type. I remember a discussion on the mailing list long ago that convinced me to change the return value of those functions to a concrete type but I can't recall why and this is a good reason to change it back.

See the comment on ObserverEffect in metrics.go for more.

Note that this changes the signature of New* for all metrics to return the interface type.  I remember a discussion on the mailing list long ago that convinced me to change the return value of those functions to a concrete type but I can't recall why and this is a good reason to change it back.
@mihasya
Copy link
Collaborator

mihasya commented Sep 13, 2013

Would love to see the mailing list discussion that made you go with a regular struct.

This looks good, other than the fact that you're breaking master :trollface: Of course, I encourage this as each time this happens, we move closer to a point where the community starts to converge on a solution for versioning.

@rcrowley
Copy link
Owner Author

@wadey
Copy link
Contributor

wadey commented Sep 13, 2013

I like this and the patch looks good. I'm not sure I like the name ObserverEffect though, seems too complicated and not obvious. Why not something simple like DisableMetrics or UseNilMetrics.

@rcrowley
Copy link
Owner Author

Alright, ETOOCLEVER, I'll change it.

type NilCounter struct{}

// Force the compiler to check that NilCounter implements Counter.
var _ Counter = NilCounter{}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is cool trick, but unnecessary here since NewCounter will enforce the same thing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I actually was gonna say something about ObserverEffect but then I
remembered getFletcherFromDayCare and decided I had no platform whence to
speak.

On Fri, Sep 13, 2013 at 11:51 AM, Wade Simmons notifications@github.comwrote:

In counter.go:

@@ -13,6 +13,32 @@ type Counter interface {
Inc(int64)
}

+// Create a new Counter.
+func NewCounter() Counter {

  • if UseNilMetrics {
  •   return NilCounter{}
    
  • }
  • return &StandardCounter{0}
    +}

+// No-op Counter.
+type NilCounter struct{}
+
+// Force the compiler to check that NilCounter implements Counter.
+var _ Counter = NilCounter{}

This is cool trick, but unnecessary here since NewCounter will enforce the
same thing.


Reply to this email directly or view it on GitHubhttps://github.com//pull/17/files#r6355966
.

@rcrowley rcrowley merged commit b953f7c into master Oct 8, 2013
vincentbernat added a commit to vincentbernat/go-metrics that referenced this pull request Jan 25, 2014
This bug was already fixed by rcrowley#20 (and reported in rcrowley#19) but was rolled
back after merging rcrowley#17.

`uncounted` has been moved to top with a comment explaining that it
should stay at top. This is not mandatory but this is the easiest way to
ensure a good alignment in the future without taking too much care.

This alignment is required to use atomic functions as explained here:
 http://godoc.org/sync/atomic#pkg-note-bug
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.

3 participants