Skip to content

MetricsFilter can't be disabled #4365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bohrqiu opened this issue Nov 2, 2015 · 5 comments
Closed

MetricsFilter can't be disabled #4365

bohrqiu opened this issue Nov 2, 2015 · 5 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@bohrqiu
Copy link
Contributor

bohrqiu commented Nov 2, 2015

when set endpoints.metrics.filter.enabled=false, exception was throwed:

Exception in thread "Main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metricsEndpoint': Could not bind properties to MetricsEndpoint (prefix=endpoints.metrics, ignoreInvalidFields=false, ignoreUnknownFields=false, ignoreNestedProperties=false); nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'filter[enabled]' of bean class [org.springframework.boot.actuate.endpoint.MetricsEndpoint]: Cannot access indexed value in property referenced in indexed property path 'filter[enabled]'; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'filter[enabled]' of bean class [org.springframework.boot.actuate.endpoint.MetricsEndpoint]: Bean property 'filter[enabled]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:324)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:273)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:835)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:356)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
at com.yiji.boot.test.DemoApplication.main(DemoApplication.java:14)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'filter[enabled]' of bean class [org.springframework.boot.actuate.endpoint.MetricsEndpoint]: Cannot access indexed value in property referenced in indexed property path 'filter[enabled]'; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'filter[enabled]' of bean class [org.springframework.boot.actuate.endpoint.MetricsEndpoint]: Bean property 'filter[enabled]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:304)
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280)
    at org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanWrapper.setPropertyValue(RelaxedDataBinder.java:698)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)
    at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:834)
    at org.springframework.validation.DataBinder.doBind(DataBinder.java:730)
    at org.springframework.boot.bind.RelaxedDataBinder.doBind(RelaxedDataBinder.java:128)
    at org.springframework.validation.DataBinder.bind(DataBinder.java:715)
    at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:267)
    at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:240)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:319)
    ... 17 more
Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'filter[enabled]' of bean class [org.springframework.boot.actuate.endpoint.MetricsEndpoint]: Bean property 'filter[enabled]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:619)
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:301)
    ... 27 more

It seems like org.springframework.boot.actuate.endpoint.MetricsEndpoint's ConfigurationProperties annotation load it.

@snicoll
Copy link
Member

snicoll commented Nov 2, 2015

This condition looks wrong and was introduced in d0cf6b5

@snicoll snicoll self-assigned this Nov 2, 2015
@snicoll snicoll added this to the 1.3.0 milestone Nov 2, 2015
@snicoll snicoll added the type: bug A general bug label Nov 2, 2015
@snicoll snicoll modified the milestones: 1.2.8, 1.3.0 Nov 2, 2015
@snicoll
Copy link
Member

snicoll commented Nov 2, 2015

That property does not work because endpoints.metrics. is supposed to handle all that namespace and the filter.enabled property is not known.

The feature of disabling the filter is still nice though so we decided to align that to the main endpoints.metrics.enabled property.

@snicoll snicoll changed the title org.springframework.boot.actuate.autoconfigure.MetricsFilter can't be disable MetricsFilter can't be disabled Nov 3, 2015
@snicoll snicoll closed this as completed in 8c14009 Nov 3, 2015
@bohrqiu
Copy link
Contributor Author

bohrqiu commented Nov 3, 2015

thx

@wilkinsona
Copy link
Member

I don't like this change. The benefit of using two different properties was that the filter could be disabled using a property while the endpoint remained enabled. Now it's both or nothing. The alternative is to use auto-configuration exclusions but people seem to prefer the properties.

Couldn't we set ignoreUnknownFields to true or give MetricsEndpoint a filter.enabled property so that it can be bound?

@wilkinsona wilkinsona reopened this Dec 9, 2015
@wilkinsona wilkinsona added for: team-attention An issue we'd like other members of the team to review and removed for: team-attention An issue we'd like other members of the team to review labels Dec 9, 2015
@snicoll
Copy link
Member

snicoll commented Dec 9, 2015

We decided to restore the initial property and make sure it can be set by adding ignoreUnknownFields. We could revisit this change once #3445 is implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants