Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 56a6b16

Browse filesBrowse files
authored
Time series tests use random unique name to avoid limits (GoogleCloudPlatform#1776)
* Time series tests use random unique name to avoid limits * Lint wants another blank line here * Use current debian image family * Restore to old state. Work should be on different branch. * Update snippets.py
1 parent 81a8413 commit 56a6b16
Copy full SHA for 56a6b16

File tree

Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed

‎monitoring/api/v3/cloud-client/snippets.py

Copy file name to clipboardExpand all lines: monitoring/api/v3/cloud-client/snippets.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,22 @@
1515
import argparse
1616
import os
1717
import pprint
18+
import random
1819
import time
1920

2021
from google.cloud import monitoring_v3
2122

2223

24+
# Avoid collisions with other runs
25+
RANDOM_SUFFIX = str(random.randint(1000, 9999))
26+
27+
2328
def create_metric_descriptor(project_id):
2429
# [START monitoring_create_metric]
2530
client = monitoring_v3.MetricServiceClient()
2631
project_name = client.project_path(project_id)
2732
descriptor = monitoring_v3.types.MetricDescriptor()
28-
descriptor.type = 'custom.googleapis.com/my_metric'
33+
descriptor.type = 'custom.googleapis.com/my_metric' + RANDOM_SUFFIX
2934
descriptor.metric_kind = (
3035
monitoring_v3.enums.MetricDescriptor.MetricKind.GAUGE)
3136
descriptor.value_type = (
@@ -50,7 +55,7 @@ def write_time_series(project_id):
5055
project_name = client.project_path(project_id)
5156

5257
series = monitoring_v3.types.TimeSeries()
53-
series.metric.type = 'custom.googleapis.com/my_metric'
58+
series.metric.type = 'custom.googleapis.com/my_metric' + RANDOM_SUFFIX
5459
series.resource.type = 'gce_instance'
5560
series.resource.labels['instance_id'] = '1234567890123456789'
5661
series.resource.labels['zone'] = 'us-central1-f'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.