I have something working for what my team built on top on Netty4 to support mainly Restful endpoints - it can't be used in Netty as is, but I'll outline what I did:
I am using Codahale metrics (core, jvm and graphite jars) and a MetricsEvent extensible enum (that currently only has these 3 events REQUEST_RECEIVED, RESPONSE_SENT, RESPONSE_WRITE_FAILED).
I have a MetricsCollector that has this method void onEvent(MetricsEvent event, Object value)
and based on these 3 events and the object (in my case the object is a request state object I created and that I keep on the ChannelHandlerContext as an attribute to hold state all along the channel pipeline) I capture these metrics about the app and about the endpoints exposed:
- JVM metrics: gc, buffers, memory, threads
- App config properties;
- Counter inflightRequests;
- Counter processedRequests;
- Counter failedRequests;
- Counter responseWriteFailed;
- Histogram responseSizes;
- Histogram requestSizes;
- Timer getRequests;
- Timer postRequests;
- Timer putRequests;
- Timer deleteRequests;
- Timer otherRequests;
- Timer requests;
- Meter[] responses; // 1xx, 2xx, 3xx, 4xx, 5xx
- Map<String, Timer> restEndpointRequestsTimers; // API endpoints by matching path
- Map<String, Meter[]> restEndpointResponsesMeters; // API endpoints by matching path and 1xx, 2xx, 3xx, 4xx, 5xx for each endpoint
Cheers,
Florin