@@ -79,20 +79,16 @@ public void visit(Event event, long value) {
7979 long threadId = resolveThreadId (event .tid );
8080
8181 if (stackTrace != null ) {
82- // Process thread metadata if enabled
8382 if (args .threads ) {
8483 processThreadMetadata (event , threadId );
8584 }
86-
87- // Create and add the sample
85+
8886 createSample (event , threadId );
8987
90- // Build the stack trace from methods
9188 buildStackTraceAndFrames (stackTrace );
9289 }
9390 }
9491
95- // Extract thread metadata and add to profile
9692 private void processThreadMetadata (Event event , long threadId ) {
9793 final String threadName = getPlainThreadName (event .tid );
9894 sentryProfile
@@ -107,7 +103,6 @@ private void processThreadMetadata(Event event, long threadId) {
107103 });
108104 }
109105
110- // Build stack trace from method array
111106 private void buildStackTraceAndFrames (StackTrace stackTrace ) {
112107 List <Integer > stack = new ArrayList <>();
113108 int currentFrame = sentryProfile .getFrames ().size ();
@@ -132,19 +127,14 @@ private void buildStackTraceAndFrames(StackTrace stackTrace) {
132127 sentryProfile .getStacks ().add (stack );
133128 }
134129
135- // Create a single stack frame from a stack trace element
136130 private SentryStackFrame createStackFrame (StackTraceElement element ) {
137131 SentryStackFrame frame = new SentryStackFrame ();
138132 final String classNameWithLambdas = element .getClassName ().replace ("/" , "." );
139133 frame .setFunction (element .getMethodName ());
140134
141- // Extract class name without lambda suffix
142135 String sanitizedClassName = extractSanitizedClassName (classNameWithLambdas );
143-
144- // Set module based on package structure
145136 frame .setModule (extractModuleName (sanitizedClassName , classNameWithLambdas ));
146137
147- // Determine if frame should be marked as in_app
148138 if (shouldMarkAsSystemFrame (element , classNameWithLambdas )) {
149139 frame .setInApp (false );
150140 } else {
@@ -166,7 +156,7 @@ private String extractSanitizedClassName(String classNameWithLambdas) {
166156 return classNameWithLambdas ;
167157 }
168158
169- // Set module name based on package structure
159+ // TODO: test difference between null and empty string for module
170160 private @ Nullable String extractModuleName (
171161 String sanitizedClassName , String classNameWithLambdas ) {
172162 if (hasPackageStructure (sanitizedClassName )) {
@@ -178,17 +168,14 @@ private String extractSanitizedClassName(String classNameWithLambdas) {
178168 }
179169 }
180170
181- // Check if the class name has a package structure (contains dots)
182171 private boolean hasPackageStructure (String className ) {
183172 return className .lastIndexOf ('.' ) > 0 ;
184173 }
185174
186- // Check if it's a regular class without package (not an array type)
187175 private boolean isRegularClassWithoutPackage (String className ) {
188176 return !className .startsWith ("[" );
189177 }
190178
191- // Create sample with timestamp and thread info
192179 private void createSample (Event event , long threadId ) {
193180 int stackId = sentryProfile .getStacks ().size ();
194181 SentrySample sample = new SentrySample ();
@@ -201,24 +188,20 @@ private void createSample(Event event, long threadId) {
201188 long timeNs = jfr .chunkStartNanos + nsFromStart ;
202189 sample .timestamp = DateUtils .nanosToSeconds (timeNs );
203190
204- // Set thread ID
205191 sample .threadId = String .valueOf (threadId );
206192 sample .stackId = stackId ;
207193
208194 sentryProfile .getSamples ().add (sample );
209195 }
210196
211- // Check if the stack frame should be marked as a system frame
212197 private boolean shouldMarkAsSystemFrame (StackTraceElement element , String className ) {
213198 return element .isNativeMethod () || className .isEmpty ();
214199 }
215200
216- // Check if the stack trace element has a valid line number
217201 private @ Nullable Integer extractLineNumber (StackTraceElement element ) {
218202 return element .getLineNumber () != 0 ? element .getLineNumber () : null ;
219203 }
220204
221- // Resolve the actual thread ID from the JFR event
222205 private long resolveThreadId (int eventThreadId ) {
223206 return jfr .threads .get (eventThreadId ) != null
224207 ? jfr .javaThreads .get (eventThreadId )
0 commit comments