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

Cut v1.4.0 #707

Merged
merged 2 commits into from Jan 27, 2020
Merged

Cut v1.4.0 #707

merged 2 commits into from Jan 27, 2020

Conversation

beorn7
Copy link
Member

@beorn7 beorn7 commented Jan 25, 2020

Note that adding a method to the Histogram and Counter interfaces is technically a breaking change. However, I cannot really think about any option that wouldn't be terribly convoluted. (It would be much easier if the constructor returned a concrete type that implements certain interfaces, but this mistake was made long ago.)

I would expect that very few will have implemented their own Histogram and Counter, and if they did, it will be easy to fix. So the impact will (hopefully) be quite limited.

@brian-brazil
Copy link
Contributor

👍

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Nice! LGTM 👍

Well, we could add just a separate interface e.g

type HistogramWithExemplars interface {
        // ObserveWithExemplar works like Observe but also replaces the
	// currently saved exemplar for the relevant bucket (possibly none) with
	// a new one, created from the provided value, the current time as
	// timestamp, and the provided Labels. Empty Labels will lead to a valid
	// (label-less) exemplar. But if Labels is nil, the current exemplar in
	// the relevant bucket is left in place. This method panics if any of
	// the provided labels are invalid or if the provided labels contain
	// more than 64 runes in total.
	ObserveWithExemplar(value float64, exemplar Labels)
}

and then:

  • have constructor that returns Histogram like now, then user can try casting it to HistogramWithExamplar interface,
  • have NewHistogramWithExemplar constructor as well.

This way technically we don't have any compatibility issue, but might be an overengineering. I can see people implementing their own Histogram implementation (eg wrappers), but fixing this incompatibility indeed might be not a huge issue.

The same path is kind of done by http.ResponseWriter when if you want to use custom methods you need to cast to certain interfaces.

Wonder what are you thoughts about separate interface idea @beorn7 (: But I think I am fine with this approach as well.

@beorn7
Copy link
Member Author

beorn7 commented Jan 25, 2020

@bwplotka : Yes, your thoughts are precisely what I considered as a strictly compatible solution, but then I thought it's too clunky, at least if the issue we are avoiding by it is not very relevant. But I'm on the fence about it. Or in other words: I could easily be convince to do it that way, for example if there is a lot of backlash with this release. But perhaps we shouldn't even risk it.

A related point is that the methods of a HistogramVec and a SummaryVec to retrieve a child return an Observer, which is the interface shared by Summary and Histogram. But now the Histogram has an ObserveWithExemplar, but the Summary does not. So the moment a vector is in the game, you have to do the interface upgrade anyway (and that has already occurred in practice at Grafana).

I think I'll create a proposal PR with an ExemplarObserver and an ExemplarAdder interface so that you can all look at it and decide what's the better trade-off.

@bwplotka
Copy link
Member

Perfect thanks 👍 I guess this means we wait with the release then.

Signed-off-by: beorn7 <beorn@grafana.com>
@beorn7
Copy link
Member Author

beorn7 commented Jan 27, 2020

I have rebased with #708 included.

The only CHANGE is now for the metric doc string, which is benign.

Please give final approvement or raise objections.

@@ -4,11 +4,16 @@ require (
github.com/beorn7/perks v1.0.1
github.com/cespare/xxhash/v2 v2.1.1
github.com/golang/protobuf v1.3.2
github.com/json-iterator/go v1.1.8
github.com/google/go-cmp v0.4.0 // indirect
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why about the indirect dependencies. I think they shouldn't be there.

Copy link
Member Author

Choose a reason for hiding this comment

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

They got introduced by the update of dependencies. go mod tidy doesn't remove them.

It seems that's the way it has to be.

Do you know a way I could try to get rid of them?

Signed-off-by: beorn7 <beorn@grafana.com>
@beorn7 beorn7 merged commit 76dd6c5 into master Jan 27, 2020
@beorn7 beorn7 deleted the beorn7/release branch January 27, 2020 18:08
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.

None yet

5 participants