Skip to content

Commit

Permalink
Pass in config to client (#13970)
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhan289 authored and fanny-jiang committed Feb 15, 2023
1 parent 9585e2a commit e2caa03
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from datadog_checks.kafka_consumer.client.kafka_python_client import KafkaPythonClient


def make_client(check) -> KafkaClient:
return KafkaPythonClient(check)
def make_client(check, config) -> KafkaClient:
return KafkaPythonClient(check, config)
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def token(self):


class KafkaPythonClient(KafkaClient):
def __init__(self, check) -> None:
def __init__(self, check, config) -> None:
self.check = check
self.config = config
self.log = check.log
self._kafka_client = None
self._highwater_offsets = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from datadog_checks.base import AgentCheck, is_affirmative
from datadog_checks.kafka_consumer.client.kafka_client_factory import make_client

from .config_models import ConfigMixin
from .constants import BROKER_REQUESTS_BATCH_SIZE, CONTEXT_UPPER_BOUND


class KafkaCheck(AgentCheck):
class KafkaCheck(AgentCheck, ConfigMixin):

__NAMESPACE__ = 'kafka'

Expand All @@ -33,7 +34,7 @@ def __init__(self, name, init_config, instances):
)
self._consumer_groups = self.instance.get('consumer_groups', {})
self._broker_requests_batch_size = self.instance.get('broker_requests_batch_size', BROKER_REQUESTS_BATCH_SIZE)
self.client = make_client(self)
self.client = make_client(self, self.config)

def check(self, _):
"""The main entrypoint of the check."""
Expand Down

0 comments on commit e2caa03

Please sign in to comment.