示例#1
0
 /// <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
 }
示例#2
0
 /// <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
 }
示例#3
0
        // [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);
        }