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 support for go 1.20 #617

Merged
merged 2 commits into from
Apr 10, 2024
Merged

Add support for go 1.20 #617

merged 2 commits into from
Apr 10, 2024

Conversation

ArthurSens
Copy link
Member

Since #590 (released in v0.49.0), common doesn't work for go 1.20 or lower versions since it uses functions that are only available since go 1.21.

Several features that do not require go 1.21 were introduced in common, but cannot be used by downstream projects that are still stuck with go 1.20 for a while, e.g. client_golang that wants to use the new OpenMetrics created timestamps and units.

This PR rescues the old implementation of LabelSet.String() under build tags. When using 1.20, common would still work even without the optimizations made in #590

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
model/labelset_string.go Outdated Show resolved Hide resolved
model/labelset_string.go Outdated Show resolved Hide resolved
@ArthurSens ArthurSens force-pushed the support-go-1.20 branch 2 times, most recently from 0370739 to b758cb8 Compare April 9, 2024 20:40
model/labelset_go120_test.go Outdated Show resolved Hide resolved
model/labelset_go120_test.go Outdated Show resolved Hide resolved
Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

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

Nice work!

@bboreham
Copy link
Member

Not directly relevant to that PR, but we should call out where we do support older Go versions.
I was under the impression Prometheus supported "last two versions" only, same as the Go project itself.

@ArthurSens
Copy link
Member Author

Not directly relevant to that PR, but we should call out where we do support older Go versions. I was under the impression Prometheus supported "last two versions" only, same as the Go project itself.

This PR is focused on enabling client_golang, which promises support for the 3 latest versions. I joined the team after this decision was made, I don't know the reason behind it, to be honest.

Happy to discuss if that makes sense to you @kakkoyun and @bwplotka

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
@kakkoyun
Copy link
Member

Not directly relevant to that PR, but we should call out where we do support older Go versions. I was under the impression Prometheus supported "last two versions" only, same as the Go project itself.

Has this changed recently? I was under the impression that the upstream Go supported the latest three major versions. Thus, client_golang supports the same. We should always follow the same upstream release policy.

This was a rule that was in place before @bwplotka joined the team.

If Go didn't change the release policy after this rule was implemented, there could be another historical reason behind it. @beorn7, I'm curious: Does this ring any bells?

@bboreham
Copy link
Member

client_golang, which promises support for the 3 latest versions

Where is this written down, please?

@kakkoyun
Copy link
Member

client_golang, which promises support for the 3 latest versions

Where is this written down, please?

https://github.com/prometheus/client_golang/blob/e133e490296d2ff915bfc23cdec87c235ad36ef3/README.md?plain=1#L14

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.

Thanks @ArthurSens!

Yea, it's 3 releases for client_golang and it is a bit fair (IMO). If we want to change that, let' perhaps have a dedicated topic on client_golang/DevSummit.

We can also drag the discussion until the next Go release and we would be good (no sarcasm here, this happened a lot and that's ok, just funny =D)

I would merge this to unblock client_golang for now -- until we consider changing policy/new release happens (summer time).

@bwplotka bwplotka merged commit 0234594 into main Apr 10, 2024
8 checks passed
@bwplotka bwplotka deleted the support-go-1.20 branch April 10, 2024 16:03
@beorn7
Copy link
Member

beorn7 commented Apr 10, 2024

I don't think the support promise was ever modeled on promises by any support for older Go version by the Go team. It might have just been a rule of thumb we made up, knowing from experience that many users must use older Go toolchains for one reason or another, even if that isn't a good situation to be in.

But rules can be changed if they don't seem useful anymore.

for name := range l {
labelNames = append(labelNames, string(name))
}
sort.Strings(labelNames)
Copy link
Member

Choose a reason for hiding this comment

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

Note this was:

slices.Sort(labelNames)

Which makes a difference to performance.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch, sorry for the copy paste mistake!

Copy link
Member

Choose a reason for hiding this comment

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

Really? Changing the type of lna from LabelName to string looks quite deliberate to me.

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.

6 participants