Updated metrics.send to send function named, followed by status, separated by a period
This commit is contained in:
parent
11cd095131
commit
503df999fa
|
@ -96,12 +96,14 @@ def _has_dns_propagated(name, token, domain):
|
||||||
for txt_record in rdata.strings:
|
for txt_record in rdata.strings:
|
||||||
txt_records.append(txt_record.decode("utf-8"))
|
txt_records.append(txt_record.decode("utf-8"))
|
||||||
except dns.exception.DNSException:
|
except dns.exception.DNSException:
|
||||||
metrics.send("has_dns_propagated_fail", "counter", 1)
|
function = sys._getframe().f_code.co_name
|
||||||
|
metrics.send("{}.fail".format(function), "counter", 1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for txt_record in txt_records:
|
for txt_record in txt_records:
|
||||||
if txt_record == token:
|
if txt_record == token:
|
||||||
metrics.send("has_dns_propagated_success", "counter", 1)
|
function = sys._getframe().f_code.co_name
|
||||||
|
metrics.send("{}.success".format(function), "counter", 1)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -132,7 +134,6 @@ def wait_for_dns_change(change_id, account_number=None):
|
||||||
nameserver = get_public_authoritative_nameserver()
|
nameserver = get_public_authoritative_nameserver()
|
||||||
for attempts in range(0, number_of_attempts):
|
for attempts in range(0, number_of_attempts):
|
||||||
status = _has_dns_propagated(fqdn, token, nameserver)
|
status = _has_dns_propagated(fqdn, token, nameserver)
|
||||||
function = sys._getframe().f_code.co_name
|
|
||||||
log_data = {
|
log_data = {
|
||||||
"function": function,
|
"function": function,
|
||||||
"fqdn": fqdn,
|
"fqdn": fqdn,
|
||||||
|
@ -141,18 +142,12 @@ def wait_for_dns_change(change_id, account_number=None):
|
||||||
}
|
}
|
||||||
current_app.logger.debug(log_data)
|
current_app.logger.debug(log_data)
|
||||||
if status:
|
if status:
|
||||||
metrics.send("wait_for_dns_change_success", "counter", 1)
|
metrics.send("{}.success".format(function), "counter", 1)
|
||||||
break
|
break
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
if not status:
|
if not status:
|
||||||
metrics.send("wait_for_dns_change_fail", "counter", 1)
|
metrics.send("{}.fail".format, "counter", 1, metric_tags={"fqdn": fqdn, "txt_record": token})
|
||||||
sentry.captureException(extra={"fqdn": str(fqdn), "txt_record": str(token)})
|
sentry.captureException(extra={"fqdn": str(fqdn), "txt_record": str(token)})
|
||||||
metrics.send(
|
|
||||||
"wait_for_dns_change_error",
|
|
||||||
"counter",
|
|
||||||
1,
|
|
||||||
metric_tags={"fqdn": fqdn, "txt_record": token},
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,7 +178,8 @@ def get_zone_name(domain, account_number):
|
||||||
if z.count(".") > zone_name.count("."):
|
if z.count(".") > zone_name.count("."):
|
||||||
zone_name = z
|
zone_name = z
|
||||||
if not zone_name:
|
if not zone_name:
|
||||||
metrics.send("ultradns_no_zone_name", "counter", 1)
|
function = sys._getframe().f_code.co_name
|
||||||
|
metrics.send("{}.fail".format(function), "counter", 1)
|
||||||
raise Exception("No UltraDNS zone found for domain: {}".format(domain))
|
raise Exception("No UltraDNS zone found for domain: {}".format(domain))
|
||||||
return zone_name
|
return zone_name
|
||||||
|
|
||||||
|
@ -264,7 +260,8 @@ def delete_txt_record(change_id, account_number, domain, token):
|
||||||
rrsets = _get(path)
|
rrsets = _get(path)
|
||||||
record = Record(rrsets)
|
record = Record(rrsets)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
metrics.send("delete_txt_record_geterror", "counter", 1)
|
function = sys._getframe().f_code.co_name
|
||||||
|
metrics.send("{}.geterror".format(function), "counter", 1)
|
||||||
# No Text Records remain or host is not in the zone anymore because all records have been deleted.
|
# No Text Records remain or host is not in the zone anymore because all records have been deleted.
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
@ -341,7 +338,8 @@ def get_authoritative_nameserver(domain):
|
||||||
|
|
||||||
rcode = response.rcode()
|
rcode = response.rcode()
|
||||||
if rcode != dns.rcode.NOERROR:
|
if rcode != dns.rcode.NOERROR:
|
||||||
metrics.send("get_authoritative_nameserver_error", "counter", 1)
|
function = sys._getframe().f_code.co_name
|
||||||
|
metrics.send("{}.error".format(function), "counter", 1)
|
||||||
if rcode == dns.rcode.NXDOMAIN:
|
if rcode == dns.rcode.NXDOMAIN:
|
||||||
raise Exception("%s does not exist." % sub)
|
raise Exception("%s does not exist." % sub)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue