@Override
  public void filter(final ContainerRequestContext requestContext) throws IOException {
    try {
      Metrics.summary(CONTENT_LENGTH_DISTRIBUTION_NAME, TRAFFIC_SOURCE_TAG, trafficSourceTag)
          .record(requestContext.getLength());
      Metrics.counter(IP_VERSION_METRIC, TRAFFIC_SOURCE_TAG, trafficSourceTag, IP_VERSION_TAG,
              resolveIpVersion(requestContext))
          .increment();
    } catch (final Exception e) {
      logger.warn("Error recording request statistics", e);
    }
  }
@Test
  void testFilter() throws Exception {

    final RequestStatisticsFilter requestStatisticsFilter = new RequestStatisticsFilter(TrafficSource.WEBSOCKET);

    final ContainerRequestContext requestContext = mock(ContainerRequestContext.class);

    when(requestContext.getLength()).thenReturn(-1);
    when(requestContext.getLength()).thenReturn(Integer.MAX_VALUE);
    when(requestContext.getLength()).thenThrow(RuntimeException.class);

    requestStatisticsFilter.filter(requestContext);
    requestStatisticsFilter.filter(requestContext);
    requestStatisticsFilter.filter(requestContext);
  }