Skip to content

Commit

Permalink
Use namespace while filtering metric result
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Singh <[email protected]>
  • Loading branch information
viveksyngh authored and alexellis committed Nov 2, 2020
1 parent c0ba41c commit c9c2b39
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gateway/metrics/add_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func mixIn(functions *[]types.FunctionStatus, metrics *VectorQueryResponse) {
for i, function := range *functions {
for _, v := range metrics.Data.Result {

if v.Metric.FunctionName == function.Name {
if v.Metric.FunctionName == fmt.Sprintf("%s.%s", function.Name, function.Namespace) {
metricValue := v.Value[1]
switch metricValue.(type) {
case string:
Expand Down
7 changes: 4 additions & 3 deletions gateway/metrics/add_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type FakePrometheusQueryFetcher struct {
}

func (q FakePrometheusQueryFetcher) Fetch(query string) (*VectorQueryResponse, error) {
val := []byte(`{"status":"success","data":{"resultType":"vector","result":[{"metric":{"code":"200","function_name":"func_echoit"},"value":[1509267827.752,"1"]}]}}`)
val := []byte(`{"status":"success","data":{"resultType":"vector","result":[{"metric":{"code":"200","function_name":"func_echoit.openfaas-fn"},"value":[1509267827.752,"1"]}]}}`)
queryRes := VectorQueryResponse{}
err := json.Unmarshal(val, &queryRes)
return &queryRes, err
Expand Down Expand Up @@ -84,8 +84,9 @@ func makeFunctionsHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
functions := []types.FunctionStatus{
types.FunctionStatus{
Name: "func_echoit",
Replicas: 0,
Name: "func_echoit",
Replicas: 0,
Namespace: "openfaas-fn",
},
}
bytesOut, marshalErr := json.Marshal(&functions)
Expand Down

0 comments on commit c9c2b39

Please sign in to comment.