本文整理汇总了Java中com.google.api.services.monitoring.v3.model.LabelDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java LabelDescriptor类的具体用法?Java LabelDescriptor怎么用?Java LabelDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LabelDescriptor类属于com.google.api.services.monitoring.v3.model包,在下文中一共展示了LabelDescriptor类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMetrics
import com.google.api.services.monitoring.v3.model.LabelDescriptor; //导入依赖的package包/类
private void createMetrics() {
try {
MetricDescriptor metricDescriptor = new MetricDescriptor()
.setType("custom.googleapis.com/cloud-pubsub/loadclient/" + metricName);
metricDescriptor.setDisplayName(metricName.toPrettyString())
.setDescription(metricName.toPrettyString())
.setName(metricDescriptor.getType())
.setLabels(Collections.singletonList(new LabelDescriptor()
.setKey("client_type")
.setDescription("The type of client reporting latency.")
.setValueType("STRING")))
.setMetricKind("GAUGE")
.setValueType("DISTRIBUTION")
.setUnit("ms");
monitoring.projects().metricDescriptors().create("projects/" + project, metricDescriptor)
.execute();
} catch (Exception e) {
log.info("Metrics already exist.");
}
}
示例2: encodeLabelDescriptors
import com.google.api.services.monitoring.v3.model.LabelDescriptor; //导入依赖的package包/类
@VisibleForTesting
static ImmutableList<LabelDescriptor> encodeLabelDescriptors(
ImmutableSet<com.google.monitoring.metrics.LabelDescriptor> labelDescriptors) {
List<LabelDescriptor> stackDriverLabelDescriptors = new ArrayList<>(labelDescriptors.size());
for (com.google.monitoring.metrics.LabelDescriptor labelDescriptor : labelDescriptors) {
stackDriverLabelDescriptors.add(
new LabelDescriptor()
.setKey(labelDescriptor.name())
.setDescription(labelDescriptor.description())
.setValueType(LABEL_VALUE_TYPE));
}
return ImmutableList.copyOf(stackDriverLabelDescriptors);
}