Skip to content

Return empty method lines instead of throwing when class bytecode resource is missing - #12380

Open
dougqh wants to merge 2 commits into
masterfrom
dougqh/fix-ci-vis-null-classstream-npe
Open

Return empty method lines instead of throwing when class bytecode resource is missing#12380
dougqh wants to merge 2 commits into
masterfrom
dougqh/fix-ci-vis-null-classstream-npe

Conversation

@dougqh

@dougqh dougqh commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Guards ByteCodeLinesResolver.ClassMethodLines.parse against a null bytecode stream: when Utils.getClassStream(clazz) can't locate a class's .class resource (documented @Nullable), it now returns an empty ClassMethodLines and logs at debug, instead of letting ClassReader throw an IOException that gets wrapped, logged at ERROR, and swallowed.

Also migrates ByteCodeLinesResolverTest from Groovy/Spock to JUnit 5/Java (project convention for new/touched unit tests) and adds a regression test (NullResourceClassLoader) exercising the null-stream path directly.

Motivation

Investigated a recurring, non-crashing Datadog error-tracking issue for CI Visibility (TestNG) test runs: Could not determine method borders for {} logged at ERROR, observed across tracer versions from 1.48.1 through 1.65.1, recurring every few months whenever a test suite exercises a class whose bytecode resource isn't resolvable this way (e.g. a Mockito-generated proxy class). No functional impact (the exception was already caught and empty lines returned), but it's noisy in production logs/error tracking and keeps re-triggering an alert.

Additional Notes

  • Fix mirrors the existing handling for the identical condition in the sibling method Utils.getFileName, which already checks for a null stream and logs at debug.
  • Verified with ./gradlew :dd-java-agent:agent-ci-visibility:test (full module) and spotlessCheck.

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion — not needed, files stay under the existing agent-ci-visibility ownership
  • Update public documentation with any new configuration flags or behaviors — not applicable, no config/behavior surface change
  • Once approved, use merge queue to merge the PR

Jira ticket: none (found via Datadog error tracking, not a filed ticket)

…ource is missing

Utils.getClassStream() is documented @nullable and can return null for
classes whose .class resource can't be located on the classpath (e.g.
Mockito-generated proxy classes). ByteCodeLinesResolver.ClassMethodLines.parse
passed that possibly-null stream straight into ClassReader, which threw an
IOException that got wrapped and logged at ERROR, then swallowed. This has
been recurring in error tracking for CI Visibility test runs across many
tracer versions. Short-circuit on a null stream and log at debug instead,
matching the existing handling in Utils.getFileName for the same condition.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dougqh dougqh added tag: ai generated Largely based on code generated by an AI or LLM comp: ci visibility Continuous Integration Visibility type: bug fix Bug fix labels Sep 2, 2026
@dougqh
dougqh marked this pull request as ready for review September 2, 2026 10:56
@dougqh
dougqh requested a review from a team as a code owner September 2, 2026 10:56
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Environment - sbt-scalatest

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 55.25 55.43 $\color{green}{\blacktriangledown}$ -0.18 55.43 $\color{green}{\blacktriangledown}$ -0.18 42/188
agentEvpProxy 54.44 n/a n/a n/a n/a -

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@datadog-prod-us1-5 datadog-prod-us1-5 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.

Datadog Autotest: PASS

More details

The null guard returns empty line data when the class resource is absent. The Java test migration keeps the prior cases and adds the missing-resource case.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit c34874c · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c34874c328

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@datadog-prod-us1-5

