Skip to content

Avoid repeated controller attribute-key allocation in Spring MVC - #12547

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
andrea.marziali/spring-mvc-handler-span-keys
Sep 18, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
andrea.marziali/spring-mvc-handler-span-keys

Conversation

@amarziali

Copy link
Copy Markdown
Contributor

What Does This Do

Cache Spring MVC controller span and continuation attribute keys per runtime controller class, avoiding repeated string construction during synchronous and async request handling.

Both MVC decorators own a ClassValue, using the existing immutable Pair type. No additional helper class or injection entries are needed. Key contents, controller-class selection, span lifecycle, and cached UTF-8 span names are preserved.

Temporary JMH benchmark outside the repository, using the final implementation:

Key-handling path Allocation before → after Time before → after
Synchronous 376 B → ≈0 B/op 41.2 → 6.0 ns/op
Async, including controller entry/exit 872 B → ≈0 B/op 116.9 → 23.0 ns/op

Simulated one controller class, warmed caches, and a prepopulated ConcurrentHashMap with 65- and 74-character keys.

Results isolate key handling, not whole-request latency. Savings depend on key length, JVM behavior, and servlet implementation.

Motivation

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@amarziali amarziali added the type: feature Enhancements and improvements label Sep 17, 2026
@amarziali
amarziali requested a review from a team as a code owner September 17, 2026 14:36
@amarziali amarziali added the tag: performance Performance related changes label Sep 17, 2026
@amarziali
amarziali removed the request for review from a team September 17, 2026 14:36
@amarziali amarziali added the inst: spring Spring instrumentation label Sep 17, 2026
@amarziali
amarziali requested a review from ygree September 17, 2026 14:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-17T14:39:14.038262Z 6af3f1d PR opened
🔒 Security Review ✅ Completed 2026-09-17T14:41:52.143679Z 6af3f1d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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 cache uses the same runtime handler class and keeps the same attribute keys for synchronous and asynchronous requests.

Was this helpful? React 👍 or 👎

Open Bits AI session

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

@amarziali
amarziali requested a review from mcculls September 17, 2026 14:45
@datadog-prod-us1-5

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 68.82% (+9.73%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 6af3f1d | Docs | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Sep 17, 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.68 s [-0.1%; +1.8%] (no difference)
startup:insecure-bank:tracing:Agent 13.63 s 13.63 s [-0.6%; +0.7%] (no difference)
startup:petclinic:appsec:Agent 17.11 s 16.91 s [+0.2%; +2.0%] (maybe worse)
startup:petclinic:iast:Agent 16.95 s 17.01 s [-1.3%; +0.6%] (no difference)
startup:petclinic:profiling:Agent 16.63 s 16.86 s [-2.4%; -0.2%] (maybe better)
startup:petclinic:sca:Agent 16.97 s 16.87 s [-0.3%; +1.5%] (no difference)
startup:petclinic:tracing:Agent 16.17 s 16.03 s [-0.1%; +1.8%] (no difference)

Commit: 6af3f1d5 · 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.

@ygree ygree 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.

IDM approved

@amarziali

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-09-18 07:32:20 UTC ℹ️ Start processing command /merge


2026-09-18 07:32:26 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-09-18 08:35:49 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit dff0056 into master Sep 18, 2026
607 of 610 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the andrea.marziali/spring-mvc-handler-span-keys branch September 18, 2026 08:35
@github-actions github-actions Bot added this to the 1.67.0 milestone Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: spring Spring instrumentation tag: performance Performance related changes type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants