File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Original file line number Diff line number Diff line change @@ -74,10 +74,17 @@ def create_custom_metric(client, project_id,
74
74
"displayName" : "Custom Metric"
75
75
}
76
76
77
- client .projects ().metricDescriptors ().create (
77
+ return client .projects ().metricDescriptors ().create (
78
78
name = project_id , body = metrics_descriptor ).execute ()
79
79
80
80
81
+ def delete_metric_descriptor (
82
+ client , custom_metric_name ):
83
+ """Delete a custom metric descriptor."""
84
+ client .projects ().metricDescriptors ().delete (
85
+ name = custom_metric_name ).execute ()
86
+
87
+
81
88
def get_custom_metric (client , project_id , custom_metric_type ):
82
89
"""Retrieve the custom metric we created"""
83
90
request = client .projects ().metricDescriptors ().list (
Original file line number Diff line number Diff line change 26
26
from gcp .testing import eventually_consistent
27
27
from gcp .testing .flaky import flaky
28
28
29
- from custom_metric import create_custom_metric , get_custom_metric
30
- from custom_metric import read_timeseries , write_timeseries_value
29
+ from custom_metric import create_custom_metric
30
+ from custom_metric import delete_metric_descriptor
31
+ from custom_metric import get_custom_metric
32
+ from custom_metric import read_timeseries
33
+ from custom_metric import write_timeseries_value
34
+
31
35
import list_resources
32
36
33
37
""" Custom metric domain for all custom metrics"""
@@ -53,7 +57,7 @@ def test_custom_metric(cloud_config):
53
57
INSTANCE_ID = "test_instance"
54
58
METRIC_KIND = "GAUGE"
55
59
56
- create_custom_metric (
60
+ custom_metric_descriptor = create_custom_metric (
57
61
client , PROJECT_RESOURCE , METRIC_RESOURCE , METRIC_KIND )
58
62
59
63
# wait until metric has been created, use the get call to wait until
@@ -77,3 +81,5 @@ def _():
77
81
response ['timeSeries' ][0 ]['points' ][0 ]['value' ]['int64Value' ])
78
82
# using seed of 1 will create a value of 1
79
83
assert value == pseudo_random_value
84
+
85
+ delete_metric_descriptor (client , custom_metric_descriptor ['name' ])
You can’t perform that action at this time.
0 commit comments