Skip to content

feat(auto-install): Auto-install sentry-opentelemetry-bom#266

Closed
adinauer wants to merge 1 commit into
side-quest/detect-bom-version-for-installfrom
feat/auto-install-opentelemetry-bom
Closed

feat(auto-install): Auto-install sentry-opentelemetry-bom#266
adinauer wants to merge 1 commit into
side-quest/detect-bom-version-for-installfrom
feat/auto-install-opentelemetry-bom

Conversation

@adinauer

@adinauer adinauer commented Jul 1, 2026

Copy link
Copy Markdown
Member

Builds on top of #265.

What

Auto-installs io.sentry:sentry-opentelemetry-bom to align OpenTelemetry dependency versions with the versions Sentry was tested against, whenever a project uses a Sentry OpenTelemetry integration (excluding the standalone sentry-opentelemetry-agent and the BOM itself).

Why the mechanism differs from the Gradle plugin

Maven resolves BOM imports during effective-model building, which happens before the plugin's afterProjectsRead hook. A late-injected import-scope BOM is therefore a no-op (verified experimentally). Instead the plugin:

  1. Resolves sentry-opentelemetry-bom at the managed Sentry version (via fix(auto-install): Use Sentry BOM version for installs #265's ManagedSentryVersionResolver, with SDK fallback) and expands it into concrete OpenTelemetry versions using ProjectBuilder.
  2. Applies them to the project's dependencyManagement:
    • overwrite in place OpenTelemetry versions inherited from a parent/other BOM (e.g. Spring Boot),
    • add managed entries for unmanaged OpenTelemetry artifacts,
    • skip versions the user pinned explicitly (own <dependencyManagement> or explicit direct <version>), warning when they differ from Sentry's tested version.

This wins over Spring Boot dependency management (both spring-boot-starter-parent and imported spring-boot-dependencies) without turning transitive artifacts into direct dependencies.

Config

Opt out with <skipInstallOpenTelemetryBom>true</skipInstallOpenTelemetryBom>. Adds a SENTRY_installOpenTelemetryBom telemetry tag.

Notes

  • Self-skips gracefully until sentry-opentelemetry-bom is published for the resolved Sentry version.

Tests

  • Unit: OpenTelemetryBomInstallerTest (detection, expand, skip/overwrite/add, user-pin respect + warning).
  • Integration: OpenTelemetryBomAutoInstallTestIT — Spring Boot parent alignment, transitive alignment, user-pin respect + warn, disabled flag, agent no-op, BOM-already-imported.

Co-authored with Claude.

Align OpenTelemetry dependency versions with the versions Sentry was
tested against whenever a project uses a Sentry OpenTelemetry integration
(excluding the standalone agent and the BOM itself).

Maven resolves BOM imports during effective-model building, before the
plugin's afterProjectsRead hook runs, so a late-injected import-scope BOM
is a no-op. Instead the plugin resolves sentry-opentelemetry-bom at the
managed Sentry version, expands it into concrete OpenTelemetry versions,
and applies them to the project's dependencyManagement: versions inherited
from a parent or another BOM (e.g. Spring Boot) are overwritten in place,
unmanaged artifacts get a new managed entry, and versions the user pinned
explicitly are left untouched (with a warning when they differ).

Add a skipInstallOpenTelemetryBom opt-out and a telemetry tag.

Co-Authored-By: Claude <[email protected]>
@adinauer
adinauer requested review from markushi and romtsn as code owners July 1, 2026 14:45
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor
Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- Auto-install sentry-opentelemetry-bom ([#266](https://github.com/getsentry/sentry-maven-plugin/pull/266))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against a8a27de

@adinauer

adinauer commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Superseded: we're pivoting away from auto-installing/rewriting the BOM. In Maven, overwriting inherited dependencyManagement is too magic, and the real risk is a silent OpenTelemetry downgrade (e.g. Spring Boot forcing OTel below what Sentry's sentry-opentelemetry-* artifacts need). New PR instead detects that downgrade and fails the build with instructions to import sentry-opentelemetry-bom — mirroring sentry-android-gradle-plugin#1350. Replacing this PR.

@adinauer adinauer closed this Jul 6, 2026
adinauer added a commit that referenced this pull request Jul 14, 2026
#268)

Builds on top of #265. Maven port of
getsentry/sentry-android-gradle-plugin#1350 (which itself is stacked on
the SAGP equivalent of #265,
getsentry/sentry-android-gradle-plugin#1349).

## What

Fails the build when the OpenTelemetry versions resolved for a project
are **downgraded** below what Sentry's `sentry-opentelemetry-*`
artifacts were built and tested against.

## Why

Sentry's OpenTelemetry artifacts declare the exact OpenTelemetry
versions they require. When another dependency management mechanism —
most commonly Spring Boot (via `spring-boot-starter-parent` or an
imported `spring-boot-dependencies` BOM) — forces OpenTelemetry below
those versions, it happens **silently** (the user never declares an OTel
version). Running against the mismatched versions can throw
`ClassNotFoundException` / `NoSuchMethodError` at runtime. This surfaces
the problem at build time with actionable guidance instead.

This **replaces an earlier approach that auto-installed the BOM**
(previous PR #266). In Maven a late-injected import-scope BOM is a no-op
(BOM imports are flattened during effective-model building, before
`afterProjectsRead`), and rewriting inherited `dependencyManagement` in
place is too surprising. Detecting-and-failing is the more honest
behavior — same conclusion as SAGP #1350.

## How it works

- Runs in the lifecycle participant (automatic, no execution config
needed), reusing the dependency resolution already done for
auto-install.
- Gated by a cheap check: skipped entirely unless the project uses a
`sentry-opentelemetry-*` artifact.
- Resolves each present `sentry-opentelemetry-*` artifact to determine
the OpenTelemetry versions it requires (declared dependencies + its own
dependency management), then compares against the versions actually
resolved on the project. A resolved version lower than the required
version is a downgrade.
- Only OpenTelemetry modules a `sentry-opentelemetry-*` artifact
requires are inspected, so unrelated OpenTelemetry usage is never
flagged. Unparseable versions are skipped.
- The failure message lists each downgrade and shows the exact
`<dependencyManagement>` import for `sentry-opentelemetry-bom` at the
resolved Sentry version, noting Maven's first-declaration-wins ordering
when Spring Boot is present.

## Config

Opt out with
`<skipValidateOpenTelemetryVersions>true</skipValidateOpenTelemetryVersions>`.
Adds a `SENTRY_validateOpenTelemetryVersions` telemetry tag.

## Phase / placement

Implemented in the lifecycle participant (runs before any phase,
automatically) rather than as an opt-in `validate`-phase mojo, so users
get protected by default — matching SAGP #1350's automatic, default-on
behavior.

## Open items (mirroring SAGP #1350)

- **Docs URL is a placeholder**
(`.../platforms/java/tracing/instrumentation/opentelemetry/troubleshooting/`)
and must resolve to a live page before release.
- **Default-on is a product call.** Defaulting a build-breaking check to
on will surprise existing Spring Boot users on upgrade. Either keep
default-on with a clearly-flagged behavioral-change changelog entry, or
ship opt-in first and flip later based on telemetry.

## Tests

- Unit (`OpenTelemetryVersionCheckerTest`): downgrade detection (match /
upgrade / not-resolved / alpha / unparseable), eligibility gate, and
failure-message content (mismatch line, BOM snippet, opt-out, Spring
Boot ordering note).
- Integration (`OpenTelemetryVersionCheckTestIT`): build fails on a
Spring Boot parent downgrade with the guidance message; succeeds when
not downgraded; succeeds when disabled; no-op without a Sentry
OpenTelemetry dependency.

Co-authored with Claude.

---------

Co-authored-by: Claude <[email protected]>
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.

1 participant