-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Replace deprecated github.com/golang/protobuf package #427
Conversation
Some format changes in the PR is caused by gopls format, I can leave them untouched if you don't like that. And this PR doesn't replace |
For
This uses |
CircleCI Pipeline — Could not find a usable config.yml, you may have revoked the CircleCI OAuth app. |
It's now fixed. I logged in CircleCI again. Probably I've revoked it before. |
This needs a rebase to pick up go.mod conflicts. |
rebased. |
Sorry, needs a rebase again. 😂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Individual comments are just nitpicking.)
If I remember correctly, the problem is that consumers of this package have to change their import paths in the same way at the same time. Even though the interface doesn't change, a different import path still means we have different types. This could even lead to really tricky situations if someone has multiple dependencies, and some are still using the old version of prometheus/common while others use the new. That's usually caught by changing the import path with new major versions. But prometheus/common is still 0.x. However, prometheus/client_golang is already at 1.x, so there is an expectation to not do breaking changes.
I think the call if we can make this change or not should be made by @kakkoyun and @bwplotka . Given how frequently prometheus/client_golang is used, that's not an easy decision.
expfmt/decode_test.go
Outdated
"github.com/prometheus/common/model" | ||
|
||
dto "github.com/prometheus/client_model/go" | ||
"google.golang.org/protobuf/proto" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: In the Prometheus code base, we tend to keep imports from other repos than the current one in its own block above the imports from the same repo (as it was before). And we usually also have the named imports in a different block (which wasn't adhered to before, but you could fix it now that we are on it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format is fixed.
dto "github.com/prometheus/client_model/go" | ||
"google.golang.org/protobuf/proto" | ||
"google.golang.org/protobuf/types/known/timestamppb" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import nit as before: Have the named imports in their own block after the unnamed imports (as it was before).
dto "github.com/prometheus/client_model/go" | ||
"google.golang.org/protobuf/proto" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could fix the block structure here (it wasn't quite right before, see other nitpicking comments).
expfmt/text_parse.go
Outdated
"github.com/prometheus/common/model" | ||
|
||
dto "github.com/prometheus/client_model/go" | ||
"google.golang.org/protobuf/proto" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same nitpicking as before. This has to be
"google.golang.org/protobuf/proto"
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/model"
And yes, it was wrong in a different way before...
dto "github.com/prometheus/client_model/go" | ||
"google.golang.org/protobuf/proto" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import nitpick as above.
Hmmm, thinking more about it, the only usage of the proto package outside of tests is in text_parse.go line 288, and this particular function just returns a pointer to a (standard) So I would cautiously say now that this PR is OK (modulo import nitpicking ;). Still, would be good to have @kakkoyun / @bwplotka confirm. |
The break already happened when bumping google/protobuf from 1.3 to 1.4, which forces using google.golang.org/protobuf. As you can see the go.mod changes, it only moves google.golang.org/protobuf from indirect to direct. |
This replaces usage of proto.{Float64,Int32,Int64,String,Uint32,Uint64}, which doesn't break the interface. And replaces ptypes.TimestampProto by google.golang.org/protobuf/types/known/timestamppb. This works since github.com/golang/protobuf has been bumped to v1.5.2, which makes ptypes.TimestampProto an alias to timestamppb.Timestamp. This is only used test (openmetrics_create_test.go), which won't break interfaces. Updates: prometheus#317 Signed-off-by: Shengjing Zhu <zhsj@debian.org>
The above is not related to this repo. But for other repos that have pb.go files. This repo as @beorn7 said, "returns a pointer to a (standard) string". And the string format should be its interface. That's why |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #479 |
This replaces usage of proto.{Float64,Int32,Int64,String,Uint32,Uint64}, which doesn't break the interface.
And replaces ptypes.TimestampProto by google.golang.org/protobuf/types/known/timestamppb. This works since github.com/golang/protobuf has been bumped to v1.5.2, which makes ptypes.TimestampProto an alias to timestamppb.Timestamp. This is only used test (openmetrics_create_test.go), which won't break interfaces.
Updates: #317
Signed-off-by: Shengjing Zhu zhsj@debian.org