Skip to content

Commit

Permalink
Specify more accurate error message
Browse files Browse the repository at this point in the history
  • Loading branch information
charleslin-appd committed Feb 12, 2023
1 parent 23b7641 commit e3be145
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/metrics/providers/appdynamicscloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e3be145

Please sign in to comment.