Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

JUnit4 suite-level TestExecutionListener callbacks see no active span under Bazel

Đang mở
#11,886 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

@daniel-mohedano đang làm issue này rồi.

Từ ngày 8/7/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

comp: ci visibility type: bug report
Tracer Version(s)

1.63.1, 1.62.0

Java Version(s)

21.0.6

JVM Vendor

Azul Zing / Zulu

Bug Report

We attach custom test metadata to CI Visibility spans via a org.junit.platform.launcher.TestExecutionListener registered on the JUnit Platform Launcher (tried both META-INF/services auto-registration and explicit registerTestExecutionListeners()). This listener calls GlobalTracer.get().activeSpan() inside executionStarted/executionFinished to tag the currently-active span.

For JUnit4 tests bridged through junit-vintage-engine:

Method-level spans: activeSpan() resolves correctly and our tags apply.
Suite-level (container) spans, under Bazel: activeSpan() is reliably null at both executionStarted and executionFinished, even though the suite span itself is still created and reported to Datadog correctly (correct duration/status/etc — just without our tags).
We have a separate, non-Bazel test runner that invokes the exact same JUnit Platform Launcher API directly (LauncherFactory.openSession(), explicit listener registration, selectClass(...)) and registers an equivalent listener doing the same activeSpan() lookup — and it successfully tags suite-level spans in production. So this isn't a general limitation of the plain Launcher API path; something about the Bazel environment specifically prevents the suite span from being visible as "active" to an external TestExecutionListener.

What we've ruled out
We suspected a version regression between 1.62.0 and 1.63.1 (a bytecode diff showed 1.63.1 removed a lazy-suite-autostart fallback from JUnit4TracingListener that existed in 1.62.0, landing in the same PR that added Bazel-wrapper-specific suite-event handling). We tested this directly: swapped Bazel's agent from 1.63.1 down to 1.62.0 for the same test class, same Bazel launch setup. Result: activeSpan() is still null for the suite container on 1.62.0 too.

Expected Behavior

A suite-level TestExecutionListener callback should be able to observe the active suite span via GlobalTracer.get().activeSpan() under Bazel, consistent with how it behaves for the same JUnit Platform Launcher API used outside Bazel.

Reproduction Code
  1. A JUnit4 test class run via junit-vintage-engine under the JUnit Platform Launcher, under Bazel, with a custom main_class = "org.junit.platform.console.ConsoleLauncher" (i.e., not Bazel's native BazelTestRunner/RunNotifierWrapper).
  2. Register a TestExecutionListener that calls GlobalTracer.get().activeSpan() inside executionStarted/executionFinished for container-type TestIdentifiers.
  3. Observed on both dd-java-agent 1.62.0 and 1.63.1: activeSpan() is null for the suite container, both at start and finish.
  4. The equivalent pattern (plain Launcher API, explicit listener registration) works outside Bazel in our environment, on 1.62.0.
Ngôn ngữ chính
Java
Star
737
Fork
361
Merge trung bình
3 ngày 20 giờ
Pull request đã merge (30 ngày)
173

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DataDog/dd-trace-java

Tất cả issue của DataDog/dd-trace-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.