class GraphQLMetricHandler implements InvocationHandler {

  @Override
  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    boolean success = false;
    Stopwatch stopwatch = Stopwatch.createStarted();
    try {
      Object result = method.invoke(delegate, args);
      success = true;
      return result;
    } catch (InvocationTargetException e) {
      if (e.getCause() != null) {
        throw e.getCause();
      }
      throw e;
    } finally {
      Tags tags = Tags
          .of("api", method.getDeclaringClass().getSimpleName())
          .and("method", method.getName())
          .and("result", success ? "success" : "failure")
          .and("authentication_group", AuthenticationGroup.of(authenticationSupplier.get()).name());
      registry.timer("graphql_api", tags).record(stopwatch.elapsed());
    }
  }

  public  GraphQLMetricHandler(Object delegate, MeterRegistry registry);

}