@@ -50,6 +50,7 @@ public static void setup() throws IOException {
5050 public void cleanup () {
5151 if (profilerStarted ) {
5252 profiler .stop ();
53+ profiler .resetThreadContext ();
5354 profilerStarted = false ;
5455 }
5556 }
@@ -62,7 +63,7 @@ public void cleanup() {
6263 public void testOtelStorageModeContext () throws Exception {
6364 Path jfrFile = Files .createTempFile ("otel-ctx-otel" , ".jfr" );
6465
65- profiler .execute (String .format ("start,cpu=1ms,jfr,file=%s" , jfrFile .toAbsolutePath ()));
66+ profiler .execute (String .format ("start,cpu=1ms,attributes=tag1;tag2;tag3, jfr,file=%s" , jfrFile .toAbsolutePath ()));
6667 profilerStarted = true ;
6768
6869 long localRootSpanId = 0x1111222233334444L ;
@@ -83,7 +84,7 @@ public void testOtelStorageModeContext() throws Exception {
8384 public void testOtelModeStartsOnAnyPlatform () throws Exception {
8485 Path jfrFile = Files .createTempFile ("otel-ctx-any" , ".jfr" );
8586
86- profiler .execute (String .format ("start,cpu=1ms,jfr,file=%s" , jfrFile .toAbsolutePath ()));
87+ profiler .execute (String .format ("start,cpu=1ms,attributes=tag1;tag2;tag3, jfr,file=%s" , jfrFile .toAbsolutePath ()));
8788 profilerStarted = true ;
8889
8990 // Context operations should not crash
@@ -97,7 +98,7 @@ public void testOtelModeStartsOnAnyPlatform() throws Exception {
9798 public void testOtelModeClearContext () throws Exception {
9899 Path jfrFile = Files .createTempFile ("otel-ctx-clear" , ".jfr" );
99100
100- profiler .execute (String .format ("start,cpu=1ms,jfr,file=%s" , jfrFile .toAbsolutePath ()));
101+ profiler .execute (String .format ("start,cpu=1ms,attributes=tag1;tag2;tag3, jfr,file=%s" , jfrFile .toAbsolutePath ()));
101102 profilerStarted = true ;
102103
103104 profiler .setContext (0xCAFEBABEL , 0xDEADBEEFL , 0L , 0x12345678L );
@@ -116,7 +117,7 @@ public void testOtelModeClearContext() throws Exception {
116117 public void testOtelModeCustomAttributes () throws Exception {
117118 Path jfrFile = Files .createTempFile ("otel-ctx-attrs" , ".jfr" );
118119
119- profiler .execute (String .format ("start,cpu=1ms,contextattribute =http.route;db.system,jfr,file=%s" , jfrFile .toAbsolutePath ()));
120+ profiler .execute (String .format ("start,cpu=1ms,attributes =http.route;db.system,jfr,file=%s" , jfrFile .toAbsolutePath ()));
120121 profilerStarted = true ;
121122
122123 // Register attribute keys
@@ -145,7 +146,7 @@ public void testOtelModeCustomAttributes() throws Exception {
145146 public void testSetContextAttribute () throws Exception {
146147 Path jfrFile = Files .createTempFile ("otel-ctx-attr" , ".jfr" );
147148
148- profiler .execute (String .format ("start,cpu=1ms,contextattribute =http.route,jfr,file=%s" , jfrFile .toAbsolutePath ()));
149+ profiler .execute (String .format ("start,cpu=1ms,attributes =http.route,jfr,file=%s" , jfrFile .toAbsolutePath ()));
149150 profilerStarted = true ;
150151
151152 profiler .setContext (0x456L , 0x123L , 0L , 0x789L );
@@ -162,7 +163,7 @@ public void testSetContextAttribute() throws Exception {
162163 public void testOtelModeAttributeOverflow () throws Exception {
163164 Path jfrFile = Files .createTempFile ("otel-ctx-overflow" , ".jfr" );
164165
165- profiler .execute (String .format ("start,cpu=1ms,contextattribute =k0;k1;k2;k3;k4,jfr,file=%s" , jfrFile .toAbsolutePath ()));
166+ profiler .execute (String .format ("start,cpu=1ms,attributes =k0;k1;k2;k3;k4,jfr,file=%s" , jfrFile .toAbsolutePath ()));
166167 profilerStarted = true ;
167168
168169 OTelContext .getInstance ().registerAttributeKeys ("k0" , "k1" , "k2" , "k3" , "k4" );
@@ -171,8 +172,8 @@ public void testOtelModeAttributeOverflow() throws Exception {
171172
172173 ThreadContext ctx = profiler .getThreadContext ();
173174
174- // Fill up attrs_data with long values (255 bytes each = 257 bytes per entry)
175- // 612 / 257 = 2 full entries, third should fail
175+ // LRS "2" occupies 3 bytes (key=1, len=1, value=1) in attrs_data.
176+ // Each 255-char attr = 257 bytes per entry. Two fit; third overflows.
176177 StringBuilder sb = new StringBuilder (255 );
177178 for (int i = 0 ; i < 255 ; i ++) sb .append ('x' );
178179 String longValue = sb .toString ();
0 commit comments