Skip to content

fix #4278: proxy all methods in ProxiedProducer/Consumer#4358

Open
JMGalvao wants to merge 1 commit intoopen-telemetry:mainfrom
JMGalvao:fix/proxied-delegation-4278
Open

fix #4278: proxy all methods in ProxiedProducer/Consumer#4358
JMGalvao wants to merge 1 commit intoopen-telemetry:mainfrom
JMGalvao:fix/proxied-delegation-4278

Conversation

@JMGalvao
Copy link
Copy Markdown

Description

Fixes #4278

ProxiedProducer and ProxiedConsumer inherited from the confluent-kafka C-extension classes (Producer/Consumer) but never called super().__init__(). Any method not explicitly defined on the proxy class fell through to the base class with an uninitialized C handle, causing RuntimeError: Handle has been closed / Consumer closed.

The fix removes inheritance and uses pure composition with __getattr__ to delegate all undefined method calls to the wrapped instance.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Testing

Added two regression tests:

  • test_proxied_producer_delegates_undefined_methods — calls list_topics() on ProxiedProducer and verifies it delegates to the underlying producer
  • test_proxied_consumer_delegates_undefined_methods — calls assignment() on ProxiedConsumer and verifies it delegates to the underlying consumer

Does This Require a Core Repo Change?

  • No

Checklist

  • Followed the style guidelines of this project
  • Changelogs updated for any user-facing changes
  • Unit tests added covering the changes

@JMGalvao JMGalvao requested a review from a team as a code owner March 25, 2026 21:59
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Mar 25, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: JMGalvao / name: João Galvão (a4419bd)

@tammy-baylis-swi
Copy link
Copy Markdown
Contributor

Thanks for this! Please pull as I did a changelog resolve before triggering workflows.

Please then could you address the lint issues with:

  • tox -e lint-instrumentation-confluent-kafka
  • tox -e precommit

Remove Producer/Consumer inheritance from
ProxiedProducer and ProxiedConsumer. Add
__getattr__ to delegate undefined methods
to the wrapped client, fixing segfaults on
calls like list_topics() or assignment().

Add regression tests to verify delegation
of undefined methods on both proxy classes.
@JMGalvao JMGalvao force-pushed the fix/proxied-delegation-4278 branch from 2baa7b6 to a4419bd Compare March 26, 2026 14:00
@tammy-baylis-swi tammy-baylis-swi moved this to Ready for review in Python PR digest Mar 26, 2026
@tammy-baylis-swi tammy-baylis-swi moved this from Ready for review to Easy to review / merge / close in Python PR digest Mar 26, 2026
Copy link
Copy Markdown
Contributor

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

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

Thanks again! Maintainers will also have a look

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

Labels

None yet

Projects

Status: Easy to review / merge / close

Development

Successfully merging this pull request may close these issues.

[ConfluentKafkaInstrumentor] Not all methods are supported by returned proxy objects

2 participants