Hiteshsai007 opened a new pull request, #13627:
URL: https://github.com/apache/maven/pull/13627
### 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.
---
<!-- Please open pull requests against one of the following branches:
- master — default target for all changes (new features + bug fixes).
If the change should also go to maven-4.0.x, request a backport in the PR.
- maven-3.10.x — target for 3.x changes (new features + bug fixes).
If the change should also go to maven-3.9.x, request a backport in the PR.
maven-3.9.x should receive only serious bug fixes, as it is approaching
EOL.
Backports are typically handled by maintainers; however, after agreement you
may open a separate backport PR to the target maintenance branch. -->
Following this checklist to help us incorporate your contribution quickly
and easily:
- [x] This pull request addresses one issue without unrelated changes.
- [x] The pull request description explains what the change does, how it
works, and why it is needed.
- [x] The commit has a meaningful subject line and body.
- [x] Unit tests cover the behavioral change.
- [ ] Full `mvn verify` completed locally.
- [ ] The Core IT suite completed locally.
- [x] I hereby declare this contribution to be licensed under the [Apache
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0).
- [ ] I hereby declare that I have filed an [Apache Individual Contributor
License Agreement](https://www.apache.org/licenses/icla.pdf).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]