This comment has been minimized.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Environment - nebula-release-plugin

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 35.93 36.42 $\color{green}{\blacktriangledown}$ -0.49 36.42 $\color{green}{\blacktriangledown}$ -0.49 24/97
agentless 35.45 35.70 $\color{green}{\blacktriangledown}$ -0.25 35.70 $\color{green}{\blacktriangledown}$ -0.25 24/97
agentlessCodeCoverage 43.79 44.48 $\color{green}{\blacktriangledown}$ -0.69 44.48 $\color{green}{\blacktriangledown}$ -0.69 24/97
agentlessLineCoverage 54.03 55.43 $\color{green}{\blacktriangledown}$ -1.40 55.43 $\color{green}{\blacktriangledown}$ -1.40 23/97

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Environment - netflix-zuul

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 87.42 87.80 $\color{green}{\blacktriangledown}$ -0.38 87.80 $\color{green}{\blacktriangledown}$ -0.38 21/99
agentless 80.84 81.05 $\color{green}{\blacktriangledown}$ -0.21 81.05 $\color{green}{\blacktriangledown}$ -0.21 21/99
agentlessCodeCoverage 96.88 95.12 $\color{red}{\blacktriangle}$ +1.76 95.12 $\color{red}{\blacktriangle}$ +1.76 21/98
agentlessLineCoverage 112.05 111.62 $\color{red}{\blacktriangle}$ +0.43 111.62 $\color{red}{\blacktriangle}$ +0.43 23/100

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Environment - reactive-streams-jvm

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 21.78 21.65 $\color{red}{\blacktriangle}$ +0.13 21.65 $\color{red}{\blacktriangle}$ +0.13 22/103
agentless 19.39 18.82 $\color{red}{\blacktriangle}$ +0.57 18.82 $\color{red}{\blacktriangle}$ +0.57 22/98
agentlessCodeCoverage 20.36 19.59 $\color{red}{\blacktriangle}$ +0.77 19.99 $\color{red}{\blacktriangle}$ +0.37 22/96
agentlessLineCoverage 27.83 25.92 $\color{red}{\blacktriangle}$ +1.91 26.98 $\color{red}{\blacktriangle}$ +0.85 12/58

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Environment - heliboard

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 10.29 10.13 $\color{red}{\blacktriangle}$ +0.16 10.13 $\color{red}{\blacktriangle}$ +0.16 22/93

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@dd-octo-sts

dd-octo-sts Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.81 s 14.62 s [+0.5%; +2.2%] (maybe worse)
startup:insecure-bank:tracing:Agent 13.61 s 13.64 s [-1.1%; +0.6%] (no difference)
startup:petclinic:appsec:Agent 17.03 s 17.04 s [-1.0%; +0.9%] (no difference)
startup:petclinic:iast:Agent 17.03 s 17.07 s [-1.1%; +0.7%] (no difference)
startup:petclinic:profiling:Agent 16.54 s 16.92 s [-3.5%; -1.0%] (maybe better)
startup:petclinic:sca:Agent 17.13 s 16.85 s [+0.5%; +2.8%] (maybe worse)
startup:petclinic:tracing:Agent 16.08 s 16.08 s [-1.1%; +1.2%] (no difference)

