mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 08:44:17 -04:00
Measure and expose DNS programming latency from Kubernetes plugin. (#3171)
For now metric is measure only for headless services. Informer has been slighlty refactored, so the code can measure latency without storing extra fields on Endpoint struct. Signed-off-by: Janek Łukaszewicz <janluk@google.com> Suggestions from code review Co-Authored-By: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
@@ -26,8 +26,14 @@ type Service struct {
|
||||
// ServiceKey return a string using for the index.
|
||||
func ServiceKey(name, namespace string) string { return name + "." + namespace }
|
||||
|
||||
// ToService converts an api.Service to a *Service.
|
||||
func ToService(obj interface{}) interface{} {
|
||||
// ToService returns a function that converts an api.Service to a *Service.
|
||||
func ToService(skipCleanup bool) ToFunc {
|
||||
return func(obj interface{}) interface{} {
|
||||
return toService(skipCleanup, obj)
|
||||
}
|
||||
}
|
||||
|
||||
func toService(skipCleanup bool, obj interface{}) interface{} {
|
||||
svc, ok := obj.(*api.Service)
|
||||
if !ok {
|
||||
return nil
|
||||
@@ -58,7 +64,9 @@ func ToService(obj interface{}) interface{} {
|
||||
s.ExternalIPs[li+i] = lb.IP
|
||||
}
|
||||
|
||||
*svc = api.Service{}
|
||||
if !skipCleanup {
|
||||
*svc = api.Service{}
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user