mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 03:56:37 +00:00
Specify Linux constraints by default
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
@ -16,6 +16,8 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
io_prometheus_client "github.com/prometheus/client_model/go"
|
||||
)
|
||||
|
||||
// MakeFunctionReader gives a summary of Function structs with Docker service stats overlaid with Prometheus counters.
|
||||
@ -68,3 +70,19 @@ func MakeFunctionReader(metricsOptions metrics.MetricOptions, c *client.Client)
|
||||
w.Write(functionBytes)
|
||||
}
|
||||
}
|
||||
|
||||
func getCounterValue(service string, code string, metricsOptions *metrics.MetricOptions) float64 {
|
||||
|
||||
metric, err := metricsOptions.GatewayFunctionInvocation.
|
||||
GetMetricWith(prometheus.Labels{"function_name": service, "code": code})
|
||||
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
// Get the metric's value from ProtoBuf interface (idea via Julius Volz)
|
||||
var protoMetric io_prometheus_client.Metric
|
||||
metric.Write(&protoMetric)
|
||||
invocations := protoMetric.GetCounter().GetValue()
|
||||
return invocations
|
||||
}
|
||||
|
Reference in New Issue
Block a user