logger.warn("failed to send metrics to stackdriver: {}", e.getCause().getMessage());
private void createMetricDescriptorIfNecessary(MetricServiceClient client, Meter.Id id, MetricDescriptor.ValueType valueType, @Nullable String statistic) { if (!verifiedDescriptors.contains(id.getName())) { MetricDescriptor descriptor = MetricDescriptor.newBuilder() .setType(metricType(id, statistic)) .setDescription(id.getDescription() == null ? "" : id.getDescription()) .setMetricKind(MetricDescriptor.MetricKind.GAUGE) .setValueType(valueType) .build(); ProjectName name = ProjectName.of(config.projectId()); CreateMetricDescriptorRequest request = CreateMetricDescriptorRequest.newBuilder() .setName(name.toString()) .setMetricDescriptor(descriptor) .build(); if (logger.isTraceEnabled()) { logger.trace("creating metric descriptor:\n{}", request); } try { client.createMetricDescriptor(request); verifiedDescriptors.add(id.getName()); } catch (ApiException e) { logger.warn("failed to create metric descriptor in stackdriver for meter " + id + " {}", e.getCause().getMessage()); } } }