Java Code Examples for com.linecorp.armeria.common.metric.MoreMeters#newTimer()
The following examples show how to use
com.linecorp.armeria.common.metric.MoreMeters#newTimer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Subscriber.java From curiostack with MIT License | 5 votes |
public Subscriber( @Provided SubscriberStub stub, @Provided Optional<MeterRegistry> meterRegistry, @Provided Tracing tracing, SubscriberOptions options) { this.stub = options.getUnsafeWrapBuffers() ? Clients.newDerivedClient( stub, GrpcClientOptions.UNSAFE_WRAP_RESPONSE_BUFFERS.newValue(true)) : stub; this.options = options; MeterRegistry registry = meterRegistry.orElse(NoopMeterRegistry.get()); List<Tag> tags = ImmutableList.of(Tag.of("subscription", options.getSubscription())); receivedMessages = registry.counter("subscriber-received-messages", tags); ackedMessages = registry.counter("subscriber-acked-messages", tags); nackedMessages = registry.counter("subscriber-nacked-messages", tags); registry.gauge("reconnect-backoff-millis", tags, streamReconnectBackoff, Duration::toMillis); messageProcessingTime = MoreMeters.newTimer(registry, "subscriber-message-processing-time", tags); tracer = tracing.tracer(); traceExtractor = tracing .propagation() .extractor((message, key) -> message.getAttributesOrDefault(key, null)); }
Example 2
Source File: Http2ClientConnectionHandler.java From armeria with Apache License 2.0 | 5 votes |
Http2ClientConnectionHandler(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings, Channel channel, HttpClientFactory clientFactory, SessionProtocol protocol) { super(decoder, encoder, initialSettings); this.clientFactory = clientFactory; if (clientFactory.idleTimeoutMillis() > 0 || clientFactory.pingIntervalMillis() > 0) { final Timer keepAliveTimer = MoreMeters.newTimer(clientFactory.meterRegistry(), "armeria.client.connections.lifespan", ImmutableList.of(Tag.of("protocol", protocol.uriText()))); keepAliveHandler = new Http2ClientKeepAliveHandler( channel, encoder.frameWriter(), keepAliveTimer, clientFactory.idleTimeoutMillis(), clientFactory.pingIntervalMillis()); } else { keepAliveHandler = null; } responseDecoder = new Http2ResponseDecoder(channel, encoder(), clientFactory, keepAliveHandler); connection().addListener(responseDecoder); decoder().frameListener(responseDecoder); // Setup post build options final long timeout = clientFactory.idleTimeoutMillis(); if (timeout > 0) { gracefulShutdownTimeoutMillis(timeout); } else { // Timeout disabled gracefulShutdownTimeoutMillis(-1); } }
Example 3
Source File: KeepAliveHandlerTest.java From armeria with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { channel = spy(new EmbeddedChannel()); when(channel.eventLoop()).thenReturn(eventLoop.get()); ctx = mock(ChannelHandlerContext.class); when(ctx.channel()).thenReturn(channel); meterRegistry = new SimpleMeterRegistry(); keepAliveTimer = MoreMeters.newTimer(meterRegistry, CONNECTION_LIFETIME, ImmutableList.of()); }
Example 4
Source File: HttpServerPipelineConfigurator.java From armeria with Apache License 2.0 | 4 votes |
private Timer newKeepAliveTimer(SessionProtocol protocol) { return MoreMeters.newTimer(config.meterRegistry(), "armeria.server.connections.lifespan", ImmutableList.of(Tag.of("protocol", protocol.uriText()))); }