Skip to content

Commit 9ac8760

Browse files
jbachorikclaude
andcommitted
fix(review): address sphinx review findings
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 6479338 commit 9ac8760

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

ddprof-lib/src/main/java/com/datadoghq/profiler/ContextSetter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public int[] snapshotTags() {
3030
return snapshot;
3131
}
3232

33+
/**
34+
* Copies current sidecar encodings into {@code snapshot}. The copy only runs when
35+
* {@code snapshot.length >= attributes.size()}; callers must size the array accordingly.
36+
*/
3337
public void snapshotTags(int[] snapshot) {
3438
if (snapshot.length >= attributes.size()) {
3539
profiler.copyTags(snapshot);
@@ -57,6 +61,11 @@ public boolean setContextValue(int offset, String value) {
5761
* OTEP attrs_data value for every slot whose constantId is {@code > 0}, in a single atomic
5862
* publish — no String allocation, hashing, or cache lookup. Intended for re-applying
5963
* application-managed context after a {@code setContext} span activation wipes the slots.
64+
*
65+
* <p><b>Partial-write on overflow.</b> A {@code false} return does not mean the record is
66+
* unchanged: slots that were written before an attrs_data overflow remain published. Overflowed
67+
* slots are zeroed in both the sidecar and attrs_data views. Callers must not assume the record
68+
* is unmodified when {@code false} is returned.
6069
*/
6170
public boolean setContextValuesByIdAndBytes(int[] constantIds, byte[][] utf8) {
6271
return profiler.setContextAttributesByIdAndBytes(constantIds, utf8);

ddprof-stresstest/src/chaos/java/com/datadoghq/profiler/chaos/ReapplyContextAntagonist.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ private void workerLoop() {
108108
for (int i = 0; i < ROUTES.length; i++) {
109109
ctx.setContextAttribute(i, ROUTES[i]);
110110
}
111-
int[] constantIds = new int[10];
111+
int[] constantIds = new int[ROUTES.length];
112112
ctx.copyCustoms(constantIds);
113-
byte[][] utf8 = new byte[10][];
113+
byte[][] utf8 = new byte[ROUTES.length][];
114114
for (int i = 0; i < ROUTES.length; i++) {
115115
utf8[i] = ROUTES[i].getBytes(StandardCharsets.UTF_8);
116116
}

0 commit comments

Comments
 (0)