From e3be145cd8bd6b53ce303282f480a7cf011a8431 Mon Sep 17 00:00:00 2001 From: charleslin-appd Date: Sun, 12 Feb 2023 11:00:22 -0700 Subject: [PATCH] Specify more accurate error message --- pkg/metrics/providers/appdynamicscloud.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/metrics/providers/appdynamicscloud.go b/pkg/metrics/providers/appdynamicscloud.go index f3f371f75..1ec1638a2 100644 --- a/pkg/metrics/providers/appdynamicscloud.go +++ b/pkg/metrics/providers/appdynamicscloud.go @@ -126,18 +126,18 @@ func (p *AppDynamicsCloudProvider) RunQuery(query string) (float64, error) { return 0, fmt.Errorf("failed to un-marshaling result: %s.\n error: %w", string(body), err) } if len(anyValue) < 1 { - return 0, fmt.Errorf("invalid response: %s: %w", string(body), ErrNoValuesFound) + return 0, fmt.Errorf("invalid response for query: %s: %w", query, ErrNoValuesFound) } // actual result (non-meta data) is in the data element of the last item // of the json array data := anyValue[len(anyValue)-1]["data"].([]any) if len(data) < 1 { - return 0, fmt.Errorf("invalid response: %s: %w", string(body), ErrNoValuesFound) + return 0, fmt.Errorf("metrics not available for query: %s", query) } // nested in the data element of the first item data_data := data[0].([]any) if len(data_data) < 2 { - return 0, fmt.Errorf("invalid response: %s: %w", string(body), ErrNoValuesFound) + return 0, fmt.Errorf("invalid data item for query: %s", query) } // metrics data is the second element, the first element is the // source, e.g. "sys:derived"