• Miek Gieben's avatar
    Metrics: expand coredns_dns_responses_total with plugin label (#4914) · 6953ab2b
    Miek Gieben authored
    * Metrics: expand coredns_dns_responses_total with plugin label
    
    This adds (somewhat hacky?) code to add a plugin label to the
    coredns_dns_responses_total metric. It's completely obvlious to the
    plugin as we just check who called the *recorder.WriteMsg method. We use
    runtime.Caller( 1 2 3) to get multiple levels of callers, this should be
    deep enough, but it depends on the dns.ResponseWriter wrapping that's
    occuring.
    
    README.md of metrics updates and test added in test/metrics_test.go to
    check for the label being set.
    
    I went through the plugin to see what metrics could be removed, but
    actually didn't find any, the plugin push out metrics that make sense.
    
    Due to the path fiddling to figure out the plugin name I doubt this
    works (out-of-the-box) for external plugins, but I haven't tested that.
    Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
    
    * better comment
    Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
    
    * Metrics: expand coredns_dns_responses_total with plugin label
    
    This adds (somewhat hacky?) code to add a plugin label to the
    coredns_dns_responses_total metric. It's completely obvlious to the
    plugin as we just check who called the *recorder.WriteMsg method. We use
    runtime.Caller( 1 2 3) to get multiple levels of callers, this should be
    deep enough, but it depends on the dns.ResponseWriter wrapping that's
    occuring.
    
    README.md of metrics updates and test added in test/metrics_test.go to
    check for the label being set.
    
    I went through the plugin to see what metrics could be removed, but
    actually didn't find any, the plugin push out metrics that make sense.
    
    Due to the path fiddling to figure out the plugin name I doubt this
    works (out-of-the-box) for external plugins, but I haven't tested that.
    Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
    
    * Update core/dnsserver/server.go
    Co-authored-by: default avatardilyevsky <ilyevsky@gmail.com>
    
    * Use [3]string
    Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
    
    * imports
    Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
    
    * remove dnstest changes
    Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
    
    * revert
    Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
    
    * Add some sleeps to make it less flaky
    Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
    
    * Revert "Add some sleeps to make it less flaky"
    
    This reverts commit b5c6655196e3ad570555f086832ceb1f48f6f2d5.
    
    * Remove forward when not needed
    Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
    
    * remove newline
    Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
    Co-authored-by: default avatardilyevsky <ilyevsky@gmail.com>
    6953ab2b
handler.go 1.7 KB