mirror of
https://github.com/openfaas/faas.git
synced 2025-06-09 08:46:48 +00:00
Adds a pair of configuration options for performance tuning. The gateway can now invoke functions directly and can bypass the provider. See updated table in README.md for configuration values. BaseURLResolver is added with unit tests that decouples resolving upstream URL from the reverse proxy client code. - SingleHostBaseURLResolver resolves a single upstream host - FunctionAsHostBaseURLResolver resolves host based upon conventions within the URL of the request to a function for direct access Tested with Kubernetes (faas-netes) and faas-swarm through UI, CLI calling system endpoints and functions directly. Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
32 lines
887 B
Go
32 lines
887 B
Go
// Copyright (c) Alex Ellis 2017. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
package handlers
|
|
|
|
import (
|
|
"strconv"
|
|
"time"
|
|
|
|
"github.com/openfaas/faas/gateway/metrics"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
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())
|
|
}
|
|
|
|
func trackTimeExact(duration time.Duration, metrics metrics.MetricOptions, name string) {
|
|
metrics.GatewayFunctionsHistogram.
|
|
WithLabelValues(name).
|
|
Observe(float64(duration))
|
|
}
|