How to create OpenTelemetry traces in Java and send to the OpenTelemetry collector manually?
Use opentelemetry java sdk to create spans and configure exporter to send spans to opentelemetry collector
SDK available here
Use the Manual instrumentation as explained here.
Example available here
Related
I'm trying to monitor JVM usages in IBM Websphere Server. Normally I use jstat tool from the JDK but since that's not available with IBM WAS, is there any other tool available for the same?
WAS uses IBM's J9 JVM under the hood. So, some of the HotSpot JVM's debugging tool will not work with it. WAS exposes all details using Performance Monitoring Infrastucture(PMI). You should be able to get lots of metrics using it. You need to enable this feature in order to get metrics.
In our existing MFP 7.1 project, we're relying on the polling event source in a JavaScript adapter to create a scheduler which enables an interval-specific operation such as watching over a database table for new records to process at server side. The implementation was based on the following guide:
http://www.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.dev.doc/devref/t_configuring_a_polling_event_source.html
However, we discovered that polling event source is nowhere to be found in the MFP 8.0 documentation and the following document states that polling event source is no longer supported:
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/product-overview/release-notes/deprecated-discontinued/
We would like to know what is the recommended approach to migrate from 7.1 to 8.0 when dealing with polling event source such as this, and what is the alternative way suggested if there is no possible way in MFP 8.0. Thanks.
Polling is indeed not supported in MobileFirst Foundation 8.0.
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/upgrading/migrating-push-notifications/
I don't have any official alternative, but since polling is the checking of some backend for new content and if true, then have a notification dispatched, you can still create some service of your own to check your backend if there is a new "record" or new otherwise new content, and if true, the construct a JSON for that notification and send it.
In v8.0 you have multiple REST endpoints you could use together with Confidential clients to send it.
http://www.ibm.com/support/knowledgecenter/SSHS8R_8.0.0/com.ibm.worklight.apiref.doc/rest_runtime/c_restapi_runtime.html
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/authentication-and-security/confidential-clients/
You can also take a look at the following way of constructing a mechanism to send notifications using Node.js: https://mobilefirstplatform.ibmcloud.com/blog/2016/10/18/using-mff-8-push-service-rest-api-in-a-nodejs-based-server/
How does Visual VM interact with JVM to get all the information. Is there any API's exposed by JVM to do so ? \
Yes, this is done mostly through JMX API.
There are public standardized MBeans for JVM monitoring:
ThreadMXBean
RuntimeMXBean
MemoryMXBean
ClassLoadingMXBean
etc., see java.lang.management package.
And there are also private HotSpot-specific MBeans under sun.management package:
HotspotClassLoadingMBean
HotspotCompilationMBean
HotspotMemoryMBean
HotspotRuntimeMBean
HotspotThreadMBean
Besides JMX HotSpot JVM has other diagnostic APIs:
Jvmstat Performance Counters, aka PerfData
Dynamic Attach API
JVM Tool Interface
By the way, VisualVM is open source, you may download the sources to see everything yourself.
According to below, we can call Java code from javascript adapter.
Calling Java code from a JavaScript adapter
http://www-01.ibm.com/support/knowledgecenter/?lang=en#!/SSZH4A_6.2.0/com.ibm.worklight.dev.doc/devref/t_calling_java_code_from_a_javas.html
We plan to install worklight server on WAS full profile. WAS full profile supports two-phase commit.
Transaction support in WebSphere Application Server< br/>
http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/cjta_trans.html?cp=SSAW57_8.5.5%2F3-2-7-3&lang=en
To call java code from adapter, we need to deploy it on "Worklight server". Can we use two-phase commit in java code? Are there any limitations when using java code on worklight server?
Thanks in advance!
The only limitation I am aware of is that the WAS security context is not propagated to Worklight adapter's thread. But generally speaking, the same capabilities exist and the same servlet API is available.
You can read more about Java Vs JavaScript in adapters, in this question: Worklight Adapters - Java vs JavaScript
That said, two-phase commit was never tested in practice, so it may work and may not work... for the same reason as the security context mentioned above. As a transaction is usually associated with a thread, and that thread is not available for Worklight adapters which are using their own thread pool.
This limitation mentioned above may be removed in a future release of Worklight, which in turn may make it possible to use the two-phase commit feature.
I want to monitor JVM performance on my production environment. I have installed only JRE, not JDK, Hence i can't use jstat, jconsole etc. to monitor the JVM performance.
Can somebody please help to understand how can i monitor JVM performance in this scenario?
Is there any way to achieve this?
(please note that i don't want to monitor it remotely through JMX or something else. i would like to install local agent in each machine which will send the metrics to server at the interval of 1 minute.)
Thanks,
KS
If you manage to get JMX up and running on your VM (from the comment), you can then use jmxterm or jmxfetch to push these JMX metrics into a metrics system (like graphite or Datadog).
If you have enough patience and time to write, you can probably have a look at JVMTI. You can write your code in C/C++ and run it along your Java Process and you can gather information about the JVM without affecting it.
Another simple and naive way is to start your VM with a javaagent written in java but JVMTI is even better than that. The most crucial difference between the javaagent and JVMTI app is derived from the loading mechanics. While the agents are loaded inside the heap, they are governed by the same JVM. Whereas the JVMTI agents are not governed by the JVM rules and are thus not affected by the JVM internals such as the GC or runtime error handling.
You can even give Java Mission Control a try if you're using JDK7 or above :)
Jolokia is a java agent you can use to expose JMX as http. Run jmx2graphite and get those metrics into Graphite. The link includes instructions on Graphite installation (10 minutes)