@Inject public EventLoopGroupMetrics(Registry registry) { this.registry = registry; this.metricsForCurrentThread = ThreadLocal.withInitial(() -> { String name = nameForCurrentEventLoop(); EventLoopMetrics metrics = new EventLoopMetrics(registry, name); byEventLoop.put(Thread.currentThread(), metrics); return metrics; }); }
public Map<Thread, Integer> connectionsPerEventLoop() { Map<Thread, Integer> map = new HashMap<>(byEventLoop.size()); for (Map.Entry<Thread, EventLoopMetrics> entry : byEventLoop.entrySet()) { map.put(entry.getKey(), entry.getValue().currentConnectionsCount()); } return map; }
public Map<Thread, Integer> httpRequestsPerEventLoop() { Map<Thread, Integer> map = new HashMap<>(byEventLoop.size()); for (Map.Entry<Thread, EventLoopMetrics> entry : byEventLoop.entrySet()) { map.put(entry.getKey(), entry.getValue().currentHttpRequestsCount()); } return map; }
public void decrementCurrentConnections() { int value = this.currentConnections.decrementAndGet(); updateGauge(currentConnectionsId, value); }
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { groupMetrics.getForCurrentEventLoop().incrementCurrentConnections(); super.channelActive(ctx); }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { try { super.channelInactive(ctx); } finally { groupMetrics.getForCurrentEventLoop().decrementCurrentConnections(); } } }
private void decrementCurrentRequestsIfOneInflight(ChannelHandlerContext ctx) { if (ctx.channel().attr(ATTR_REQ_INFLIGHT).getAndRemove() != null) { groupMetrics.getForCurrentEventLoop().decrementCurrentRequests(); } } }
private void incrementCurrentRequestsInFlight(ChannelHandlerContext ctx) { groupMetrics.getForCurrentEventLoop().incrementCurrentRequests(); ctx.channel().attr(ATTR_REQ_INFLIGHT).set(INFLIGHT); }
public void incrementCurrentRequests() { int value = this.currentRequests.incrementAndGet(); updateGauge(currentRequestsId, value); }
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { groupMetrics.getForCurrentEventLoop().incrementCurrentConnections(); super.channelActive(ctx); }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { try { super.channelInactive(ctx); } finally { groupMetrics.getForCurrentEventLoop().decrementCurrentConnections(); } } }
private void decrementCurrentRequestsIfOneInflight(ChannelHandlerContext ctx) { if (ctx.channel().attr(ATTR_REQ_INFLIGHT).getAndRemove() != null) { groupMetrics.getForCurrentEventLoop().decrementCurrentRequests(); } } }
private void incrementCurrentRequestsInFlight(ChannelHandlerContext ctx) { groupMetrics.getForCurrentEventLoop().incrementCurrentRequests(); ctx.channel().attr(ATTR_REQ_INFLIGHT).set(INFLIGHT); }
public void decrementCurrentRequests() { int value = this.currentRequests.decrementAndGet(); updateGauge(currentRequestsId, value); }
@Inject public EventLoopGroupMetrics(Registry registry) { this.registry = registry; this.metricsForCurrentThread = ThreadLocal.withInitial(() -> { String name = nameForCurrentEventLoop(); EventLoopMetrics metrics = new EventLoopMetrics(registry, name); byEventLoop.put(Thread.currentThread(), metrics); return metrics; }); }
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { groupMetrics.getForCurrentEventLoop().incrementCurrentConnections(); super.channelActive(ctx); }
public Map<Thread, Integer> httpRequestsPerEventLoop() { Map<Thread, Integer> map = new HashMap<>(byEventLoop.size()); for (Map.Entry<Thread, EventLoopMetrics> entry : byEventLoop.entrySet()) { map.put(entry.getKey(), entry.getValue().currentHttpRequestsCount()); } return map; }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { try { super.channelInactive(ctx); } finally { groupMetrics.getForCurrentEventLoop().decrementCurrentConnections(); } } }
private void decrementCurrentRequestsIfOneInflight(ChannelHandlerContext ctx) { if (ctx.channel().attr(ATTR_REQ_INFLIGHT).getAndRemove() != null) { groupMetrics.getForCurrentEventLoop().decrementCurrentRequests(); } } }
private void incrementCurrentRequestsInFlight(ChannelHandlerContext ctx) { groupMetrics.getForCurrentEventLoop().incrementCurrentRequests(); ctx.channel().attr(ATTR_REQ_INFLIGHT).set(INFLIGHT); }