Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize logging format #4896

Merged
merged 1 commit into from
Oct 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions activemq_xml/datadog_checks/activemq_xml/activemq_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def check(self, instance):

tags = custom_tags + ["url:{0}".format(url)]

self.log.debug("Processing ActiveMQ data for %s" % url)
self.log.debug("Processing ActiveMQ data for %s", url)
data = self._fetch_data(url, QUEUE_URL, suppress_errors)
if data:
self._process_data(data, "queue", tags, max_queues, detailed_queues)
Expand All @@ -54,7 +54,7 @@ def check(self, instance):

def _fetch_data(self, base_url, xml_url, suppress_errors):
url = "%s%s" % (base_url, xml_url)
self.log.debug("ActiveMQ Fetching queue data from: %s" % url)
self.log.debug("ActiveMQ Fetching queue data from: %s", url)
try:
r = self.http.get(url)
r.raise_for_status()
Expand All @@ -78,9 +78,14 @@ def _process_data(self, data, el_type, tags, max_elements, detailed_elements):
if count > max_elements:
if not detailed_elements:
self.warning(
"Number of {0} is too high ({1} > {2}). "
"Please use the detailed_{0}s parameter"
" to list the {0} you want to monitor.".format(el_type, count, max_elements)
"Number of %s is too high (%s > %s). "
"Please use the detailed_%ss parameter"
" to list the %s you want to monitor.",
el_type,
count,
max_elements,
el_type,
el_type,
)

for el in elements[:max_elements]:
Expand All @@ -95,7 +100,7 @@ def _process_data(self, data, el_type, tags, max_elements, detailed_elements):
value = stats.get(attr_name, 0)
self.gauge(metric_name, value, tags=el_tags)

self.log.debug("ActiveMQ {0} count: {1}".format(el_type, count))
self.log.debug("ActiveMQ %s count: %s", el_type, count)
self.gauge("activemq.{0}.count".format(el_type), count, tags=tags)

def _process_subscriber_data(self, data, tags, max_subscribers, detailed_subscribers):
Expand All @@ -110,9 +115,12 @@ def _process_subscriber_data(self, data, tags, max_subscribers, detailed_subscri
if count > max_subscribers:
if not detailed_subscribers:
self.warning(
"Number of subscribers is too high ({0} > {1})."
"Number of subscribers is too high (%s > %s)."
"Please use the detailed_subscribers parameter "
"to list the {0} you want to monitor.".format(count, max_subscribers)
"to list the %s you want to monitor.",
count,
max_subscribers,
count,
)

for subscriber in subscribers[:max_subscribers]:
Expand All @@ -138,21 +146,19 @@ def _process_subscriber_data(self, data, tags, max_subscribers, detailed_subscri
dispatched_counter = stats.get("dispatchedCounter", 0)

self.log.debug(
"ActiveMQ Subscriber %s: %s %s %s %s %s"
% (
clientId,
pending_queue_size,
dequeue_counter,
enqueue_counter,
dispatched_queue_size,
dispatched_counter,
)
"ActiveMQ Subscriber %s: %s %s %s %s %s",
clientId,
pending_queue_size,
dequeue_counter,
enqueue_counter,
dispatched_queue_size,
dispatched_counter,
)
self.gauge("activemq.subscriber.pending_queue_size", pending_queue_size, tags=el_tags)
self.gauge("activemq.subscriber.dequeue_counter", dequeue_counter, tags=el_tags)
self.gauge("activemq.subscriber.enqueue_counter", enqueue_counter, tags=el_tags)
self.gauge("activemq.subscriber.dispatched_queue_size", dispatched_queue_size, tags=el_tags)
self.gauge("activemq.subscriber.dispatched_counter", dispatched_counter, tags=el_tags)

self.log.debug("ActiveMQ Subscriber Count: {0}".format(count))
self.log.debug("ActiveMQ Subscriber Count: %s", count)
self.gauge("activemq.subscriber.count", count, tags=tags)