Skip to content

feat(spring): Boot 4 embedded test database and sampled-only SQL comments#241

Merged
zantvoort merged 1 commit into
mainfrom
feat/113-polish
Jul 12, 2026
Merged

feat(spring): Boot 4 embedded test database and sampled-only SQL comments#241
zantvoort merged 1 commit into
mainfrom
feat/113-polish

Conversation

@zantvoort

Copy link
Copy Markdown
Collaborator

Two polish items surfaced by running the example applications on Spring Boot 4.

Fixes #238
Fixes #239

@DataStormTest: embedded test database on Spring Boot 4 (#238)

Spring Boot 3 replaces the application's DataSource with an embedded database through its own TestDatabaseAutoConfiguration, which the slice imports. Spring Boot 4 relocated that behavior to the separate spring-boot-jdbc-test-autoconfigure artifact, so Boot 4 slice tests needed manual datasource properties.

The slice now ships a fallback auto-configuration, triple-gated: it activates only when Boot's own replacement is absent (class condition on both its locations), an embedded driver is on the test classpath, and spring.test.database.replace is not none (the Testcontainers opt-out). Ordered before the DataSource auto-configuration, whose back-off then applies naturally. Inert on Boot 3 by construction.

Trace-context SQL comments: sampled-only mode (#239)

With sampling below 1.0, commenting every statement pays the prepared-statement-caching cost on all statements for comments that correlate to an exported trace only in the sampled fraction. TraceContextSqlCommenter(tracer, onlySampled) comments only statements of sampled traces; in the starters, storm.tracing.sql-comments accepts sampled alongside true, and unknown values fail startup with a descriptive error.

Docs

The Boot 3/4 asymmetry paragraph in the slice docs collapses to one sentence; the sql-comments docs recommend sampled under partial sampling; and a new composition warning covers the @ConditionalOnBean trap: conditions in user @Configuration classes evaluate before auto-configurations contribute their beans (such as the Tracer) and fail silently — integration beans in user configurations should be unconditional.

Verification

  • Full reactor green (13,758 tests).
  • The decisive Boot 4 proof: both example applications' @DataStormTest classes (Spring Boot 4.1) pass with their manual datasource properties deleted, running entirely on the new fallback. Boot 3 verified inert through the module's own suite.
  • New tests: sampled-only skips unsampled spans while the default mode comments them; starter accepts sampled and fails fast on unknown values.

…ents

Two polish items surfaced by running the example applications on
Spring Boot 4.

- @DataStormTest provides an embedded test database on Spring Boot 4:
  a fallback auto-configuration in the slice activates only when Boot's
  own test-database replacement is absent (relocated to
  spring-boot-jdbc-test-autoconfigure in Boot 4), an embedded driver is
  on the test classpath, and spring.test.database.replace is not none.
  Ordered before the DataSource auto-configuration, whose back-off then
  applies naturally; inert on Boot 3. Slice tests behave identically on
  both generations without manual datasource properties.
- Trace-context SQL comments gain a sampled-only mode:
  TraceContextSqlCommenter(tracer, onlySampled) comments only
  statements of sampled traces, aligning the prepared-statement-caching
  cost with the correlation benefit when sampling is below 1.0. In the
  starters, storm.tracing.sql-comments accepts true or sampled, and
  unknown values fail startup with a descriptive error.

The docs also gain a composition warning: integration beans in user
configurations must be unconditional, because @ConditionalOnBean in a
plain @configuration evaluates before auto-configurations contribute
their beans and fails silently.

Fixes #238
Fixes #239
@zantvoort zantvoort merged commit c19cee3 into main Jul 12, 2026
7 checks passed
@zantvoort zantvoort deleted the feat/113-polish branch July 12, 2026 09:14
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.

Trace-context SQL comments: sampled-only mode @DataStormTest: embedded database fallback on Spring Boot 4

1 participant