Skip to content

Commit

Permalink
Collect version metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek committed Oct 6, 2020
1 parent 109ab42 commit 50565f2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions kafka_consumer/datadog_checks/kafka_consumer/kafka_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def check(self, instance):
self._report_highwater_offsets(self._context_limit)
self._report_consumer_offsets_and_lag(self._context_limit - len(self._highwater_offsets))

self._collect_broker_metadata()

def _create_kafka_admin_client(self, api_version):
"""Return a KafkaAdminClient."""
kafka_connect_str = self.instance.get('kafka_connect_str')
Expand Down Expand Up @@ -458,6 +460,15 @@ def _send_event(self, title, text, tags, event_type, aggregation_key, severity='
}
self.event(event_dict)

@AgentCheck.metadata_entrypoint
def _collect_broker_metadata(self):
version_data = [str(part) for part in self._kafka_client._client.check_version()]
version_parts = {name: part for name, part in zip(('major', 'minor', 'patch'), version_data)}

self.set_metadata(
'version', '.'.join(version_data), scheme='parts', final_scheme='semver', part_map=version_parts
)

@classmethod
def _determine_kafka_version(cls, init_config, instance):
"""Return the Kafka cluster version as a tuple."""
Expand Down

0 comments on commit 50565f2

Please sign in to comment.