Search in sources :

Example 6 with MetricInfo

use of com.google.cloud.logging.MetricInfo in project google-cloud-java by GoogleCloudPlatform.

the class LoggingSnippets method updateMetricAsync.

/**
   * Example of asynchronously updating a metric.
   */
// [TARGET updateAsync(MetricInfo)]
// [VARIABLE "my_metric_name"]
public Metric updateMetricAsync(String metricName) throws ExecutionException, InterruptedException {
    // [START updateMetricAsync]
    MetricInfo metricInfo = MetricInfo.newBuilder(metricName, "severity>=ERROR").setDescription("new description").build();
    Future<Metric> future = logging.updateAsync(metricInfo);
    // ...
    Metric metric = future.get();
    // [END updateMetricAsync]
    return metric;
}
Also used : MetricInfo(com.google.cloud.logging.MetricInfo) Metric(com.google.cloud.logging.Metric)

Aggregations

MetricInfo (com.google.cloud.logging.MetricInfo)6 Metric (com.google.cloud.logging.Metric)5 Logging (com.google.cloud.logging.Logging)1 RemoteLoggingHelper (com.google.cloud.logging.testing.RemoteLoggingHelper)1 BeforeClass (org.junit.BeforeClass)1