captured java thread name

Erik Gahlin erik.gahlin at oracle.com
Mon Mar 9 16:41:06 UTC 2020


I imagine you create a Java event like this in your application:

@Name("org.milan.mimica.ThreadContext")
@Label("Thread Context)
@StackTrace(false)
@Enabled(true)
@Threshold("0 ms")
static class ThreadContextEvent {
   @Label("Context Name);
   String name;
}

...

public void transaction(String userName) {
     Thread.currentThread().setName(userName);
     ThreadContextEvent event;
     event.name = userName;
     event.begin();
     executeQuery(userName);
     event.end();
     Thread.currentThread().setName(NO_TRANSACTION);
}

If you get an allocation in the executeQuery method, your custom 
ThreadContext event will overlap with the TLAB event. You can in the 
Threads tab in JMC select events that happens at the same time 
(concurrently) to see how they relate. I have not tried the selection 
mechanism in JMC, so I can't help you there, but that is the idea.

Erik

On 2020-03-09 15:43, Milan Mimica wrote:
> On Mon, 9 Mar 2020 at 14:32, Erik Gahlin <erik.gahlin at oracle.com> wrote:
>> We are aware of the problem.
> Hi Erik. Ok, I though so.
>
>> Have you considered adding a custom event with the context you want to
>> track, or is it a third party library that you don't have control over?
> How do I add custom events?
>
>


More information about the hotspot-jfr-dev mailing list