Skip to content

Commit 2000f0b

Browse files
jbachorikclaude
andcommitted
Force JNI path for context writes in OTEL mode
On Java < 17, ThreadContext.put() uses the ByteBuffer path which writes directly to the Context struct, bypassing ContextApi::set(). In OTEL mode this means the OTEP record is never written. Fix: always use setContext0 JNI when otelMode is active. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 41b7b5c commit 2000f0b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ public long getChecksum() {
156156
}
157157

158158
public long put(long spanId, long rootSpanId) {
159-
return useJNI ? setContext0(spanId, rootSpanId) : putContextJava(spanId, rootSpanId);
159+
// OTEL mode must always use JNI to route through ContextApi::set()
160+
// which writes to the OTEP record (ByteBuffer path only writes to Context struct)
161+
return (useJNI || otelMode) ? setContext0(spanId, rootSpanId) : putContextJava(spanId, rootSpanId);
160162
}
161163

162164
public void putCustom(int offset, int value) {

0 commit comments

Comments
 (0)