Skip to content

feat: Spring Boot starter + integration tests (Part 4)#333

Merged
heruan merged 15 commits into
micrometerfrom
feat/micrometer-starter
Jun 9, 2026
Merged

feat: Spring Boot starter + integration tests (Part 4)#333
heruan merged 15 commits into
micrometerfrom
feat/micrometer-starter

Conversation

@heruan

@heruan heruan commented Jun 9, 2026

Copy link
Copy Markdown
Member

Closes #328.

Final part of the Micrometer rewrite: the Spring Boot starter plus the remaining integration tests (plain-Spring and Boot/Prometheus). The standalone IT already landed in #330; this part renames it into the shared scheme and adds the rest.

Spring Boot starter (observability-kit-starter)

  • ObservabilityAutoConfiguration@AutoConfiguration ordered after Boot's MetricsAutoConfiguration / CompositeMeterRegistryAutoConfiguration; gated by @ConditionalOnClass({MeterRegistry, VaadinService}) and @ConditionalOnProperty("vaadin.observability.enabled", matchIfMissing = true). Registers the ObservabilitySettings bean (@ConditionalOnMissingBean) and the listener (@ConditionalOnBean(MeterRegistry) + @ConditionalOnMissingBean).
  • ObservabilityProperties@ConfigurationProperties("vaadin.observability"); toSettings() maps every flag except enabled.
  • Reuses the public SpringMetricsServiceInitListener, extracted from ObservabilityConfiguration in observability-kit-spring so plain-Spring and Boot share one listener.
  • ApplicationContextRunner unit tests (AssertJ): default-on registers beans, enabled=false disables, property binding honored, user @ConditionalOnMissingBean overrides respected, no-MeterRegistry ⇒ no listener.

Integration tests (under the observability-kit-tests aggregator)

  • observability-kit-tests-common — shared AbstractIT (+ DriverSupplier) as a jar, consumed test-scope.
  • observability-kit-tests-micrometer — the standalone IT from test: add it tests for micrometer core #330, renamed into the scheme (pkg com.vaadin.observability.tests.micrometer) and refactored onto the shared base.
  • observability-kit-tests-spring — plain-Spring MVC WAR on Jetty; scrapes /metrics; asserts vaadin.sessions.created / vaadin.ui.created / vaadin.sessions.active / vaadin.request.duration. maven-enforcer bans org.springframework.boot.
  • observability-kit-tests-starter — Spring Boot + Prometheus on Jetty (Tomcat excluded); scrapes /actuator/prometheus; asserts the Prometheus-renamed vaadin_sessions_total / vaadin_ui_total / vaadin_sessions_active / vaadin_request_duration_seconds.

All IT modules use com.vaadin.observability.tests.<flavor> packages and the agreed observability-kit-tests-* naming.

Notes

  • Fixed an inconsistency surfaced in review: plain-Spring bound the session-id traces flag from the dotted vaadin.observability.traces.session-id, while the Boot starter and the design use the flat vaadin.observability.traces-session-id. Both now use the flat key.
  • Supersedes test: add it tests for micrometer spring #332, which adds an overlapping plain-Spring IT on the pre-rename aggregator; that PR can be closed once this lands.
  • Verified locally: mvn spotless:check install -DskipIt green across the production reactor; full reactor (9 modules) resolves. Browser ITs run in CI.

heruan added 12 commits June 9, 2026 11:21
…shared test base

- Aggregator artifactId: observability-kit-micrometer-test → observability-kit-tests
- New observability-kit-test-common (jar) with AbstractIT in pkg
  com.vaadin.observability.tests.common; compile-scope testbench deps
- Standalone IT dir renamed to observability-kit-tests-micrometer,
  artifactId observability-kit-tests-micrometer, pkg
  com.vaadin.observability.tests.micrometer; depends on test-common
…ests-common

Align the shared IT base module with the agreed observability-kit-tests-*
naming scheme (it was the lone module still using the singular 'test-'
prefix). Updates the directory, artifactId, aggregator module entry, and
the three dependent test poms.
ObservabilityConfiguration bound the session-id traces flag from the
dotted key vaadin.observability.traces.session-id, the lone non-flat key
in the module. The Boot starter binds the same flag from the flat
vaadin.observability.traces-session-id (the canonical key in the design
spec), so a user copying properties between the two flavours would have
the setting silently dropped. Switch the plain-Spring @value to the flat
key so both modules and the spec agree.
The unique value isolates the shutdown handshake, not the HTTP listen
port (which stays Jetty's default 8080); the reactor runs IT modules
sequentially.
@heruan heruan self-assigned this Jun 9, 2026
heruan added 2 commits June 9, 2026 13:46
…ut of the box

observability-kit-starter only attached to a pre-existing MeterRegistry;
it never set Micrometer up, so the kit was not a real Micrometer starter
— users had to wire metrics themselves. Depend on Boot's
spring-boot-starter-micrometer-metrics (compile) so MetricsAutoConfiguration
+ CompositeMeterRegistryAutoConfiguration are present: a MeterRegistry is
wired out of the box and the Vaadin instrumentation activates with no
further setup. The registry backend (Prometheus, OTLP, ...) and Actuator
endpoint exposure remain the application's choice.

With those autoconfig classes now guaranteed on the classpath, switch
@autoConfiguration(afterName = {strings}) to the type-safe
after = {MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class}.

Drop the unused optional spring-boot-actuator-autoconfigure dependency
(the starter references no actuator types). Add an ApplicationContextRunner
test asserting that with the metrics autoconfig present and no
hand-supplied registry, both a MeterRegistry and the listener appear.
- Use a descriptive withFailMessage on the request-duration .contains
  assertions (BootMetricsIT, SpringMetricsIT) so a failure reports what
  was missing instead of dumping the whole scrape body (caalador review).
- Switch both ITs to static AssertJ imports (assertThat), matching the
  unit test and the project's test conventions.
@heruan heruan merged commit 133edce into micrometer Jun 9, 2026
2 checks passed
@heruan heruan deleted the feat/micrometer-starter branch June 9, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants