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

PROPOSAL: remove timer.go #11

Closed
bernerdschaefer opened this issue Apr 19, 2013 · 5 comments
Closed

PROPOSAL: remove timer.go #11

bernerdschaefer opened this issue Apr 19, 2013 · 5 comments

Comments

@bernerdschaefer
Copy link
Contributor

To me the following code is simpler, more idiomatic, and gives the same results as the timer API:

func foo() {
    defer func(began time.Time) {
        xyz.IncrementBy(map[string]string{}, time.Since(began))
    }(time.Now())

    // do some work
}

Also, as @matttproud notes the current timer code fails in the presence of a panic, while this does not.

For comparison, see the current registry handler vs. a version using the above pattern.

@matttproud
Copy link
Member

Excellent. Will review shortly.
Am 19.04.2013 11:29 schrieb "Bernerd Schaefer" [email protected]:

To me the following code is simpler, more idiomatic, and gives the same
results as the timer API:

func foo() {
defer func(began time.Time) {
xyz.IncrementBy(map[string]string{}, time.Since(began))
}(time.Now())

// do some work}

Also, as @matttproud https://github.com/matttproud notes the current
timer code fails in the presence of a panic, while this does not.


Reply to this email directly or view it on GitHubhttps://github.com//issues/11
.

@matttproud
Copy link
Member

Sounds reasonable to me. I don't think anyone else is using it, since the API never matured—as you can see from just how rough it is.

For the future:
defer someCounter.IncrementWithDuration(labels, time.Now(), time.Second) defer someHistogram.AddWithDuration(labels, time.Now(), time.Second)

Often times labels may encapsulate the disposition of the operation.

@bernerdschaefer
Copy link
Contributor Author

Great. I'll make a PR. Should I base off master, or the reorganization branch?

Bernerd

On Apr 19, 2013, at 13:13, "Matt T. Proud" [email protected] wrote:

Sounds reasonable to me. I don't think anyone else is using it, since the API never matured—as you can see from just how rough it is.

For the future:

defer someCounter.IncrementWithDuration(labels, time.Now(), time.Second)
defer someHistogram.AddWithDuration(labels, time.Now(), time.Second)

Often times labels may encapsulate the disposition of the operation.


Reply to this email directly or view it on GitHub.

@matttproud
Copy link
Member

I would clone my reorganization branch.

2013/4/19 Bernerd Schaefer [email protected]

Great. I'll make a PR. Should I base off master, or the reorganization
branch?

Bernerd

On Apr 19, 2013, at 13:13, "Matt T. Proud" [email protected]
wrote:

Sounds reasonable to me. I don't think anyone else is using it, since
the API never matured—as you can see from just how rough it is.

For the future:

defer someCounter.IncrementWithDuration(labels, time.Now(), time.Second)
defer someHistogram.AddWithDuration(labels, time.Now(), time.Second)

Often times labels may encapsulate the disposition of the operation.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHubhttps://github.com//issues/11#issuecomment-16648699
.

@bernerdschaefer
Copy link
Contributor Author

This is merged into the refactor branch. Closing.

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

No branches or pull requests

2 participants