Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Using Query Analyzer

Using Query Analyzer

  • Ensure that the JMX support is enabled using the following system properties regardless of the application that uses the support, such as Cortex or a standalone application:
    -Dcom.sun.management.jmxremote
    -Dcom.sun.management.jmxremote.port=<PORT> 
    -Dcom.sun.management.jmxremote.ssl=false
    -Dcom.sun.management.jmxremote.authenticate=false

Where PORT is the port number, for example 6969. When you start Cortex using Maven, add the parameters to the MAVEN_OPTS environment variable.

You can use the Query Analyzer tool from an OSGi container or a command line. When used from an OSGi container, the tool is deployed as a bundle, while from the command line it is run as an executable JAR. Regardless of the usage, only one JAR is created.

The tool uses the trace lines that is found in ep-cortex.log and are enabled through a JMX connection to the Logback MBean. The following classes provide the trace output:
OpenJPA**
com.elasticpath.rest.resource.dispatch.operator.AnnotatedMethodDispatcher
com.elasticpath.rest.resource.dispatch.linker.ResourceLinker
com.elasticpath.rest.helix.runtime.server.PrototypeDispatcherResourceServer

All JPA classes, AnnotatedMethodDispatcher, ResourceLinker, and PrototypeDispatcherResourceServer classes provide trace output for Query Analyzer. The OpenJPA trace lines provide JPA and SQL statistics. The Cortex traces provide correlation between Cortex requests and JPA/DB queries, so that Cortex operation can report the database statistics. For more information about the details provided, see Overview

To use the tool from the command line, run the following command:
java -jar </ep-commerce/commerce-engine/ep-query-analyzer>
Use the command line tool when Cortex log already contains the required TRACE lines. You can override the following default values using system properties:
Table 1. Default Settings
Value Description
-Dlog.file.path=<ABSOLUTE_PATH_TO_CORTEX_LOG> Specifies the default location of Cortex log file. The parser accesses the Cortex log file at this location if you set the location. If not, parser reads the default Cortex log file, USER_HOME/ep/logs/ep-cortex.log.
-Dprint.json.to.console.only Displays JSON output only in console.

If this property is set to a value, such as -Dprint.json.to.console.only=X or -Dprint.json.to.console.only=EP, the system displays the JSON output file only in the console and does not save the output to a file irrespective of the value.

-Doutput.json.file.path Saves the output in an external file at the specified path. By default, the output is saved at USER_HOME/ep/db_statistics.json.

All system properties are defined in the com.elasticpath.repo.performancetools.queryanalyzer.utils.SystemProperties module.