use of io.helidon.grpc.server.MethodDescriptor in project helidon by oracle.
the class GrpcMetricsInterceptorIT method shouldApplyTags.
@Test
public void shouldApplyTags() throws Exception {
ServiceDescriptor descriptor = ServiceDescriptor.builder(createMockService()).unary("barTags", this::dummyUnary).build();
MethodDescriptor methodDescriptor = descriptor.method("barTags");
Map<String, String> tags = Map.of("one", "t1", "two", "t2");
GrpcMetrics metrics = GrpcMetrics.counted().tags(tags);
ServerCall<String, String> call = call(metrics, methodDescriptor);
call.close(Status.OK, new Metadata());
Map<MetricID, Metric> matchingMetrics = appRegistry.get().getMetrics().entrySet().stream().filter(entry -> entry.getKey().getName().equals("Foo.barTags")).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
assertThat(matchingMetrics.size(), not(0));
Map.Entry<MetricID, Metric> match = matchingMetrics.entrySet().stream().findFirst().orElse(null);
assertVendorMetrics();
Map<String, String> expected = new HashMap<>();
expected.put("one", "t1");
expected.put("two", "t2");
/*
* We expect the tags to be on the ID in the version-neutral (and 2.0)
* metrics programming model.
*/
assertThat(match.getKey().getTags(), is(expected));
}
use of io.helidon.grpc.server.MethodDescriptor in project helidon by oracle.
the class GrpcMetricsInterceptorIT method shouldUseTimerMetric.
@Test
public void shouldUseTimerMetric() throws Exception {
ServiceDescriptor descriptor = ServiceDescriptor.builder(createMockService()).unary("barTimed", this::dummyUnary).build();
MethodDescriptor methodDescriptor = descriptor.method("barTimed");
GrpcMetrics metrics = GrpcMetrics.timed();
ServerCall<String, String> call = call(metrics, methodDescriptor);
call.close(Status.OK, new Metadata());
Timer appTimer = appRegistry.get().timer("Foo.barTimed");
assertVendorMetrics();
assertThat(appTimer.getCount(), is(1L));
}
use of io.helidon.grpc.server.MethodDescriptor in project helidon by oracle.
the class GrpcMetricsInterceptorIT method shouldUseCountedMetric.
@Test
public void shouldUseCountedMetric() throws Exception {
ServiceDescriptor descriptor = ServiceDescriptor.builder(createMockService()).unary("testCounted", this::dummyUnary).build();
MethodDescriptor methodDescriptor = descriptor.method("testCounted");
GrpcMetrics metrics = GrpcMetrics.counted();
ServerCall<String, String> call = call(metrics, methodDescriptor);
call.close(Status.OK, new Metadata());
Counter appCounter = appRegistry.get().counter("Foo.testCounted");
assertVendorMetrics();
assertThat(appCounter.getCount(), is(1L));
}
use of io.helidon.grpc.server.MethodDescriptor in project helidon by oracle.
the class GrpcMetricsInterceptorIT method shouldUseConcurrentGaugeMetric.
@Test
public void shouldUseConcurrentGaugeMetric() throws Exception {
ServiceDescriptor descriptor = ServiceDescriptor.builder(createMockService()).unary("barConcurrentGauge", this::dummyUnary).build();
MethodDescriptor methodDescriptor = descriptor.method("barConcurrentGauge");
GrpcMetrics metrics = GrpcMetrics.concurrentGauge();
ServerCall<String, String> call = call(metrics, methodDescriptor);
call.close(Status.OK, new Metadata());
ConcurrentGauge appConcurrentGauge = appRegistry.get().concurrentGauge("Foo.barConcurrentGauge");
assertVendorMetrics();
assertThat(appConcurrentGauge.getCount(), is(1L));
}
use of io.helidon.grpc.server.MethodDescriptor in project helidon by oracle.
the class GrpcMetricsInterceptorIT method shouldHaveCorrectNameWithDotsForSlashes.
@Test
public void shouldHaveCorrectNameWithDotsForSlashes() throws Exception {
ServiceDescriptor descriptor = ServiceDescriptor.builder(createMockService()).name("My/Service").unary("bar", this::dummyUnary).build();
MethodDescriptor methodDescriptor = descriptor.method("bar");
GrpcMetrics metrics = GrpcMetrics.counted();
ServerCall<String, String> call = call(metrics, descriptor, methodDescriptor);
call.close(Status.OK, new Metadata());
Counter appCounter = appRegistry.get().counter("My.Service.bar");
assertVendorMetrics();
assertThat(appCounter.getCount(), is(1L));
}
Aggregations