Sync async_nats work with master

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis
2017-08-18 17:44:00 +01:00
parent edb71d8b09
commit bd146f526c
79 changed files with 24713 additions and 1762 deletions

View File

@ -75,19 +75,6 @@ func MakeProxy(metrics metrics.MetricOptions, wildcard bool, client *client.Clie
}
}
func writeHead(service string, metrics metrics.MetricOptions, code int, w http.ResponseWriter) {
w.WriteHeader(code)
metrics.GatewayFunctionInvocation.With(prometheus.Labels{"function_name": service, "code": strconv.Itoa(code)}).Inc()
// metrics.GatewayFunctionInvocation.WithLabelValues(service).Add(1)
}
func trackTime(then time.Time, metrics metrics.MetricOptions, name string) {
since := time.Since(then)
metrics.GatewayFunctionsHistogram.WithLabelValues(name).Observe(since.Seconds())
}
func lookupInvoke(w http.ResponseWriter, r *http.Request, metrics metrics.MetricOptions, name string, c *client.Client, logger *logrus.Logger, proxyClient *http.Client) {
exists, err := lookupSwarmService(name, c)
@ -197,3 +184,18 @@ func randomInt(min, max int) int {
rand.Seed(time.Now().Unix())
return rand.Intn(max-min) + min
}
func writeHead(service string, metrics metrics.MetricOptions, code int, w http.ResponseWriter) {
w.WriteHeader(code)
trackInvocation(service, metrics, code)
}
func trackInvocation(service string, metrics metrics.MetricOptions, code int) {
metrics.GatewayFunctionInvocation.With(prometheus.Labels{"function_name": service, "code": strconv.Itoa(code)}).Inc()
}
func trackTime(then time.Time, metrics metrics.MetricOptions, name string) {
since := time.Since(then)
metrics.GatewayFunctionsHistogram.WithLabelValues(name).Observe(since.Seconds())
}