|
6 | 6 | #ifndef _THREAD_H |
7 | 7 | #define _THREAD_H |
8 | 8 |
|
| 9 | +#include "context.h" |
9 | 10 | #include "os.h" |
10 | 11 | #include "threadLocalData.h" |
11 | 12 | #include "unwindStats.h" |
@@ -74,11 +75,13 @@ class ProfiledThread : public ThreadLocalData { |
74 | 75 | bool _crash_protection_active; |
75 | 76 | Context* _ctx_tls_ptr; |
76 | 77 | OtelThreadContextRecord* _otel_ctx_record; |
77 | | - u64 _otel_local_root_span_id; // Cached local root span ID for OTEL mode (O(1) read) |
| 78 | + u32 _otel_tag_encodings[DD_TAGS_CAPACITY]; |
| 79 | + u64 _otel_local_root_span_id; |
78 | 80 |
|
79 | 81 | ProfiledThread(int buffer_pos, int tid) |
80 | 82 | : ThreadLocalData(), _pc(0), _sp(0), _span_id(0), _root_span_id(0), _crash_depth(0), _buffer_pos(buffer_pos), _tid(tid), _cpu_epoch(0), |
81 | | - _wall_epoch(0), _call_trace_id(0), _recording_epoch(0), _misc_flags(0), _filter_slot_id(-1), _ctx_tls_initialized(false), _otel_ctx_initialized(false), _crash_protection_active(false), _ctx_tls_ptr(nullptr), _otel_ctx_record(nullptr), _otel_local_root_span_id(0) {}; |
| 83 | + _wall_epoch(0), _call_trace_id(0), _recording_epoch(0), _misc_flags(0), _filter_slot_id(-1), _ctx_tls_initialized(false), _otel_ctx_initialized(false), _crash_protection_active(false), _ctx_tls_ptr(nullptr), _otel_ctx_record(nullptr), |
| 84 | + _otel_tag_encodings{}, _otel_local_root_span_id(0) {}; |
82 | 85 |
|
83 | 86 | ~ProfiledThread(); // Defined in thread.cpp (needs complete OtelThreadContextRecord type) |
84 | 87 | void releaseFromBuffer(); |
@@ -208,13 +211,6 @@ class ProfiledThread : public ThreadLocalData { |
208 | 211 | return _otel_ctx_record; |
209 | 212 | } |
210 | 213 |
|
211 | | - inline void setOtelLocalRootSpanId(u64 id) { |
212 | | - _otel_local_root_span_id = id; |
213 | | - } |
214 | | - |
215 | | - inline u64 getOtelLocalRootSpanId() { |
216 | | - return _otel_local_root_span_id; |
217 | | - } |
218 | 214 |
|
219 | 215 | // JavaThread status cache — avoids repeated vtable checks in VMThread::isJavaThread(). |
220 | 216 | // JVMTI ThreadStart only fires for application threads, not for JVM-internal |
@@ -247,6 +243,16 @@ class ProfiledThread : public ThreadLocalData { |
247 | 243 | inline bool isCrashProtectionActive() const { return _crash_protection_active; } |
248 | 244 | inline void setCrashProtectionActive(bool active) { _crash_protection_active = active; } |
249 | 245 |
|
| 246 | + // OTEL JFR tag encoding sidecar — populated by JNI thread, read by signal handler |
| 247 | + inline void setOtelTagEncoding(u32 idx, u32 val) { |
| 248 | + if (idx < DD_TAGS_CAPACITY) _otel_tag_encodings[idx] = val; |
| 249 | + } |
| 250 | + inline u32 getOtelTagEncoding(u32 idx) const { |
| 251 | + return idx < DD_TAGS_CAPACITY ? _otel_tag_encodings[idx] : 0; |
| 252 | + } |
| 253 | + inline void setOtelLocalRootSpanId(u64 id) { _otel_local_root_span_id = id; } |
| 254 | + inline u64 getOtelLocalRootSpanId() const { return _otel_local_root_span_id; } |
| 255 | + |
250 | 256 | private: |
251 | 257 | // Atomic flag for signal handler reentrancy protection within the same thread |
252 | 258 | // Must be atomic because a signal handler can interrupt normal execution mid-instruction, |
|
0 commit comments