Skip to content

Add trace correlation IDs to build reports - #13627

Merged
gnodet merged 1 commit into
apache:feature/build-reportfrom
Hiteshsai007:codex/issue-13567
Oct 22, 2026
Merged

gnodet merged 1 commit into
apache:feature/build-reportfrom
Hiteshsai007:codex/issue-13567

Conversation

@Hiteshsai007

@Hiteshsai007 Hiteshsai007 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR addresses #13567 by adding optional OpenTelemetry trace and span correlation identifiers to module and mojo entries in Maven build reports.

Issue: #13567

This PR is intentionally based on and targets feature/build-report, because the BuildReport API is introduced by #12695.

How it works:
I added nullable traceId() and spanId() fields to ModuleReport and MojoReport. BuildReportCollector snapshots the otel.trace_id and otel.span_id values from the SLF4J MDC when a project or mojo starts, preserves them for the corresponding report entry, and leaves them null when no tracing extension provides a context. Skipped mojos also leave these fields null because no mojo span is started for them.

The JSON writer now emits the two optional fields for modules and mojos. Since this is an additive schema change, the report version is updated from 1.0 to 1.1.

Why this is necessary:
Build reports currently describe Maven module and mojo execution, while tracing extensions record the same work as OpenTelemetry spans. Without correlation IDs, users cannot reliably move from a failed or slow build-report entry to the corresponding trace and span in their observability backend. Defining an MDC-based handoff lets tracing extensions supply this context without adding a direct OpenTelemetry dependency to Maven Core.

Testing:

  • Added collector tests covering both populated and absent trace context.
  • Added JSON writer tests covering module/mojo serialization and report version 1.1.
  • Successfully ran:
    mvn -o -pl impl/maven-core -am -DskipITs -Drat.skip=true -Dtest=BuildReportCollectorTest,BuildReportJsonWriterTest -Dsurefire.failIfNoSpecifiedTests=false test
  • Result: 19 tests run, 0 failures, 0 errors, 0 skipped.
  • Checkstyle passed and Spotless reported the changed sources clean.
  • The Core IT suite was not run locally.

Checklist

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
  • Run mvn verify to make sure basic checks pass.
  • You have run the Core IT successfully.

To make clear that you license your contribution under the Apache License Version 2.0, January 2004, you have to acknowledge this by using the following checkbox.

Expose optional trace and span identifiers for module and mojo reports. Capture tracing context from the SLF4J MDC at lifecycle start events and include it in JSON build reports.

Bump the additive report schema version and cover both populated and absent correlation fields in tests.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Trace correlation IDs are correctly captured from the SLF4J MDC at event-start time, properly null-guarded with nonBlank() and TraceContext.EMPTY, and consistently propagated through all assembly paths — including the mojo stream in buildModuleReport and the module-level path. API design follows the noun-style accessor convention (traceId(), spanId()) required for @Immutable interfaces. Tests cover both the populated and null cases; the @AfterEach MDC cleanup is correct. No issues found.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet
gnodet merged commit 05624f6 into apache:feature/build-report Oct 22, 2026
3 checks passed
gnodet pushed a commit to gnodet/maven that referenced this pull request Oct 24, 2026
Expose optional trace and span identifiers for module and mojo reports. Capture tracing context from the SLF4J MDC at lifecycle start events and include it in JSON build reports.

Bump the additive report schema version and cover both populated and absent correlation fields in tests.
gnodet pushed a commit to gnodet/maven that referenced this pull request Oct 25, 2026
Expose optional trace and span identifiers for module and mojo reports. Capture tracing context from the SLF4J MDC at lifecycle start events and include it in JSON build reports.

Bump the additive report schema version and cover both populated and absent correlation fields in tests.
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.

3 participants