-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter attributes neuron metrics (#1262)
This change adds per-type emf attribute filtering to AWSNeuron EMF metrics
- Loading branch information
1 parent
5a46112
commit 55a3d88
Showing
8 changed files
with
684 additions
and
217 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
28 changes: 28 additions & 0 deletions
28
plugins/processors/gpuattributes/internal/awsneuron_metric_checker.go
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,28 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package internal | ||
|
||
import ( | ||
"regexp" | ||
) | ||
|
||
const ( | ||
PROCESSED_NEURON_METRIC_PATTERN = "^(container|node|pod)_(neuroncore_|neurondevice_).*|^node_neuron_.*" | ||
) | ||
|
||
type AwsNeuronMetricChecker struct { | ||
} | ||
|
||
func NewAwsNeuronMetricChecker() *AwsNeuronMetricChecker { | ||
return &AwsNeuronMetricChecker{} | ||
} | ||
|
||
func (md *AwsNeuronMetricChecker) IsProcessedNeuronMetric(name string) bool { | ||
matched, err := regexp.MatchString(PROCESSED_NEURON_METRIC_PATTERN, name) | ||
if err != nil { | ||
print(err) | ||
return false | ||
} | ||
return matched | ||
} |
73 changes: 73 additions & 0 deletions
73
plugins/processors/gpuattributes/internal/awsneuron_metric_checker_test.go
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,73 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package internal | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestAwsNeuronMetricModifier_IsProcessedNeuronMetric(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input string | ||
expected bool | ||
}{ | ||
{ | ||
name: "container_neuroncore_prefix", | ||
input: "container_neuroncore_metric", | ||
expected: true, | ||
}, | ||
{ | ||
name: "pod_neuroncore_prefix", | ||
input: "pod_neuroncore_metric", | ||
expected: true, | ||
}, | ||
{ | ||
name: "node_neuroncore_prefix", | ||
input: "node_neuroncore_metric", | ||
expected: true, | ||
}, | ||
{ | ||
name: "container_neurondevice_prefix", | ||
input: "container_neurondevice_metric", | ||
expected: true, | ||
}, | ||
{ | ||
name: "pod_neurondevice_prefix", | ||
input: "pod_neurondevice_metric", | ||
expected: true, | ||
}, | ||
{ | ||
name: "node_neurondevice_prefix", | ||
input: "node_neurondevice_metric", | ||
expected: true, | ||
}, | ||
{ | ||
name: "node_neuron_prefix", | ||
input: "node_neuron_metric", | ||
expected: true, | ||
}, | ||
{ | ||
name: "container_neuron_prefix", | ||
input: "container_neuron_metric", | ||
expected: false, | ||
}, | ||
{ | ||
name: "other_prefix", | ||
input: "other_metric", | ||
expected: false, | ||
}, | ||
} | ||
|
||
md := NewAwsNeuronMetricChecker() | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
result := md.IsProcessedNeuronMetric(test.input) | ||
if result != test.expected { | ||
t.Errorf("IsProcessedNeuronMetric(%q) = %v, expected %v", test.input, result, test.expected) | ||
} | ||
}) | ||
} | ||
} |
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.