コード例 #1
0
        public void ListMetricDescriptors()
        {
            // Snippet: ListMetricDescriptors(string,string,int?,CallSettings)
            // Create client
            MetricServiceClient metricServiceClient = MetricServiceClient.Create();
            // Initialize request argument(s)
            string formattedName = MetricServiceClient.FormatProjectName("[PROJECT]");
            // Make the request
            IPagedEnumerable <ListMetricDescriptorsResponse, MetricDescriptor> response =
                metricServiceClient.ListMetricDescriptors(formattedName);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (MetricDescriptor item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over fixed-sized pages, lazily performing RPCs as required
            int pageSize = 10;

            foreach (FixedSizePage <MetricDescriptor> page in response.AsPages().WithFixedSize(pageSize))
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (MetricDescriptor item in page)
                {
                    Console.WriteLine(item);
                }
            }
            // End snippet
        }
コード例 #2
0
        /// <summary>Snippet for ListMetricDescriptors</summary>
        public void ListMetricDescriptors_RequestObject()
        {
            // Snippet: ListMetricDescriptors(ListMetricDescriptorsRequest,CallSettings)
            // Create client
            MetricServiceClient metricServiceClient = MetricServiceClient.Create();
            // Initialize request argument(s)
            ListMetricDescriptorsRequest request = new ListMetricDescriptorsRequest
            {
                ProjectName = new ProjectName("[PROJECT]"),
            };
            // Make the request
            PagedEnumerable <ListMetricDescriptorsResponse, MetricDescriptor> response =
                metricServiceClient.ListMetricDescriptors(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (MetricDescriptor item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListMetricDescriptorsResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (MetricDescriptor item in page)
                {
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <MetricDescriptor> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (MetricDescriptor item in singlePage)
            {
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
コード例 #3
0
        public void ListMetricDescriptors()
        {
            string projectId = _fixture.ProjectId;

            // Sample: ListMetricDescriptors
            // Additional: ListMetricDescriptors(*,*,*,*)
            MetricServiceClient client      = MetricServiceClient.Create();
            ProjectName         projectName = new ProjectName(projectId);
            PagedEnumerable <ListMetricDescriptorsResponse, MetricDescriptor> metrics = client.ListMetricDescriptors(projectName);

            foreach (MetricDescriptor metric in metrics.Take(10))
            {
                Console.WriteLine($"{metric.Name}: {metric.DisplayName}");
            }
            // End sample
        }
コード例 #4
0
        // [END monitoring_delete_metric]

        // [START monitoring_list_descriptors]
        public static object ListMetrics(string projectId)
        {
            MetricServiceClient client      = MetricServiceClient.Create();
            ProjectName         projectName = new ProjectName(projectId);
            PagedEnumerable <ListMetricDescriptorsResponse, MetricDescriptor> metrics = client.ListMetricDescriptors(projectName);

            foreach (MetricDescriptor metric in metrics)
            {
                Console.WriteLine($"{metric.Name}: {metric.DisplayName}");
            }
            return(0);
        }
コード例 #5
0
        public void ListMetricDescriptors()
        {
            string projectId = _fixture.ProjectId;

            // Snippet: ListMetricDescriptors
            MetricServiceClient client = MetricServiceClient.Create();
            string projectName         = MetricServiceClient.FormatProjectName(projectId);
            string filter = "";
            IPagedEnumerable <ListMetricDescriptorsResponse, MetricDescriptor> metrics = client.ListMetricDescriptors(projectName, filter);

            foreach (MetricDescriptor metric in metrics.Take(10))
            {
                Console.WriteLine($"{metric.Name}: {metric.DisplayName}");
            }
            // End snippet
        }