Commit: 7e640a6a · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Environment - sonar-kotlin

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 11.98 12.62 $\color{green}{\blacktriangledown}$ -0.64 12.87 $\color{green}{\blacktriangledown}$ -0.89 22/93
agentless 11.42 12.12 $\color{green}{\blacktriangledown}$ -0.70 11.88 $\color{green}{\blacktriangledown}$ -0.46 22/92
agentlessCodeCoverage 13.75 14.81 $\color{green}{\blacktriangledown}$ -1.06 15.11 $\color{green}{\blacktriangledown}$ -1.36 22/92
agentlessLineCoverage 16.89 17.73 $\color{green}{\blacktriangledown}$ -0.84 17.38 $\color{green}{\blacktriangledown}$ -0.49 21/91

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Environment - jolokia

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 93.84 95.12 $\color{green}{\blacktriangledown}$ -1.28 95.12 $\color{green}{\blacktriangledown}$ -1.28 26/103
agentless 87.93 89.58 $\color{green}{\blacktriangledown}$ -1.65 89.58 $\color{green}{\blacktriangledown}$ -1.65 26/101
agentlessCodeCoverage 98.32 99.00 $\color{green}{\blacktriangledown}$ -0.68 99.00 $\color{green}{\blacktriangledown}$ -0.68 25/99
agentlessLineCoverage 99.65 101.00 $\color{green}{\blacktriangledown}$ -1.35 101.00 $\color{green}{\blacktriangledown}$ -1.35 25/101

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Environment - okhttp

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 20.28 19.99 $\color{red}{\blacktriangle}$ +0.29 19.59 $\color{red}{\blacktriangle}$ +0.69 21/96
agentless 19.95 19.59 $\color{red}{\blacktriangle}$ +0.36 19.20 $\color{red}{\blacktriangle}$ +0.75 22/94
agentlessCodeCoverage 22.68 22.54 $\color{red}{\blacktriangle}$ +0.14 22.54 $\color{red}{\blacktriangle}$ +0.14 21/94
agentlessLineCoverage 38.92 38.67 $\color{red}{\blacktriangle}$ +0.25 38.67 $\color{red}{\blacktriangle}$ +0.25 21/95

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Environment - spring_boot

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 16.65 16.04 $\color{red}{\blacktriangle}$ +0.61 16.36 $\color{red}{\blacktriangle}$ +0.29 19/91
agentless 10.04 9.73 $\color{red}{\blacktriangle}$ +0.31 9.92 $\color{red}{\blacktriangle}$ +0.12 19/91
agentlessCodeCoverage 14.04 13.40 $\color{red}{\blacktriangle}$ +0.64 13.40 $\color{red}{\blacktriangle}$ +0.64 19/91
agentlessLineCoverage 22.45 22.09 $\color{red}{\blacktriangle}$ +0.36 22.09 $\color{red}{\blacktriangle}$ +0.36 18/89

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Environment - sonar-java

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent -13.93 7.96 $\color{green}{\blacktriangledown}$ -21.89 10.97 $\color{green}{\blacktriangledown}$ -24.90 25/103
agentless -4.65 11.65 $\color{green}{\blacktriangledown}$ -16.30 11.65 $\color{green}{\blacktriangledown}$ -16.30 25/102
agentlessCodeCoverage 78.84 73.34 $\color{red}{\blacktriangle}$ +5.50 74.82 $\color{red}{\blacktriangle}$ +4.02 25/102
agentlessLineCoverage 111.92 107.25 $\color{red}{\blacktriangle}$ +4.67 111.62 $\color{red}{\blacktriangle}$ +0.30 24/101

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@daniel-mohedano daniel-mohedano 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, left a small nit, thanks for the changes!

Note (no behavior change) on the null-classStream branch: it's
cached as a permanent empty result via computeIfAbsent, which is
correct for a generated/proxy class with no bytecode resource, but
ClassLoader#getResourceAsStream also swallows IOException and
returns null on transient failures (e.g. OOM mid-read) -- seen
regularly in production exception tracking. Not fixing that here;
flagging it for whoever picks this up next.

Also fix testReturnsEmptyMethodLinesWhenClassResourceIsMissing to
call ClassMethodLines.parse() directly instead of going through
getMethodLines(), whose outer catch(Exception) already masks
whether the null-stream guard under test is doing anything.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dougqh
dougqh enabled auto-merge September 10, 2026 13:07
@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - pass4s

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 12.46 9.54 $\color{red}{\blacktriangle}$ +2.92 9.92 $\color{red}{\blacktriangle}$ +2.54 20/85
agentless 14.97 9.35 $\color{red}{\blacktriangle}$ +5.62 9.73 $\color{red}{\blacktriangle}$ +5.24 20/85
agentlessCodeCoverage 17.10 16.04 $\color{red}{\blacktriangle}$ +1.06 15.41 $\color{red}{\blacktriangle}$ +1.69 18/81

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@dougqh
dougqh added this pull request to the merge queue Sep 10, 2026
@dd-octo-sts

dd-octo-sts Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Sep 10, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-09-10 14:16:11 UTC ℹ️ Start processing command /merge


2026-09-10 14:16:16 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-09-10 14:23:02 UTCMergeQueue: The build pipeline contains failing jobs for this merge request

Build pipeline has failing jobs for 6bf119e:

⚠️ Do NOT retry failed jobs directly (why?).

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.
Details

Since those jobs are not marked as being allowed to fail, the pipeline will most likely fail.
Therefore, and to allow other builds to be processed, this merge request has been rejected and the pipeline got canceled.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: ci visibility Continuous Integration Visibility tag: ai generated Largely based on code generated by an AI or LLM type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants