Skip to content
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

Add tests to verify that every config setting for each auto-configured meter registry is exposed as a configuration property #33743

Closed
wants to merge 4 commits into from

Conversation

msobeck
Copy link
Contributor

@msobeck msobeck commented Jan 10, 2023

Closes #30901.

I added the missing PropertiesConfigAdapterTests and enhanced them, so that newly added
fields to micrometer configs, that are not settable via properties, will let the test fail. (if you don't specifically exclude them)

Not overridden default methods in adapters are the most common cause of forgotten field exposure in this scenario, because they do not for force an override in the adapter. (see #30898)

TestConfigsToPropertiesExposure will check for not overridden config default methods in the adapter class.
This can be an indicator for micrometer config fields, that have been forgotten to expose via properties.
They already have found some not exposed config fields f.e. for AtlasConfig:

@Test
void allConfigDefaultMethodsAreOverriddenByAdapter() {
	assertThatAllConfigDefaultMethodsAreOverriddenByAdapter(AtlasConfig.class, AtlasPropertiesConfigAdapter.class,
			"lwcIgnorePublishStep",
			"initialPollingDelay",
			"autoStart",
			"lwcStep",
			"validTagCharacters");
}

I declared them as excluded, because i don't know if they are intentionally not exposed.
Someone could look at this in another task. This PR only shows the current state.
I am aware that these tests are just a rough help against human forgetfulness and can be reverted if they don't fit in.

@pivotal-cla
Copy link

@msobeck Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@msobeck msobeck changed the title Pr/30901 Add tests to verify that every config setting for each auto-configured meter registry is exposed as a configuration property Jan 10, 2023
@pivotal-cla
Copy link

@msobeck Thank you for signing the Contributor License Agreement!

@msobeck
Copy link
Contributor Author

msobeck commented Feb 21, 2023

@wilkinsona thanks for the review! Is there anything left in this PR? Otherwise I would suggest to close this one, since the missing tests were added in ff04f00.

wilkinsona pushed a commit to wilkinsona/spring-boot that referenced this pull request Feb 21, 2023
wilkinsona added a commit to wilkinsona/spring-boot that referenced this pull request Feb 21, 2023
@wilkinsona
Copy link
Member

wilkinsona commented Feb 21, 2023

Yeah, there's quite a bit left. ff04f00 didn't include any of the changes to verify that each config setting has a property. That's what we'll merge in this PR. I'm in the process of polishing those changes: https://github.com/wilkinsona/spring-boot/tree/gh-33743.

@wilkinsona wilkinsona added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 21, 2023
@wilkinsona wilkinsona added this to the 2.7.x milestone Feb 21, 2023

}

private static final List<Class<?>> classesForPropertiesList = List.of(Boolean.class, Byte.class, Character.class,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add Enum too?
We have quite a few use-cases, e.g.: HistogramFlavor for PrometheusConfig or DynatraceApiVersion for DynatraceConfig

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a look, @jonatan-ivanov. I've removed the allow-list approach in my polishing. We now consider all default methods with no parameters, except those that are deprecated or that return Validated. The code that does that is here.

@jonatan-ivanov
Copy link
Member

I really like the idea of having verifications for this, thank you!

wilkinsona pushed a commit to wilkinsona/spring-boot that referenced this pull request Jul 24, 2023
wilkinsona added a commit to wilkinsona/spring-boot that referenced this pull request Jul 24, 2023
wilkinsona added a commit to wilkinsona/spring-boot that referenced this pull request Jul 24, 2023
* spring-projectsgh-33743:
  Polish "Test Micrometer config to property exposure"
  Test Micrometer config to property exposure

Closes spring-projectsgh-33743
@wilkinsona wilkinsona modified the milestones: 2.7.x, 2.7.15 Jul 25, 2023
wilkinsona pushed a commit that referenced this pull request Jul 25, 2023
@wilkinsona
Copy link
Member

Thanks very much, @msobeck.

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