How adding Kotlin coroutine name in logging? - kotlin

Working with coroutines, it is possible to use the -Dkotlinx.coroutines.debug jvm option to display the coroutine names in the log as explained in the doc.
How is it possible to reproduce that effect without the jvm option but with a configuration of the logger (logback for example) and/or the application.properties file?

I have not been able to get the coroutine name, but it is possible to use the MDCContext module to add a MDC value to the coroutine that can be logged using the %X{} of logback.

Related

How to set log4j2 log levels and categories in DataWeave 2.x?

When using the log() function in DataWeave I have a few questions:
How can I set a log level and log category so my logs are handled by log4j2 the same way as log messages from the Logger components in the Mule flow?
How can I suppress logging the expression? If the expression result is very large (what if it is streaming data?) I might only want to log to first argument to log, and skip the actual DW expression evaluation.
There is no way to set the logging level with the log() function in DataWeave. As an alternative you could implement a custom function in a custom module in to log that allows to set levels.
You could use the same custom function to implement some logic, however there is the generic problem of determining if a payload is big without fully consuming it. In any case DataWeave logging is meant to be used as a debugging tool and should not be used in production or for big payloads. The best practice is to avoid logging at all unless you need to debug an issue, and then remove the logging.

How can I remove all properties in Jmeter after the run?

I usually set properties within the run in Jmeter. How can remove all these properties after the run without knowing their names?
I usually use props.remove() to remove only one specific property, but how can remove all?
Properties lifetime is limited by the JVM lifetime so it's enough to restart JMeter to remove any custom properties.
Use props.clear() function in any of the JSR223 Test Elements (the syntax assumes Groovy language)
Demo:
However if you want to keep original JMeter properties for whatever reason:
You can store them into and interim object (or to the file) somewhere in setUp Thread Group and restore it in the tearDown Thread Group

Jprofiler session filter settings to avoid tracing of jdk calls

Hi could you please let me know the session filter setting to be added in jprofiler to prevent tracing of jdk internal calls?
Internal calls in the java.* packages are not measured by JProfiler in any case, regardless of your filter settings.
If you define "inclusive" filters that define the profiled classes, then all other packages are not profiled.
Note that the first call from a profiled class into a non-profiled class is always shown in the call tree, it's just the further internal calls that are not measured.

Error in starting second JVM when one is already started

I am developing a client-server software in which server is developed by python. I want to call a group of methods from a java program in python. All the java methods exists in one jar file. It means I do not need to load different jars.
For this purpose, I used jpype. For each request from client, I invoke a function of python which looks like this:
def test(self, userName, password):
Classpath = "/home/DataSource/DMP.jar"
jpype.startJVM(
"/usr/local/java/jdk1.7.0_60/jre/lib/amd64/server/libjvm.so",
"-ea",
"- Xmx512m",
"-Djava.class.path=%s" % Classpath)
NCh = jpype.JClass("Common.NChainInterface")
n = NCh(self._DB_ipAddress, self._DB_Port, self._XML_SCHEMA_PATH, self._DSTDir)
jpype.shutdownJVM()
For one function it works, but for the second call it cannot start jvm.
I saw a lot of complain about it but I could not find any solution for that. I appreciate it if any body can help.
If jpype has problem in multiple starting jvm, is there any way to start and stop jvm once? The server is deployed on a Ubuntu virtual machine but I do not have enough knowledge to write for example, a script for this purpose. Could you please provide a link, or an example?
Check isJVMStarted() before startJVM().
If JVM is running, it will return True, otherwise False.
def init_jvm(jvmpath=None):
if jpype.isJVMStarted():
return
jpype.startJVM(jpype.getDefaultJVMPath())
For a real example, see here.
I have solved it by adding these lines when defining the connection:
if not jpype.isJVMStarted():
jpype.startJVM(jvmPath, args)
This issue is not resolved by et9's answer above.
The problem is explained here.
Effectively you need to start/stop the JVM at the server/module level.
I have had success with multiple calls using this method in unit tests.

Are testng listeners thread safe for file operation

Are testng listeners thread safe? Suppose i am using iTestListener and need to update a text file based on the test failure/pass. I am planning to use onTestFailure() and onTestPass() of the testng listener. These methods will call another method, which will be having the logic to update the text file. So should i use synchronized keyword / synchronized block in this new method?
Thanks
Mathew
Got the answer...
Testng listeners are not thread safe.