class GraphQLBeanPostProcessor implements BeanPostProcessor, ApplicationContextAware {

  @Override
  public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (bean instanceof GraphQLApiType) {
      MeterRegistry registry = applicationContext.getBean(MeterRegistry.class);
      Class<?>[] interfaces = bean.getClass().getInterfaces();
      GraphQLMetricHandler handler = new GraphQLMetricHandler(bean, registry);
      log.debug("Proxying {} with GraphQLMetricHandler", beanName);
      bean = newProxyInstance(GraphQLMetricHandler.class.getClassLoader(), interfaces, handler);
    }
    return bean;
  }

}