Skip to content

feat: Update kafka python instrumentation to support kafka-python>=3#4786

Open
rjduffner wants to merge 1 commit into
open-telemetry:mainfrom
rjduffner:rd/kafka-python-updates-1
Open

feat: Update kafka python instrumentation to support kafka-python>=3#4786
rjduffner wants to merge 1 commit into
open-telemetry:mainfrom
rjduffner:rd/kafka-python-updates-1

Conversation

@rjduffner

@rjduffner rjduffner commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Description

While kafka-python version 3.0.0 is actually a pretty large change, https://github.com/dpkp/kafka-python/releases/tag/3.0.0, the breaking changes don't seem to be exercised by the instrumentation.

I updated the instrumentation to include support for versions > 3 but also kept testing older versions as well.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Make sure the current tests pass with the new library versions.

Does This PR Require a Core Repo Change?

  • No.

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

Comment thread .changelog/4786.added Outdated
@@ -0,0 +1,14 @@
kafka-python>=3.0.0,<4.0.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also here, I'd prefer we keep this pinned. You can also look at

to see how we can make this easier to maintain by using uv pip compile.

@github-project-automation github-project-automation Bot moved this to Reviewed PRs that need fixes in Python PR digest Jul 13, 2026
@xrmx

xrmx commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

The rage committing 🤣

@rjduffner

rjduffner commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@xrmx

haha, ya. A mentor when i was very junior always made me commit often. However, since we squashed commits, the messages never had to be good. Well the habit stuck. whoops.

@rjduffner

rjduffner commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@herin049, thanks for the comment. I actually like that earliest latest pattern instead of the 0,1,2 I stole from another instrumentation. I have some questions though and forgive me, I haven't contributed in a while and it was before the switch to uv.

I am trying to figure out how to use uv pip compile to do what you say. I see the flag --resolution

So is your workflow something like this to create the "low" requirements?

uv pip compile --resolution lowest test-requirements.in --output-file test-requirements.txt.oldest

Or am I missing something?

Apologies if i missed something simple.

@herin049

herin049 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@herin049, thanks for the comment. I actually like that earliest latest pattern instead of the 0,1,2 I stole from another instrumentation. I have some questions though and forgive me, I haven't contributed in a while and it was before the switch to uv.

I am trying to figure out how to use uv pip compile to do what you say. I see the flag --resolution

So is your workflow something like this to create the "low" requirements?

uv pip compile --resolution lowest test-requirements.in --output-file test-requirements.txt.oldest

Or am I missing something?

Apologies if i missed something simple.

We typically use lowest-direct for the earliest dependencies and highest for latest.

Quoting from the uv docs:

lowest-direct: Forces the lowest compatible version for your direct dependencies (the ones explicitly listed in your pyproject.toml or requirements.in). It continues to pull the highest compatible version for any transitive (indirect) dependencies.

You can see an example of the exact command used here:

# uv pip compile --python 3.10 --universal --resolution lowest-direct --no-emit-package opentelemetry-api --no-emit-package opentelemetry-semantic-conventions -c dev-requirements.txt instrumentation/opentelemetry-instrumentation-fastapi/test-requirements.in -o instrumentation/opentelemetry-instrumentation-fastapi/test-requirements.oldest.txt

@rjduffner rjduffner force-pushed the rd/kafka-python-updates-1 branch from afe2226 to 430e048 Compare July 15, 2026 14:40
@rjduffner rjduffner force-pushed the rd/kafka-python-updates-1 branch from 430e048 to 9d84b30 Compare July 15, 2026 14:52
@rjduffner

Copy link
Copy Markdown
Contributor Author

@herin049

Yup it was something simple. Totally missed the comment in the generated file. Thank you and sorry about that. Changes made.

@emdneto emdneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not related to this PR, but I think we can drop support for kafka-python-ng now kafka-python development is active again. @rjduffner

@rjduffner

Copy link
Copy Markdown
Contributor Author

@emdneto, I agree. My original PR had the drop of kafka-python-ng in it but I pulled it out as it would technically be a breaking change and I wasn't sure if we wanted to do that. I can follow up with ripping that out in a second pr if desired.

@emdneto

emdneto commented Jul 15, 2026

Copy link
Copy Markdown
Member

@emdneto, I agree. My original PR had the drop of kafka-python-ng in it but I pulled it out as it would technically be a breaking change and I wasn't sure if we wanted to do that. I can follow up with ripping that out in a second pr if desired.

Sure. Created an issue about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

4 participants