Fully featured low overhead profiler for Java EE and Java SE platforms.
Performance monitoring and profiling of Jenkins, TeamCity, Gradle, Maven, Ant, JUnit and TestNG.
Easy to use performance and memory profiler for .NET framework.

sessionname via system properties

Moderators: Vladimir Kondratyev, Anton Katilin

sessionname via system properties

Postby ssaarinen » Thu Nov 13, 2014 8:37 am

Hi

I was wondering is it possible to set profiler session name using system properties. I have several JVMs running for which I would like to use same profiler agent settings but different session name. It would be neat if i could specify eg. agentpath:yjpagent.so=sessionname=someapp_${some.system.property:<default>} that would get interpreted by the profiler agent.

BR
samuli
ssaarinen
 
Posts: 2
Joined: Thu Nov 13, 2014 8:26 am

Re: sessionname via system properties

Postby Anton Katilin » Thu Nov 13, 2014 9:52 am

Hi samuli

Session name does not allow macros. However, you may use macros while generating a command line which contains the -agentpath parameter, for example, in .sh script or in Windows .bat.

Anyway, what is the purpose? The session name is just a name used to identify a profiled application in the profiler UI, and to give a default name for its purposes.

Please note that you can see all system properties explicitly in the Summary tab.

Best regards,
Anton
Anton Katilin
 
Posts: 5703
Joined: Wed Aug 11, 2004 8:37 am

Re: sessionname via system properties

Postby ssaarinen » Wed Nov 19, 2014 1:42 pm

I'm using JBoss Wildfly in domain mode that has 4 actual server jvms configured. I thought it would be nice to be able to configure profiler settings only once (this is possible in wildfly domain) but with different session name to distinguish sessions more easily...

As a side note I tried to workaround this as follows:
Wildfly domain controller can do some parameter substitution in jvm arguments because I could use agentpath:${jboss.home.dir} that would get resolved when the JVM is launched but when I tried sessionname=${jboss.node.name} the JVM did not start any more saying it can't resolve the variable so apparently the jboss.node.name property is not assigned that early in the process.

If somebody has resolved this I would be happy to be informed

Cheers, Samuli
ssaarinen
 
Posts: 2
Joined: Thu Nov 13, 2014 8:26 am

Re: sessionname via system properties

Postby Anton Katilin » Thu Nov 20, 2014 10:19 am

Hi Samuli

Thank you for the explanation.

As I wrote, the session name does not offer any macro substitution functionality now.

I see two approaches how to address your need:

1. Use the caller's property substitution capabilities.

What I mean with that: unlikely you start the profiled application by entering corresponding command line in a terminal. Instead, I believe that you have a sort of a script for that, or have some kind of a launcher configuration file, or something like that. That script or configuration syntax likely allows macros, properties, etc.

For example, if it's a Unix shell you may use an environment variable:

YJP_SESSION_NAME="....put necessary code here..."
...
java .... -agentpath:path_to_agent=sessionname=$YJP_SESSION_NAME

The substitution will happen on the shell side, and the profiler agent will get already prepared custom session name.

2. We could add built-in support of properties in the session name.

There is a little technical problem with using Java options for that purpose: the session name is needed as early as when the agent initializes itself, which happens during JVM initialization phase. Only a few system property values are available at the moment. In other words, jboss.node.name can't be obtained at that early time.

We can offer instead to substitute environment variables. Just like in approach #1, but will also work when the caller can't substitute the value. Will this help you?

Best regards,
Anton
Anton Katilin
 
Posts: 5703
Joined: Wed Aug 11, 2004 8:37 am


Return to Java Profiler

Who is online

Users browsing this forum: Bing [Bot] and 19 guests

cron