-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Azure Monitor support for multiple aggregation types (#39204)
* Add aggregation type to the MetricRegistry key The MetricRegistry wasn't using the aggregation type in the cache key, returning the wrong answer to the 'needs update?' question. * Handle multiple aggregation types Restores support for multiple aggregation types for the same metric name. Adding tests for the known use cases so we don't miss this feature again in future updates.
- Loading branch information
Showing
9 changed files
with
527 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package azure | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGroupMetricsDefinitionsByResourceId(t *testing.T) { | ||
|
||
t.Run("Group metrics definitions by resource ID", func(t *testing.T) { | ||
metrics := []Metric{ | ||
{ | ||
ResourceId: "resource-1", | ||
Namespace: "namespace-1", | ||
Names: []string{"metric-1"}, | ||
}, | ||
{ | ||
ResourceId: "resource-1", | ||
Namespace: "namespace-1", | ||
Names: []string{"metric-2"}, | ||
}, | ||
{ | ||
ResourceId: "resource-1", | ||
Namespace: "namespace-1", | ||
Names: []string{"metric-3"}, | ||
}, | ||
} | ||
|
||
metricsByResourceId := groupMetricsDefinitionsByResourceId(metrics) | ||
|
||
assert.Equal(t, 1, len(metricsByResourceId)) | ||
assert.Equal(t, 3, len(metricsByResourceId["resource-1"])) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.