Skip to content

feat(profiling): Publish thread context attribute keys at process start#11558

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
masterfrom
ivoanjo/prof-14883-early-thread-context
Jul 7, 2026
Merged

feat(profiling): Publish thread context attribute keys at process start#11558
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
masterfrom
ivoanjo/prof-14883-early-thread-context

Conversation

@ivoanjo

@ivoanjo ivoanjo commented Jun 4, 2026

Copy link
Copy Markdown
Member

What Does This Do

This PR adjusts the ProcessContext setup to match the change in DataDog/java-profiler#576 to publish the context attributes at process start.

Motivation

Publishing the context attributes at process start enables outside readers of thread context to immediately start reading this information; prior to this change they were impacted by the profiler start delay.

Additional Notes

This PR relies on the API changes introduced in
DataDog/java-profiler#576 and will need to be merged together with an upgrade to the latest java-profiler.

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
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level (note: the PR still needs to be mergeable, this will only skip the pre-merge build)
    • Get more information in this doc

Jira ticket: PROF-14883

@ivoanjo
ivoanjo requested a review from a team as a code owner June 4, 2026 11:59
@dd-octo-sts

dd-octo-sts Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Remove the tag from the pull request title

If you need help, please check our contributing guidelines.

@datadog-official

This comment has been minimized.

@jbachorik jbachorik changed the title feat(profiling): [PROF-14883] Publish thread context attribute keys at process start feat(profiling): Publish thread context attribute keys at process start Jul 6, 2026
**What does this PR do?**

This PR adjusts the `ProcessContext` setup to match the change in
DataDog/java-profiler#576 to publish the
context attributes at process start.

**Motivation:**

Publishing the context attributes at process start enables outside
readers of thread context to immediately start reading this information;
prior to this change they were impacted by the profiler start delay.

**Additional Notes:**

This PR relies on the API changes introduced in
DataDog/java-profiler#576 and will need to
be merged together with an upgrade to the latest java-profiler.

**How to test the change?**

This change includes test coverage.
@ivoanjo
ivoanjo force-pushed the ivoanjo/prof-14883-early-thread-context branch from a2e009f to 0e2f038 Compare July 7, 2026 08:32
@ivoanjo

ivoanjo commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

Update: This was failing the build because master had slightly changed in the meanwhile.

In particular, I needed to do this:

@@ -266,7 +266,8 @@ public final class DatadogProfiler {
     if (isWallClockProfilerEnabled(configProvider)) {
       profilingModes.add(WALL);
     }
-    this.orderedContextAttributes = getOrderedContextAttributes(configProvider);
+    Set<String> contextAttributes = getContextAttributes(configProvider);
+    this.orderedContextAttributes = getOrderedContextAttributes(contextAttributes, configProvider);
     this.contextSetter = new ContextSetter(profiler, orderedContextAttributes);
     // ContextSetter deduplicates and truncates to 10 internally; size arrays to its actual size.
     int contextSize = contextSetter.snapshotTags().length;
@@ -307,7 +308,11 @@ public final class DatadogProfiler {
    * process context can publish the same {@code attribute_key_map} before the profiler starts.
    */
   public static List<String> getOrderedContextAttributes(ConfigProvider configProvider) {
-    List<String> ordered = new ArrayList<>(getContextAttributes(configProvider));
+    return getOrderedContextAttributes(getContextAttributes(configProvider), configProvider);
+  }
+
+  private static List<String> getOrderedContextAttributes(Set<String> contextAttributes, ConfigProvider configProvider) {
+    List<String> ordered = new ArrayList<>(contextAttributes);
     if (isSpanNameContextAttributeEnabled(configProvider)) {
       ordered.add(OPERATION);
     }

as now a new user of contextAttributes has shown up inside the DatadogProfiler constructor.

Since the history on the branch was getting a bit weird, I squash/rebased-this on top of current master.

@dd-octo-sts

dd-octo-sts Bot commented Jul 7, 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.77 s 14.71 s [-0.4%; +1.2%] (no difference)
startup:insecure-bank:tracing:Agent 13.60 s 13.72 s [-1.5%; -0.2%] (maybe better)
startup:petclinic:appsec:Agent 17.48 s 17.37 s [-0.4%; +1.6%] (no difference)
startup:petclinic:iast:Agent 17.40 s 17.55 s [-1.9%; +0.1%] (no difference)
startup:petclinic:profiling:Agent 17.35 s 17.47 s [-1.8%; +0.5%] (no difference)
startup:petclinic:sca:Agent 17.62 s 17.53 s [-0.3%; +1.3%] (no difference)
startup:petclinic:tracing:Agent 16.69 s 16.72 s [-1.5%; +1.0%] (no difference)

Commit: 8d6ef163 · 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.

@ivoanjo
ivoanjo enabled auto-merge July 7, 2026 09:02
@ivoanjo
ivoanjo added this pull request to the merge queue Jul 7, 2026
@dd-octo-sts

dd-octo-sts Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 7, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-07 09:43:33 UTC ℹ️ Start processing command /merge


2026-07-07 09:43:38 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-07-07 10:38:57 UTC ⚠️ MergeQueue: This merge request build was cancelled

[email protected] cancelled this merge request build

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 7, 2026
@ivoanjo

ivoanjo commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

/merge --cancel

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 7, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-07 10:38:46 UTC ℹ️ Start processing command /merge --cancel

@ivoanjo

ivoanjo commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 7, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-07 10:39:23 UTC ℹ️ Start processing command /merge


2026-07-07 10:39:28 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-07-07 12:40:01 UTCMergeQueue: The build pipeline has timeout

The merge request has been interrupted because the build 5567830630602077201 took longer than expected. The current limit for the base branch 'master' is 120 minutes.

@ivoanjo

ivoanjo commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 7, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-07 12:45:40 UTC ℹ️ Start processing command /merge


2026-07-07 12:45:46 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-07-07 13:47:31 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 89faebe into master Jul 7, 2026
588 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the ivoanjo/prof-14883-early-thread-context branch July 7, 2026 13:47
@github-actions github-actions Bot added this to the 1.64.0 milestone Jul 7, 2026
kaahos pushed a commit that referenced this pull request Jul 8, 2026
…rt (#11558)

[PROF-14883] Publish thread context attribute keys at process start

**What does this PR do?**

This PR adjusts the `ProcessContext` setup to match the change in
DataDog/java-profiler#576 to publish the
context attributes at process start.

**Motivation:**

Publishing the context attributes at process start enables outside
readers of thread context to immediately start reading this information;
prior to this change they were impacted by the profiler start delay.

**Additional Notes:**

This PR relies on the API changes introduced in
DataDog/java-profiler#576 and will need to
be merged together with an upgrade to the latest java-profiler.

**How to test the change?**

This change includes test coverage.

Make spotless happy

Co-authored-by: ivo.anjo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants