Skip to content

Commit

Permalink
Add commit method for ConfluentKafkaInstrumentor's ProxiedConsumer
Browse files Browse the repository at this point in the history
  • Loading branch information
mrajashree committed Feb 10, 2023
1 parent df32e8c commit c60948e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#1435](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1435))
- mongo db - fix db statement capturing
([#1512](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1512))
- Add commit method for ConfluentKafkaInstrumentor's ProxiedConsumer
([#1656](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1656))

## Version 1.15.0/0.36b0 (2022-12-10)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ def __init__(self, consumer: Consumer, tracer: Tracer):
def committed(self, partitions, timeout=-1):
return self._consumer.committed(partitions, timeout)

def commit(self, *args, **kwargs):
return self._consumer.commit(*args, **kwargs)

def consume(
self, num_messages=1, *args, **kwargs
): # pylint: disable=keyword-arg-before-vararg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,18 @@ def test_instrument_api(self) -> None:

consumer = instrumentation.uninstrument_consumer(consumer)
self.assertEqual(consumer.__class__, Consumer)

def test_consumer_commit_method_exists(self) -> None:
instrumentation = ConfluentKafkaInstrumentor()

consumer = Consumer(
{
"bootstrap.servers": "localhost:29092",
"group.id": "mygroup",
"auto.offset.reset": "earliest",
}
)

consumer = instrumentation.instrument_consumer(consumer)
self.assertEqual(consumer.__class__, ProxiedConsumer)
self.assertTrue(hasattr(consumer, "commit"))

0 comments on commit c60948e

Please sign in to comment.