newrelic / micrometer-registry-newrelic

ARCHIVED. TO SEND MICROMETER METRICS TO NEW RELIC, FOLLOW THE DIRECTION IN THE README.md. Micrometer registry implementation that sends data to New Relic as dimensional metrics.
Apache License 2.0
35 stars 19 forks source link

Failed to load ApplicationContext after update to 1.4.0 #72

Closed tloszabno closed 4 years ago

tloszabno commented 4 years ago

I use spring boot 2.2.5-RELEASE, after update a micrometer-registry-new-relic from 1.3.5 to 1.4.0 my application does not start.

Stacktrace:


Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'newRelicMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicMetricsExportAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.micrometer.newrelic.NewRelicMeterRegistry]: Factory method 'newRelicMeterRegistry' threw exception; nested exception is java.lang.NoSuchMethodError: 'io.micrometer.newrelic.NewRelicMeterRegistry$Builder io.micrometer.newrelic.NewRelicMeterRegistry$Builder.httpClient(io.micrometer.core.ipc.http.HttpSender)'
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789)
    ... 193 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.micrometer.newrelic.NewRelicMeterRegistry]: Factory method 'newRelicMeterRegistry' threw exception; nested exception is java.lang.NoSuchMethodError: 'io.micrometer.newrelic.NewRelicMeterRegistry$Builder io.micrometer.newrelic.NewRelicMeterRegistry$Builder.httpClient(io.micrometer.core.ipc.http.HttpSender)'
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651)
    ... 207 more
Caused by: java.lang.NoSuchMethodError: 'io.micrometer.newrelic.NewRelicMeterRegistry$Builder io.micrometer.newrelic.NewRelicMeterRegistry$Builder.httpClient(io.micrometer.core.ipc.http.HttpSender)'
    at org.springframework.boot.actuate.autoconfigure.metrics.export.newrelic.NewRelicMetricsExportAutoConfiguration.newRelicMeterRegistry(NewRelicMetricsExportAutoConfiguration.java:71)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 208 more

It seems that you removed the method which is used by spring boot in autoconfiguration for plugin. Backward compatibility is broken now:
NewRelicMetricsExportAutoConfiguration:

@Bean
  @ConditionalOnMissingBean
  public NewRelicMeterRegistry newRelicMeterRegistry(NewRelicConfig newRelicConfig, Clock clock) {
    return NewRelicMeterRegistry.builder(newRelicConfig).clock(clock).httpClient(new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout())).build();
  }
jkwatson commented 4 years ago

Thanks for the bug report. We'll take a look at this very soon. If you have an easy fix for it, we welcome contributions!

jkwatson commented 4 years ago

@tloszabno If you're using the registry from here: https://github.com/micrometer-metrics/micrometer/tree/master/implementations/micrometer-registry-new-relic, that one is not supported by New Relic. We recommend you switch over to this official registry, which exports the metrics as dimensional metrics, rather than custom events.

If you need continued support for the other one, please log a bug in the micrometer project itself.

Thanks!

tloszabno commented 4 years ago

So I reported the bug to lib I am not using.... sorry, my bad. I will report that bug to that guys also. I will consider switching. Thanks!

jkwatson commented 4 years ago

@tloszabno no worries! When you're ready to switch to using dimensional metrics, we'd love to help you get started with it, so please reach out if help is needed!