本文整理了Java中io.micrometer.core.instrument.Tag.of()
方法的一些代码示例,展示了Tag.of()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.of()
方法的具体详情如下:
包路径:io.micrometer.core.instrument.Tag
类名称:Tag
方法名:of
暂无
代码示例来源:origin: line/armeria
private static void zip(List<Tag> list, String... tags) {
checkArgument(tags.length % 2 == 0, "tags.length: %s (expected: even)", tags.length);
for (int i = 0; i < tags.length;) {
list.add(Tag.of(tags[i++], tags[i++]));
}
}
代码示例来源:origin: line/armeria
@Override
public void accept(List<Endpoint> endpoints) {
final Map<Endpoint, Boolean> endpointsToUpdate = new HashMap<>();
endpoints.forEach(e -> endpointsToUpdate.put(e, true));
endpointGroup.allServers.forEach(
conn -> endpointsToUpdate.putIfAbsent(conn.endpoint(), false));
// Update the previously appeared endpoints.
healthMap.entrySet().forEach(e -> {
final Endpoint authority = e.getKey();
final Boolean healthy = endpointsToUpdate.remove(authority);
e.setValue(Boolean.TRUE.equals(healthy));
});
// Process the newly appeared endpoints.
endpointsToUpdate.forEach((endpoint, healthy) -> {
healthMap.put(endpoint, healthy);
final List<Tag> tags = new ArrayList<>(2);
tags.add(Tag.of("authority", endpoint.authority()));
final String ipAddr = endpoint.hasIpAddr() ? endpoint.ipAddr() : "";
assert ipAddr != null;
tags.add(Tag.of("ip", ipAddr));
registry.gauge(idPrefix.name(), idPrefix.tags(tags),
this, unused -> healthMap.get(endpoint) ? 1 : 0);
});
}
}
代码示例来源:origin: reactor/reactor-core
Tag.of(TAG_SCHEDULER_ID, schedulerId));
代码示例来源:origin: line/armeria
@Override
public MeterIdPrefix apply(MeterRegistry registry, RequestLog log) {
final List<Tag> tags = buildTags(log);
// Add the 'httpStatus' tag.
final HttpStatus status;
if (log.isAvailable(RequestLogAvailability.RESPONSE_HEADERS)) {
status = log.status();
} else {
status = HttpStatus.UNKNOWN;
}
tags.add(Tag.of("httpStatus", status.codeAsText()));
return new MeterIdPrefix(name, tags);
}
代码示例来源:origin: line/armeria
private List<Tag> buildTags(RequestLog log) {
final RequestContext ctx = log.context();
final Object requestContent = log.requestContent();
String methodName = null;
if (requestContent instanceof RpcRequest) {
methodName = ((RpcRequest) requestContent).method();
}
if (methodName == null) {
final HttpHeaders requestHeaders = log.requestHeaders();
final HttpMethod httpMethod = requestHeaders.method();
if (httpMethod != null) {
methodName = httpMethod.name();
}
}
if (methodName == null) {
methodName = MoreObjects.firstNonNull(log.method().name(), "__UNKNOWN_METHOD__");
}
final List<Tag> tags = new ArrayList<>(4); // method, hostNamePattern, pathMapping, status
tags.add(Tag.of("method", methodName));
if (ctx instanceof ServiceRequestContext) {
final ServiceRequestContext sCtx = (ServiceRequestContext) ctx;
tags.add(Tag.of("hostnamePattern", sCtx.virtualHost().hostnamePattern()));
tags.add(Tag.of("pathMapping", sCtx.pathMapping().meterTag()));
}
return tags;
}
};
代码示例来源:origin: reactor/reactor-core
.map(tuple -> Tag.of(tuple.getT1(), tuple.getT2()))
.collect(Collectors.toList());
代码示例来源:origin: reactor/reactor-core
commonTags.add(Tag.of(FluxMetrics.TAG_SEQUENCE_NAME, sequenceName));
commonTags.add(Tag.of(FluxMetrics.TAG_SEQUENCE_TYPE, FluxMetrics.TAGVALUE_MONO));
commonTags.addAll(sequenceTags);
代码示例来源:origin: reactor/reactor-core
commonTags.add(Tag.of(TAG_SEQUENCE_NAME, sequenceName));
commonTags.add(Tag.of(TAG_SEQUENCE_TYPE, TAGVALUE_FLUX));
commonTags.addAll(sequenceTags);
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
/**
* Creates a {@code method} tag based on the {@link HttpServletRequest#getMethod()
* method} of the given {@code request}.
* @param request the request
* @return the method tag whose value is a capitalized method (e.g. GET).
*/
public static Tag method(HttpServletRequest request) {
return (request != null) ? Tag.of("method", request.getMethod()) : METHOD_UNKNOWN;
}
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
/**
* Creates a {@code status} {@code Tag} derived from the
* {@link ClientHttpResponse#getRawStatusCode() status} of the given {@code response}.
* @param response the response
* @return the status tag
*/
public static Tag status(ClientHttpResponse response) {
return Tag.of("status", getStatusMessage(response));
}
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
private Tag parseTag(String tag) {
String[] parts = tag.split(":", 2);
if (parts.length != 2) {
throw new InvalidEndpointRequestException(
"Each tag parameter must be in the form 'key:value' but was: " + tag,
"Each tag parameter must be in the form 'key:value'");
}
return Tag.of(parts[0], parts[1]);
}
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
/**
* Creates a {@code uri} {@code Tag} from the given {@code uriTemplate}.
* @param uriTemplate the template
* @return the uri tag
*/
public static Tag uri(String uriTemplate) {
String uri = (StringUtils.hasText(uriTemplate) ? uriTemplate : "none");
return Tag.of("uri", ensureLeadingSlash(stripUri(uri)));
}
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
/**
* Creates a {@code method} {@code Tag} for the {@link ClientHttpRequest#getMethod()
* method} of the given {@code request}.
* @param request the request
* @return the method tag
*/
public static Tag method(ClientRequest request) {
return Tag.of("method", request.method().name());
}
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
/**
* Creates a {@code method} tag based on the
* {@link org.springframework.http.server.reactive.ServerHttpRequest#getMethod()
* method} of the {@link ServerWebExchange#getRequest()} request of the given
* {@code exchange}.
* @param exchange the exchange
* @return the method tag whose value is a capitalized method (e.g. GET).
*/
public static Tag method(ServerWebExchange exchange) {
return Tag.of("method", exchange.getRequest().getMethodValue());
}
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
/**
* Creates a {@code uri} {@code Tag} for the URI of the given {@code request}.
* @param request the request
* @return the uri tag
*/
public static Tag uri(HttpRequest request) {
return Tag.of("uri", ensureLeadingSlash(stripUri(request.getURI().toString())));
}
代码示例来源:origin: rsocket/rsocket-java
@DisplayName("requestResponse gathers metrics")
@Test
void requestResponse() {
Payload payload = DefaultPayload.create("test-metadata", "test-data");
when(delegate.requestResponse(payload)).thenReturn(Mono.empty());
new MicrometerRSocket(delegate, meterRegistry, Tag.of("test-key", "test-value"))
.requestResponse(payload)
.as(StepVerifier::create)
.verifyComplete();
assertThat(findTimer("request.response", SignalType.ON_COMPLETE).count()).isEqualTo(1);
}
代码示例来源:origin: rsocket/rsocket-java
@DisplayName("metadataPush gathers metrics")
@Test
void metadataPush() {
Payload payload = DefaultPayload.create("test-metadata", "test-data");
when(delegate.metadataPush(payload)).thenReturn(Mono.empty());
new MicrometerRSocket(delegate, meterRegistry, Tag.of("test-key", "test-value"))
.metadataPush(payload)
.as(StepVerifier::create)
.verifyComplete();
assertThat(findCounter("metadata.push", SignalType.ON_COMPLETE).count()).isEqualTo(1);
}
代码示例来源:origin: rsocket/rsocket-java
@DisplayName("fireAndForget gathers metrics")
@Test
void fireAndForget() {
Payload payload = DefaultPayload.create("test-metadata", "test-data");
when(delegate.fireAndForget(payload)).thenReturn(Mono.empty());
new MicrometerRSocket(delegate, meterRegistry, Tag.of("test-key", "test-value"))
.fireAndForget(payload)
.as(StepVerifier::create)
.verifyComplete();
assertThat(findCounter("request.fnf", SignalType.ON_COMPLETE).count()).isEqualTo(1);
}
代码示例来源:origin: rsocket/rsocket-java
@DisplayName("requestChannel gathers metrics")
@Test
void requestChannel() {
Mono<Payload> payload = Mono.just(DefaultPayload.create("test-metadata", "test-data"));
when(delegate.requestChannel(payload)).thenReturn(Flux.empty());
new MicrometerRSocket(delegate, meterRegistry, Tag.of("test-key", "test-value"))
.requestChannel(payload)
.as(StepVerifier::create)
.verifyComplete();
assertThat(findCounter("request.channel", SignalType.ON_COMPLETE).count()).isEqualTo(1);
}
代码示例来源:origin: rsocket/rsocket-java
@DisplayName("requestStream gathers metrics")
@Test
void requestStream() {
Payload payload = DefaultPayload.create("test-metadata", "test-data");
when(delegate.requestStream(payload)).thenReturn(Flux.empty());
new MicrometerRSocket(delegate, meterRegistry, Tag.of("test-key", "test-value"))
.requestStream(payload)
.as(StepVerifier::create)
.verifyComplete();
assertThat(findCounter("request.stream", SignalType.ON_COMPLETE).count()).isEqualTo(1);
}
内容来源于网络,如有侵权,请联系作者删除!