@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
/** * Gets a logs-based metric. * * <p>Sample code: * * <pre><code> * try (MetricsClient metricsClient = MetricsClient.create()) { * MetricName metricName = ProjectMetricName.of("[PROJECT]", "[METRIC]"); * LogMetric response = metricsClient.getLogMetric(metricName); * } * </code></pre> * * @param metricName The resource name of the desired metric: * <p>"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogMetric getLogMetric(MetricName metricName) { GetLogMetricRequest request = GetLogMetricRequest.newBuilder() .setMetricName(metricName == null ? null : metricName.toString()) .build(); return getLogMetric(request); }
/** * Gets a logs-based metric. * * <p>Sample code: * * <pre><code> * try (MetricsClient metricsClient = MetricsClient.create()) { * MetricName metricName = ProjectMetricName.of("[PROJECT]", "[METRIC]"); * LogMetric response = metricsClient.getLogMetric(metricName.toString()); * } * </code></pre> * * @param metricName The resource name of the desired metric: * <p>"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogMetric getLogMetric(String metricName) { GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(metricName).build(); return getLogMetric(request); }
@Test public void testGetMetric_Null() { ApiFuture<LogMetric> response = ApiFutures.immediateFuture(null); GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build(); EasyMock.expect(loggingRpcMock.get(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); assertNull(logging.getMetric(METRIC_NAME)); }
@Override public ApiFuture<Metric> getMetricAsync(String metric) { GetLogMetricRequest request = GetLogMetricRequest.newBuilder() .setMetricName(ProjectMetricName.of(getOptions().getProjectId(), metric).toString()) .build(); return transform(rpc.get(request), Metric.fromPbFunction(this)); }
@Test public void testGetMetricAsync_Null() throws ExecutionException, InterruptedException { ApiFuture<LogMetric> response = ApiFutures.immediateFuture(null); GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build(); EasyMock.expect(loggingRpcMock.get(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); assertNull(logging.getMetricAsync(METRIC_NAME).get()); }
@Test public void testGetMetric() { LogMetric sinkPb = METRIC_INFO.toPb(); ApiFuture<LogMetric> response = ApiFutures.immediateFuture(sinkPb); GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build(); EasyMock.expect(loggingRpcMock.get(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); Metric sink = logging.getMetric(METRIC_NAME); assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), sink); }
@Test public void testGetMetricAsync() throws ExecutionException, InterruptedException { LogMetric sinkPb = METRIC_INFO.toPb(); ApiFuture<LogMetric> response = ApiFutures.immediateFuture(sinkPb); GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(METRIC_NAME_PB).build(); EasyMock.expect(loggingRpcMock.get(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); Metric sink = logging.getMetricAsync(METRIC_NAME).get(); assertEquals(new Metric(logging, new MetricInfo.BuilderImpl(METRIC_INFO)), sink); }
/** * Gets a logs-based metric. * * <p>Sample code: * * <pre><code> * try (MetricsClient metricsClient = MetricsClient.create()) { * MetricName metricName = ProjectMetricName.of("[PROJECT]", "[METRIC]"); * LogMetric response = metricsClient.getLogMetric(metricName); * } * </code></pre> * * @param metricName The resource name of the desired metric: * <p>"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogMetric getLogMetric(MetricName metricName) { GetLogMetricRequest request = GetLogMetricRequest.newBuilder() .setMetricName(metricName == null ? null : metricName.toString()) .build(); return getLogMetric(request); }
/** * Gets a logs-based metric. * * <p>Sample code: * * <pre><code> * try (MetricsClient metricsClient = MetricsClient.create()) { * MetricName metricName = ProjectMetricName.of("[PROJECT]", "[METRIC]"); * LogMetric response = metricsClient.getLogMetric(metricName.toString()); * } * </code></pre> * * @param metricName The resource name of the desired metric: * <p>"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogMetric getLogMetric(String metricName) { GetLogMetricRequest request = GetLogMetricRequest.newBuilder().setMetricName(metricName).build(); return getLogMetric(request); }
@Override public ApiFuture<Metric> getMetricAsync(String metric) { GetLogMetricRequest request = GetLogMetricRequest.newBuilder() .setMetricName(ProjectMetricName.of(getOptions().getProjectId(), metric).toString()) .build(); return transform(rpc.get(request), Metric.fromPbFunction(this)); }