Exemplo n.º 1
0
        public async Task ListMetricDescriptorsAsync()
        {
            // Snippet: ListMetricDescriptorsAsync(string,string,int?,CallSettings)
            // Create client
            MetricServiceClient metricServiceClient = MetricServiceClient.Create();
            // Initialize request argument(s)
            string formattedName = MetricServiceClient.FormatProjectName("[PROJECT]");
            // Make the request
            IPagedAsyncEnumerable <ListMetricDescriptorsResponse, MetricDescriptor> response =
                metricServiceClient.ListMetricDescriptorsAsync(formattedName);

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

            // Or iterate over fixed-sized pages, lazily performing RPCs as required
            int pageSize = 10;
            IAsyncEnumerable <FixedSizePage <MetricDescriptor> > fixedSizePages = response.AsPages().WithFixedSize(pageSize);
            await fixedSizePages.ForEachAsync((FixedSizePage <MetricDescriptor> page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (MetricDescriptor item in page)
                {
                    Console.WriteLine(item);
                }
            });

            // End snippet
        }
Exemplo n.º 2
0
        public void ListMonitoredResourceDescriptors()
        {
            // Snippet: ListMonitoredResourceDescriptors(string,string,int?,CallSettings)
            // Create client
            MetricServiceClient metricServiceClient = MetricServiceClient.Create();
            // Initialize request argument(s)
            string formattedName = MetricServiceClient.FormatProjectName("[PROJECT]");
            // Make the request
            IPagedEnumerable <ListMonitoredResourceDescriptorsResponse, MonitoredResourceDescriptor> response =
                metricServiceClient.ListMonitoredResourceDescriptors(formattedName);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (MonitoredResourceDescriptor 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 <MonitoredResourceDescriptor> page in response.AsPages().WithFixedSize(pageSize))
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (MonitoredResourceDescriptor item in page)
                {
                    Console.WriteLine(item);
                }
            }
            // End snippet
        }
Exemplo n.º 3
0
 public void CreateMetricDescriptor()
 {
     // Snippet: CreateMetricDescriptor(string,MetricDescriptor,CallSettings)
     // Create client
     MetricServiceClient metricServiceClient = MetricServiceClient.Create();
     // Initialize request argument(s)
     string           formattedName    = MetricServiceClient.FormatProjectName("[PROJECT]");
     MetricDescriptor metricDescriptor = new MetricDescriptor();
     // Make the request
     MetricDescriptor response = metricServiceClient.CreateMetricDescriptor(formattedName, metricDescriptor);
     // End snippet
 }
Exemplo n.º 4
0
        public void CreateTimeSeries()
        {
            // Snippet: CreateTimeSeries(string,IEnumerable<TimeSeries>,CallSettings)
            // Create client
            MetricServiceClient metricServiceClient = MetricServiceClient.Create();
            // Initialize request argument(s)
            string formattedName = MetricServiceClient.FormatProjectName("[PROJECT]");
            IEnumerable <TimeSeries> timeSeries = new List <TimeSeries>();

            // Make the request
            metricServiceClient.CreateTimeSeries(formattedName, timeSeries);
            // End snippet
        }
Exemplo n.º 5
0
        public async Task CreateTimeSeriesAsync()
        {
            // Snippet: CreateTimeSeriesAsync(string,IEnumerable<TimeSeries>,CallSettings)
            // Additional: CreateTimeSeriesAsync(string,IEnumerable<TimeSeries>,CancellationToken)
            // Create client
            MetricServiceClient metricServiceClient = MetricServiceClient.Create();
            // Initialize request argument(s)
            string formattedName = MetricServiceClient.FormatProjectName("[PROJECT]");
            IEnumerable <TimeSeries> timeSeries = new List <TimeSeries>();
            // Make the request
            await metricServiceClient.CreateTimeSeriesAsync(formattedName, timeSeries);

            // End snippet
        }
Exemplo n.º 6
0
        public async Task CreateMetricDescriptorAsync()
        {
            // Snippet: CreateMetricDescriptorAsync(string,MetricDescriptor,CallSettings)
            // Additional: CreateMetricDescriptorAsync(string,MetricDescriptor,CancellationToken)
            // Create client
            MetricServiceClient metricServiceClient = MetricServiceClient.Create();
            // Initialize request argument(s)
            string           formattedName    = MetricServiceClient.FormatProjectName("[PROJECT]");
            MetricDescriptor metricDescriptor = new MetricDescriptor();
            // Make the request
            MetricDescriptor response = await metricServiceClient.CreateMetricDescriptorAsync(formattedName, metricDescriptor);

            // End snippet
        }
Exemplo n.º 7
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
        }
Exemplo n.º 8
0
        public async Task ListTimeSeriesAsync()
        {
            // Snippet: ListTimeSeriesAsync(string,string,TimeInterval,ListTimeSeriesRequest.Types.TimeSeriesView,string,int?,CallSettings)
            // Create client
            MetricServiceClient metricServiceClient = MetricServiceClient.Create();
            // Initialize request argument(s)
            string       formattedName = MetricServiceClient.FormatProjectName("[PROJECT]");
            string       filter        = "";
            TimeInterval interval      = new TimeInterval();

            ListTimeSeriesRequest.Types.TimeSeriesView view = ListTimeSeriesRequest.Types.TimeSeriesView.Full;
            // Make the request
            IPagedAsyncEnumerable <ListTimeSeriesResponse, TimeSeries> response =
                metricServiceClient.ListTimeSeriesAsync(formattedName, filter, interval, view);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((TimeSeries item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over fixed-sized pages, lazily performing RPCs as required
            int pageSize = 10;
            IAsyncEnumerable <FixedSizePage <TimeSeries> > fixedSizePages = response.AsPages().WithFixedSize(pageSize);
            await fixedSizePages.ForEachAsync((FixedSizePage <TimeSeries> page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (TimeSeries item in page)
                {
                    Console.WriteLine(item);
                }
            });

            // End snippet
        }