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:
janluk
2019-10-04 17:48:43 +02:00
committed by Miek Gieben
parent 03ea2ae955
commit d7cdb992b4
11 changed files with 330 additions and 37 deletions

View File

@@ -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
}