/// <summary>Snippet for GetMetricDescriptor</summary> public void GetMetricDescriptor() { // Snippet: GetMetricDescriptor(MetricDescriptorName,CallSettings) // Create client MetricServiceClient metricServiceClient = MetricServiceClient.Create(); // Initialize request argument(s) MetricDescriptorName name = new MetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]"); // Make the request MetricDescriptor response = metricServiceClient.GetMetricDescriptor(name); // End snippet }
/// <summary>Snippet for GetMetricDescriptor</summary> public void GetMetricDescriptor_RequestObject() { // Snippet: GetMetricDescriptor(GetMetricDescriptorRequest,CallSettings) // Create client MetricServiceClient metricServiceClient = MetricServiceClient.Create(); // Initialize request argument(s) GetMetricDescriptorRequest request = new GetMetricDescriptorRequest { MetricDescriptorName = new MetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]"), }; // Make the request MetricDescriptor response = metricServiceClient.GetMetricDescriptor(request); // End snippet }
// [END monitoring_list_descriptors] // [START monitoring_get_descriptor] public static object GetMetricDetails(string projectId, string metricType) { MetricServiceClient client = MetricServiceClient.Create(); MetricDescriptorName name = new MetricDescriptorName(projectId, metricType); try { var response = client.GetMetricDescriptor(name); string metric = JObject.Parse($"{response}").ToString(); Console.WriteLine($"{ metric }"); } catch (Grpc.Core.RpcException ex) when(ex.Status.StatusCode == Grpc.Core.StatusCode.NotFound) { } return(0); }