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

upgrade opentelemetry-exporter-prometheus-remote-write to use protobuf 5.26 #3219

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

michaelschuett-tomtom
Copy link

Description

This change for my case it to allow us to use this in a project that needs to use protobuf 5.29. I have tested in that project that everything still works as expected so the version limit is only based on the restriction in the produced pypi package not on any code limitation.

I originally was looking at saying the package uses =~5.29 however this conflicts with another random package I had installed streamlit 1.30.0 requires protobuf<5,>=3.20, but you have protobuf 5.29.3 which is incompatible. Which made me think it might be nice to let people use all known working versions of protobuf with this package instead of arbitrarily deciding what one is correct.

Fixes #3179

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

I tested locally by running

$ PACKAGE_NAME=opentelemetry-exporter-prometheus-remote-write VERSION=1.0 ./scripts/build_a_package.sh
$ pip install --force-reinstall ./dist/opentelemetry_exporter_prometheus_remote_write-0.51b0.dev0-py3-none-any.whl

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

I don't think so?

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@michaelschuett-tomtom michaelschuett-tomtom requested a review from a team as a code owner January 29, 2025 19:03
Copy link

linux-foundation-easycla bot commented Jan 29, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Member

@emdneto emdneto left a comment

Choose a reason for hiding this comment

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

Hey: thanks for the PR. I think we should at least add a test using protobuf 5, although tests pass and there is no guarantee for cross-version runtime. What we did in opentelemetry-proto was to support only one major version, protobuf 5.

@aabmass do you think we should wait for the protobuf Q12025 release for this kind of issue?

@aabmass
Copy link
Member

aabmass commented Jan 31, 2025

Which made me think it might be nice to let people use all known working versions of protobuf with this package instead of arbitrarily deciding what one is correct.

It's not arbitrary like @emdneto mentioned, protobuf makes it very clear that this is not officially supported. This PR lets the user decide but I fear people will come here when things break and expect us to fix it. I would prefer to do what @emdneto mentioned and just support protobuf 5. It's been out for almost a year now.

Is there a not a newer streamlit version that works with protobuf 5?

@michaelschuett-tomtom
Copy link
Author

Which made me think it might be nice to let people use all known working versions of protobuf with this package instead of arbitrarily deciding what one is correct.

It's not arbitrary like @emdneto mentioned, protobuf makes it very clear that this is not officially supported. This PR lets the user decide but I fear people will come here when things break and expect us to fix it. I would prefer to do what @emdneto mentioned and just support protobuf 5. It's been out for almost a year now.

Is there a not a newer streamlit version that works with protobuf 5?

I am completely fine with just having 5.x supported. steamlit isn't a specific issue for me but just something I ran into when testing in a few different environments. I'll update this to be only protobuf 5.x.

@michaelschuett-tomtom
Copy link
Author

https://protobuf.dev/support/version-support/#python picked 5.26 based on this page.

@michaelschuett-tomtom
Copy link
Author

michaelschuett-tomtom commented Feb 3, 2025

@emdneto more than happy to write some tests although I am not sure exactly what kind of test to write here to improve coverage. I ran tox -e test-exporter-prometheus-remote-write and it passed outside of one test that looks like it needs a local server spun up HTTPConnectionPool(host='victoria', port=8428).

I do see that we are loading the protobufs in the tests opentelemetry.exporter.prometheus_remote_write.gen.types_pb2 so any breakage at least around imports changing should be caught. However this obviously isn't great coverage but I am not sure if we just want to load in all the protobufs or are looking for more of an integration test to be added where we are actually sending them off to the server.

@aabmass
Copy link
Member

aabmass commented Feb 4, 2025

If we're just doing protobuf 5 I think his comment is resolved. Current tests should be ok

Copy link
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

Actually I think we need to regenerate the protobuf code too?

@michaelschuett-tomtom
Copy link
Author

Actually I think we need to regenerate the protobuf code too?

Just regenerated with protoc 29.3

@emdneto
Copy link
Member

emdneto commented Feb 4, 2025

Actually I think we need to regenerate the protobuf code too?

Right. There's a script in the opentelemetry-exporter-prometheus-remote-write/proto directory called generate-proto-py.sh @michaelschuett-tomtom did you use that script? If so, could you please create a requirement.txt or a note in the README file with the pinned version of grpcio-tools you've installed to run the script? Noticed you already did while I was writing the comment. Thanks

Copy link
Member

@emdneto emdneto left a comment

Choose a reason for hiding this comment

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

LGTM with Changelog entry

@michaelschuett-tomtom
Copy link
Author

LGTM with Changelog entry

Was thinking to add this under Breaking changes in the main CHANGELOG.md since upon update in the case someone has pinned protobuf to a specific version it will cause issues... But this is also true for any dependency update so I'm not 100% sure if this should go under another area.

@michaelschuett-tomtom
Copy link
Author

michaelschuett-tomtom commented Feb 4, 2025

These small PRs always turn out to have the most foot guns 😄 I was just testing some more locally to make sure I don't break anything for people and was running the tests with different versions of presumably supported protobuf versions as defined in the requirements (~=5.26). Because I generated with 29.3 protobuf will blow up with anything that isn't python protobuf version 5.29.3 or later.

Although we could just say this is the min version we should likely be nice to people since they are all still supported. I'll regenerate using v26 of protoc so that we actually support ~=5.26.

Learning on the go here although i have used protobuf before I haven't had to care much about versions since I controled client and server and generate them at the same time.

With the PR as it currently is installing 5.26 python protobuf throws the following.

google.protobuf.runtime_version.VersionError: Detected incompatible Protobuf Gencode/Runtime versions when loading opentelemetry/exporter/prometheus_remote_write/gen/remote.proto: gencode 5.29.3 runtime 5.29.2. Runtime version cannot be older than the linked gencode version. See Protobuf version guarantees at https://protobuf.dev/support/cross-version-runtime-guarantee.

@emdneto
Copy link
Member

emdneto commented Feb 4, 2025

https://protobuf.dev/support/cross-version-runtime-guarantee.

Yeah. In that case, if we want to support starting from 5.26 we must re-generate it with protoc 26. You can also add a second test-requirements.txt file with protobuf 5.29, which should also work. With that we are sure 5.26 and newer runtime versions are covered (which is guaranteed according to this)

@michaelschuett-tomtom
Copy link
Author

michaelschuett-tomtom commented Feb 4, 2025

Done, updated docs and change log and regenerated protos with v26.

@michaelschuett-tomtom michaelschuett-tomtom changed the title More permissive protobuf version for opentelemetry-exporter-prometheus-remote-write upgrade opentelemetry-exporter-prometheus-remote-write to use protobuf 5.26 Feb 4, 2025
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.

Remove protobuf restriction on opentelemetry-exporter-prometheus-remote-write
3 participants