本文整理了Java中io.micrometer.core.instrument.Tags.and()
方法的一些代码示例,展示了Tags.and()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tags.and()
方法的具体详情如下:
包路径:io.micrometer.core.instrument.Tags
类名称:Tags
方法名:and
暂无
代码示例来源:origin: micrometer-metrics/micrometer
@Threads(16)
@Benchmark
public void dotAnd() {
Tags.of("key", "value").and("key2", "value2", "key3", "value3", "key4", "value4", "key5", "value5");
}
代码示例来源:origin: rsocket/rsocket-java
private static Counter counter(
Type connectionType, MeterRegistry meterRegistry, String frameType, Tag... tags) {
return meterRegistry.counter(
"rsocket.frame",
Tags.of(tags).and("connection.type", connectionType.name()).and("frame.type", frameType));
}
}
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
@SuppressWarnings({ "unchecked" })
private MeterBinder getMeterBinder(Cache cache, Tags tags) {
Tags cacheTags = tags.and(getAdditionalTags(cache));
return LambdaSafe
.callbacks(CacheMeterBinderProvider.class, this.binderProviders, cache)
.withLogger(CacheMetricsRegistrar.class)
.invokeAnd((binderProvider) -> binderProvider.getMeterBinder(cache,
cacheTags))
.filter(Objects::nonNull).findFirst().orElse(null);
}
代码示例来源:origin: rsocket/rsocket-java
private static Counter counter(
MeterRegistry meterRegistry, String interactionModel, SignalType signalType, Tag... tags) {
return meterRegistry.counter(
"rsocket." + interactionModel, Tags.of(tags).and("signal.type", signalType.name()));
}
}
代码示例来源:origin: rsocket/rsocket-java
private static Timer timer(
MeterRegistry meterRegistry, String interactionModel, SignalType signalType, Tag... tags) {
return meterRegistry.timer(
"rsocket." + interactionModel, Tags.of(tags).and("signal.type", signalType.name()));
}
}
代码示例来源:origin: rsocket/rsocket-java
/**
* Creates a new {@link DuplexConnection}.
*
* @param connectionType the type of connection being monitored
* @param delegate the {@link DuplexConnection} to delegate to
* @param meterRegistry the {@link MeterRegistry} to use
* @param tags additional tags to attach to {@link Meter}s
* @throws NullPointerException if {@code connectionType}, {@code delegate}, or {@code
* meterRegistry} is {@code null}
*/
MicrometerDuplexConnection(
Type connectionType, DuplexConnection delegate, MeterRegistry meterRegistry, Tag... tags) {
Objects.requireNonNull(connectionType, "connectionType must not be null");
this.delegate = Objects.requireNonNull(delegate, "delegate must not be null");
Objects.requireNonNull(meterRegistry, "meterRegistry must not be null");
this.close =
meterRegistry.counter(
"rsocket.duplex.connection.close",
Tags.of(tags).and("connection.type", connectionType.name()));
this.dispose =
meterRegistry.counter(
"rsocket.duplex.connection.dispose",
Tags.of(tags).and("connection.type", connectionType.name()));
this.frameCounters = new FrameCounters(connectionType, meterRegistry, tags);
}
代码示例来源:origin: com.hotels.road/road-offramp-service
private AtomicLong getPartitionLatencyHolder(int partition) {
return partitionLatencies.computeIfAbsent(partition, k -> {
Tags tags = roadStreamTags.and("partition", Integer.toString(k));
AtomicLong latencyHolder = new AtomicLong();
registry.more().timeGauge(OFFRAMP + LATENCY, tags, latencyHolder, MILLISECONDS, AtomicLong::doubleValue);
return latencyHolder;
});
}
代码示例来源:origin: eclipse/hono
@Override
public final void incrementProcessedMessages(final String type, final String tenantId) {
Objects.requireNonNull(type);
Objects.requireNonNull(tenantId);
this.registry.counter(METER_MESSAGES_PROCESSED,
Tags.of(MetricsTags.TAG_TENANT, tenantId).and(MetricsTags.TAG_TYPE, type))
.increment();
}
代码示例来源:origin: eclipse/hono
@Override
public final void incrementUndeliverableMessages(final String type, final String tenantId) {
Objects.requireNonNull(type);
Objects.requireNonNull(tenantId);
this.registry.counter(METER_MESSAGES_UNDELIVERABLE,
Tags.of(MetricsTags.TAG_TENANT, tenantId).and(MetricsTags.TAG_TYPE, type))
.increment();
}
代码示例来源:origin: eclipse/hono
@Override
public final void incrementProcessedPayload(final String type, final String tenantId,
final long payloadSize) {
Objects.requireNonNull(type);
Objects.requireNonNull(tenantId);
if (payloadSize < 0) {
// A negative size would mess up the metrics
return;
}
this.registry.counter("hono.messages.processed.payload",
Tags.of(MetricsTags.TAG_TENANT, tenantId).and(MetricsTags.TAG_TYPE, type))
.increment(payloadSize);
}
代码示例来源:origin: com.hotels.road/road-offramp-service
public <T> T record(TimerTag timerTag, Supplier<T> supplier) {
return registry.timer(OFFRAMP_TIMER, roadStreamTags.and(timerTag.tag)).record(supplier);
}
代码示例来源:origin: com.hotels.road/road-offramp-service
public void record(TimerTag timerTag, Runnable runnable) {
registry.timer(OFFRAMP_TIMER, roadStreamTags.and(timerTag.tag)).record(runnable);
}
代码示例来源:origin: eclipse/hono
/**
* Verifies that HTTP adapter metrics are correctly mapped to
* the legacy format's metric names.
*/
@Test
public void testMappingOfHttpAdapterMetrics() {
final Tags httpTags = defaultTags
.and(MetricsTags.TAG_COMPONENT_TYPE, MetricsTags.VALUE_COMPONENT_TYPE_ADAPTER)
.and(MetricsTags.TAG_COMPONENT_NAME, Constants.PROTOCOL_ADAPTER_TYPE_HTTP)
.and(MetricsTags.TAG_TENANT, TENANT);
assertCommonAdapterMetrics("http", httpTags);
}
代码示例来源:origin: org.eclipse.hono/hono-service-base
@Override
public final void incrementProcessedMessages(final String type, final String tenantId) {
this.registry.counter("hono.messages.processed",
Tags
.of("tenant", tenantId)
.and("type", type))
.increment();
}
代码示例来源:origin: org.eclipse.hono/hono-service-base
@Override
public final void incrementUndeliverableMessages(final String type, final String tenantId) {
this.registry.counter("hono.messages.undeliverable",
Tags
.of("tenant", tenantId)
.and("type", type))
.increment();
}
代码示例来源:origin: eclipse/hono
/**
* Verifies that MQTT adapter metrics are correctly mapped to
* the legacy format's metric names.
*/
@Test
public void testMappingOfMqttAdapterMetrics() {
final Tags mqttTags = defaultTags
.and(MetricsTags.TAG_COMPONENT_TYPE, MetricsTags.VALUE_COMPONENT_TYPE_ADAPTER)
.and(MetricsTags.TAG_COMPONENT_NAME, Constants.PROTOCOL_ADAPTER_TYPE_MQTT);
assertConnectionMetrics("mqtt", mqttTags);
final Tags mqttWithTenantTags = mqttTags.and(MetricsTags.TAG_TENANT, TENANT);
assertCommonAdapterMetrics("mqtt", mqttWithTenantTags);
}
代码示例来源:origin: org.eclipse.hono/hono-service-base
@Override
public final void incrementProcessedPayload(final String type, final String tenantId,
final long payloadSize) {
if (payloadSize < 0) {
// A negative size would mess up the metrics
return;
}
this.registry.counter("hono.messages.processed.payload",
Tags
.of("tenant", tenantId)
.and("type", type))
.increment(payloadSize);
}
代码示例来源:origin: eclipse/hono
private void assertConnectionMetrics(final String protocol, final Tags tags) {
final Tags tagsWithTenant = tags.and(MetricsTags.TAG_TENANT, TENANT);
assertMapping(
new Id(MicrometerBasedMetrics.METER_CONNECTIONS_UNAUTHENTICATED, tags, null, null, Type.GAUGE),
String.format("%s.counter.hono.%s.connections.unauthenticated.count",
HOSTNAME_MAPPED, protocol));
assertMapping(
new Id(MicrometerBasedMetrics.METER_CONNECTIONS_AUTHENTICATED, tagsWithTenant, null, null, Type.GAUGE),
String.format("%s.counter.hono.%s.connections.authenticated.%s.count",
HOSTNAME_MAPPED, protocol, TENANT));
}
代码示例来源:origin: com.hotels.road/road-offramp-service
OfframpMetrics(
String roadName,
String streamName,
MeterRegistry registry,
Clock clock,
Map<RoadAndStream, AtomicInteger> activeConnections) {
this.registry = registry;
this.clock = clock;
this.activeConnections = activeConnections;
roadAndStream = RoadAndStream.of(roadName, streamName);
roadStreamTags = Tags.of(ROAD, roadName).and(STREAM, streamName);
commitSuccessCounter = registry.counter(OFFRAMP + COMMIT_SUCCESS, roadStreamTags);
commitFailureCounter = registry.counter(OFFRAMP + COMMIT_FAILURE, roadStreamTags);
messageCounter = registry.counter(OFFRAMP + MESSAGE, roadStreamTags);
bytesCounter = registry.counter(OFFRAMP + BYTES, roadStreamTags);
rebalanceCounter = registry.counter(OFFRAMP + REBALANCE, roadStreamTags);
roadNotFoundCounter = registry.counter(OFFRAMP + ROAD_NOT_FOUND, roadStreamTags);
transportErrorCounter = registry.counter(OFFRAMP + TRANSPORT_ERROR, roadStreamTags);
connectionEstablishedCounter = registry.counter(OFFRAMP + CONNECTIONS_ESTABLISHED, roadStreamTags);
partitionLatencies = new ConcurrentHashMap<>();
}
代码示例来源:origin: org.apache.camel/camel-micrometer
@Override
public void process(Exchange exchange) {
Message in = exchange.getIn();
String defaultMetricsName = simple(exchange, getEndpoint().getMetricsName(), String.class);
String finalMetricsName = getStringHeader(in, HEADER_METRIC_NAME, defaultMetricsName);
Iterable<Tag> defaultTags = getEndpoint().getTags();
Iterable<Tag> headerTags = getTagHeader(in, HEADER_METRIC_TAGS, Tags.empty());
Iterable<Tag> finalTags = Tags.concat(defaultTags, headerTags).stream()
.map(tag -> Tag.of(
simple(exchange, tag.getKey(), String.class),
simple(exchange, tag.getValue(), String.class)))
.reduce(Tags.empty(), Tags::and, Tags::and)
.and(Tags.of(
CAMEL_CONTEXT_TAG, getEndpoint().getCamelContext().getName()));
try {
doProcess(exchange, finalMetricsName, finalTags);
} catch (Exception e) {
exchange.setException(e);
} finally {
clearMetricsHeaders(in);
}
}
内容来源于网络,如有侵权,请联系作者删除!