-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create environments for the new kafka client
- Loading branch information
1 parent
e35d80b
commit 8174e9e
Showing
11 changed files
with
193 additions
and
41 deletions.
There are no files selected for viewing
32 changes: 27 additions & 5 deletions
32
kafka_consumer/datadog_checks/kafka_consumer/client/confluent_kafka_client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,36 @@ | ||
# (C) Datadog, Inc. 2023-present | ||
# All rights reserved | ||
# Licensed under a 3-clause BSD style license (see LICENSE) | ||
from datadog_checks.kafka_consumer.client.kafka_client import KafkaClient | ||
|
||
|
||
class ConfluentKafkaClient: | ||
def __init__(self) -> None: | ||
pass | ||
class ConfluentKafkaClient(KafkaClient): | ||
def create_kafka_admin_client(self): | ||
raise NotImplementedError | ||
|
||
def get_consumer_offsets_dict(self): | ||
raise NotImplementedError | ||
|
||
def get_highwater_offsets(self): | ||
raise NotImplementedError | ||
|
||
def get_highwater_offsets_dict(self): | ||
raise NotImplementedError | ||
|
||
def reset_offsets(self): | ||
raise NotImplementedError | ||
|
||
def get_partitions_for_topic(self, topic): | ||
raise NotImplementedError | ||
|
||
def request_metadata_update(self): | ||
raise NotImplementedError | ||
|
||
def collect_broker_version(self): | ||
raise NotImplementedError | ||
|
||
def get_consumer_offsets(self): | ||
pass | ||
raise NotImplementedError | ||
|
||
def get_broker_offset(self): | ||
pass | ||
raise NotImplementedError |
80 changes: 80 additions & 0 deletions
80
kafka_consumer/datadog_checks/kafka_consumer/client/generic_kafka_client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# (C) Datadog, Inc. 2023-present | ||
# All rights reserved | ||
# Licensed under a 3-clause BSD style license (see LICENSE) | ||
|
||
from datadog_checks.kafka_consumer.client.confluent_kafka_client import ConfluentKafkaClient | ||
from datadog_checks.kafka_consumer.client.kafka_client import KafkaClient | ||
from datadog_checks.kafka_consumer.client.kafka_python_client import KafkaPythonClient | ||
|
||
|
||
class GenericKafkaClient(KafkaClient): | ||
def __init__(self, config, tls_context, log) -> None: | ||
super().__init__(config, tls_context, log) | ||
self.use_legacy_client = config.use_legacy_client | ||
self.confluent_kafka_client = ConfluentKafkaClient(config, tls_context, log) if not self.use_legacy_client else None | ||
self.python_kafka_client = KafkaPythonClient(config, tls_context, log) | ||
|
||
def get_consumer_offsets(self): | ||
# TODO when this method is implemented in ConfluentKafkaClient, replace this with: | ||
# if self.use_legacy_client: | ||
# return self.python_kafka_client.get_consumer_offsets() | ||
# return self.confluent_kafka_client.get_consumer_offsets() | ||
|
||
return self.python_kafka_client.get_consumer_offsets() | ||
|
||
def get_highwater_offsets(self): | ||
# TODO when this method is implemented in ConfluentKafkaClient, replace this with: | ||
# if self.use_legacy_client: | ||
# return self.python_kafka_client.get_highwater_offsets() | ||
# return self.confluent_kafka_client.get_highwater_offsets() | ||
return self.python_kafka_client.get_highwater_offsets() | ||
|
||
def get_highwater_offsets_dict(self): | ||
# TODO when this method is implemented in ConfluentKafkaClient, replace this with: | ||
# if self.use_legacy_client: | ||
# return self.python_kafka_client.get_highwater_offsets_dict() | ||
# return self.confluent_kafka_client.get_highwater_offsets_dict() | ||
return self.python_kafka_client.get_highwater_offsets_dict() | ||
|
||
def reset_offsets(self): | ||
# TODO when this method is implemented in ConfluentKafkaClient, replace this with: | ||
# if self.use_legacy_client: | ||
# return self.python_kafka_client.reset_offsets() | ||
# return self.confluent_kafka_client.reset_offsets() | ||
return self.python_kafka_client.reset_offsets() | ||
|
||
def get_partitions_for_topic(self, topic): | ||
# TODO when this method is implemented in ConfluentKafkaClient, replace this with: | ||
# if self.use_legacy_client: | ||
# return self.python_kafka_client.get_partitions_for_topic(topic) | ||
# return self.confluent_kafka_client.get_partitions_for_topic(topic) | ||
return self.python_kafka_client.get_partitions_for_topic(topic) | ||
|
||
def request_metadata_update(self): | ||
# TODO when this method is implemented in ConfluentKafkaClient, replace this with: | ||
# if self.use_legacy_client: | ||
# return self.python_kafka_client.request_metadata_update() | ||
# return self.confluent_kafka_client.request_metadata_update() | ||
return self.python_kafka_client.request_metadata_update() | ||
|
||
def collect_broker_version(self): | ||
# TODO when this method is implemented in ConfluentKafkaClient, replace this with: | ||
# if self.use_legacy_client: | ||
# return self.python_kafka_client.collect_broker_version() | ||
# return self.confluent_kafka_client.collect_broker_version() | ||
return self.python_kafka_client.collect_broker_version() | ||
|
||
def get_consumer_offsets_dict(self): | ||
# TODO when this method is implemented in ConfluentKafkaClient, replace this with: | ||
# if self.use_legacy_client: | ||
# return self.python_kafka_client.get_consumer_offsets_dict() | ||
# return self.confluent_kafka_client.get_consumer_offsets_dict() | ||
return self.python_kafka_client.get_consumer_offsets_dict() | ||
|
||
def create_kafka_admin_client(self): | ||
# TODO when this method is implemented in ConfluentKafkaClient, replace this with: | ||
# if self.use_legacy_client: | ||
# return self.python_kafka_client.get_consumer_offsets() | ||
# return self.confluent_kafka_client.get_consumer_offsets() | ||
|
||
return self.python_kafka_client.create_kafka_admin_client() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
kafka_consumer/datadog_checks/kafka_consumer/client/kafka_client_factory.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# TODO Remove this script once the library is installed at the agent level | ||
|
||
apt-get update | ||
apt-get install -y --no-install-recommends gcc git libssl-dev g++ make build-essential libsasl2-modules-gssapi-mit krb5-user | ||
cd /tmp && git clone https://github.com/edenhill/librdkafka.git | ||
cd librdkafka && git checkout tags/v2.0.2 | ||
./configure && make && make install && ldconfig | ||
cd ../ && rm -rf librdkafka | ||
pip install --no-binary confluent-kafka confluent-kafka |