def get_dns_records(domain, rdtype, nameserver):
    """Retrieves the DNS records matching the name and type and returns a list of records"""
    records = []
    try:
        dns_resolver = dns.resolver.Resolver()
        dns_resolver.nameservers = [nameserver]
        dns_response = dns_resolver.query(domain, rdtype)
        for rdata in dns_response:
            for record in rdata.strings:
                records.append(record.decode("utf-8"))
    except dns.exception.DNSException:
        capture_exception()
        function = sys._getframe().f_code.co_name
        metrics.send(f"{function}.fail", "counter", 1)
    return records
Retrieves the DNS records matching the name and type and returns a list of records
lemur/dns_providers/util.py