newrelic / dropwizard-metrics-newrelic

Implementation of a DropWizard metrics Reporter that sends data as dimensional metrics to New Relic
Apache License 2.0
5 stars 15 forks source link

NR Dropwizard reporter should start from the project .yml file #112

Open kanderson250 opened 11 months ago

kanderson250 commented 11 months ago

Description

A user noticed that they were unable to start the NewRelicReporter from the project .yml config file after upgrading to Dropwizard v4.0.1. They are using the Dropwizard REST framework and running the .yml file on server startup (see below for reproduction steps.) They saw the error with versions 0.8.0 and 1.0.0 of the dropwizard-metrics-newrelic project.

Reproduced error message:

io.dropwizard.configuration.ConfigurationParsingException: example.yml has an error:
  * Failed to parse configuration at: metrics.reporters.[0]; Could not resolve type id 'newrelic' as a subtype of `io.dropwizard.metrics.common.ReporterFactory`: known type ids = [console, csv, graphite, log] (for POJO property 'reporters')
 at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: com.example.helloworld.HelloWorldConfiguration["metrics"]->io.dropwizard.metrics.common.MetricsFactory["reporters"]->java.util.ArrayList[0])

    at io.dropwizard.configuration.ConfigurationParsingException$Builder.build(ConfigurationParsingException.java:277)
    at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:177)
    at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:94)
    at io.dropwizard.core.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:139)
    at io.dropwizard.core.cli.ConfiguredCommand.run(ConfiguredCommand.java:85)
    at io.dropwizard.core.cli.Cli.run(Cli.java:78)
    at io.dropwizard.core.Application.run(Application.java:94)
    at com.example.helloworld.HelloWorldApplication.main(HelloWorldApplication.java:73)
Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'newrelic' as a subtype of `io.dropwizard.metrics.common.ReporterFactory`: known type ids = [console, csv, graphite, log] (for POJO property 'reporters')
 at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: com.example.helloworld.HelloWorldConfiguration["metrics"]->io.dropwizard.metrics.common.MetricsFactory["reporters"]->java.util.ArrayList[0])
    at com.fasterxml.jackson.databind.exc.InvalidTypeIdException.from(InvalidTypeIdException.java:43)
    at com.fasterxml.jackson.databind.DeserializationContext.invalidTypeIdException(DeserializationContext.java:2084)
    at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownTypeId(DeserializationContext.java:1575)
    at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._handleUnknownTypeId(TypeDeserializerBase.java:298)
    at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._findDeserializer(TypeDeserializerBase.java:165)
    at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:151)
    at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:136)
    at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:263)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:361)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28)
    at com.fasterxml.jackson.module.blackbird.deser.SettableObjectProperty.deserializeAndSet(SettableObjectProperty.java:44)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:278)
    at com.fasterxml.jackson.module.blackbird.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:155)
    at com.fasterxml.jackson.module.blackbird.deser.SettableObjectProperty.deserializeAndSet(SettableObjectProperty.java:44)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:278)
    at com.fasterxml.jackson.module.blackbird.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:155)
    at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
    at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:4801)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2974)
    at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:148)
    ... 6 more

Steps to reproduce

Acceptance Criteria

The New Relic reporter should be able to start from the Dropwizard config file without error.

Temporary Workaround

Until this issue is resolved, users can start and configure the NewRelicReporter in-code as described in the documentation of this project: starting the New Relic reporter

workato-integration[bot] commented 11 months ago

https://new-relic.atlassian.net/browse/NR-181277