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

DNS against local resolvers with ResultSet respojse does not recognise rtt correctly #9

Open
warmfusion opened this issue Nov 4, 2018 · 0 comments
Assignees

Comments

@warmfusion
Copy link

warmfusion commented Nov 4, 2018

While testing the exporter against some of my ongoing DNS test I noticed that the rtt value isn't recognised when the response contains multiple results in a resultset.

According to the ripe documentation;

resultset - [optional] an array of objects containing all the fields of a DNS result object, except for the fields: fw, from, msm_id, prb_id, and type. Available for queries sent to each local resolver.

This was added in version 4750.

Test ID as a reference: 16878571

Here's a lazy workaround that's super ugly, but i can't get the nicer version working (See later).

diff --git a/dns/exporter.go b/dns/exporter.go
index d7819ed..55e7bf5 100644
--- a/dns/exporter.go
+++ b/dns/exporter.go
@@ -41,8 +41,18 @@ func (m *dnsExporter) Export(res *measurement.Result, probe *probe.Probe, ch cha
        var rtt float64
        if res.DnsResult() != nil {
                rtt = res.DnsResult().Rt()
+               recordRtt(rtt, labelValues, ch)
+       } else if res.DnsResultsets() != nil {
+               for _, s := range res.DnsResultsets() {
+                       if s.Result() != nil {
+                               rtt = s.Result().Rt()
+                               recordRtt(rtt, labelValues, ch)
+                       }
+               }
        }
+}

+func recordRtt(rtt float64, labelValues []string, ch chan<- prometheus.Metric) {
        if rtt > 0 {
                ch <- prometheus.MustNewConstMetric(successDesc, prometheus.GaugeValue, 1, labelValues...)
                ch <- prometheus.MustNewConstMetric(rttDesc, prometheus.GaugeValue, rtt, labelValues...)

Non Working Workaround

I'd much prefer to do something like this, but I can't quite get my head around golangs slices/arrays pointers/references etc to make the popping of the first element off the DNSResultSets() array response not cause a segfault.

diff --git a/dns/exporter.go b/dns/exporter.go
index d7819ed..b6706d4 100644
--- a/dns/exporter.go
+++ b/dns/exporter.go
@@ -41,6 +41,8 @@ func (m *dnsExporter) Export(res *measurement.Result, probe *probe.Probe, ch cha
        var rtt float64
        if res.DnsResult() != nil {
                rtt = res.DnsResult().Rt()
+       } else if res.DnsResultsets() != nil {
+               rtt = res.DnsResultsets()[0].Result().Rt()
        }

        if rtt > 0 {
@warmfusion warmfusion changed the title DNS with multiple results in ResultSet do not recognise rtt correctly DNS against local resolvers with ResultSet respojse does not recognise rtt correctly Nov 4, 2018
@czerwonk czerwonk self-assigned this Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants