Skip to content

Commit

Permalink
fix(analysis): Graphite query - remove whitespaces
Browse files Browse the repository at this point in the history
Signed-off-by: mdsjip <[email protected]>
  • Loading branch information
mdsjip committed May 6, 2023
1 parent c74c464 commit 489053e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion metricproviders/graphite/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (api APIClient) Query(quer string) ([]dataPoint, error) {

func (api APIClient) trimQuery(q string) string {
space := regexp.MustCompile(`\s+`)
return space.ReplaceAllString(q, " ")
return space.ReplaceAllString(q, "")
}

type dataPoint struct {
Expand Down
23 changes: 23 additions & 0 deletions metricproviders/graphite/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,29 @@ func TestQuery(t *testing.T) {
nil,
`[]`,
200,
}, {
"query with surrounding whitespace",
fmt.Sprintf("\n %s \t \n", query),
targetQuery,
fromQuery,
goodResult,
nil,
fmt.Sprintf(`[
{
"datapoints": [
[
%f,
%d
]
],
"target": " sumSeries(app.http.*.*.count)",
"tags": {
"aggregatedBy": "sum",
"name": "sumSeries(app.http.*.*.count)"
}
}
]`, value, timestamp),
200,
}, {
"graphite response body with invalid JSON",
query,
Expand Down

0 comments on commit 489053e

Please sign in to comment.