Custom Telemetries


  Besides the pre-defined system telemetries, you can add your own telemetries to the telemetry section. With the  add button in the tool bar, you can quickly add a new telemetry view with a single data line.

Multiple data lines can be set up with with the  configure button in the tool bar. In the configuration dialog you can also add and remove custom telemetries. When adding new data lines, the insertion point depends on the current selection. If an existing telemetry is selected, the new data line will be added to that telemetry, otherwise a new telemetry will be added.

You can collate existing data lines into a single telemetry by using the  move up and  move down buttons in the custom telemetry configuration dialog, which let data lines be moved across telemetry view boundaries. If a telemetry ends up being empty, you have to delete it before you can successfully close the configuration dialog.

When adding a telemetry line in such a way that it is not added to an existing telemetry, a telemetry view item will be created automatically, with an automatically generated name. The telemetry view item can be edited. The following properties that apply to all data lines can be configured:

  • Name
    The name of the telemetry view. This is the name that is displayed in the JProfiler view selector on the left side of the window.
  • Unit
    By default, telemetries show plain numbers. The unit types "per-second", "percent", "milliseconds", "microseconds", "nanoseconds" and "bytes" are also available. For time and size units, aggregated units like "seconds" or "MB" are used automatically as appropriate.
  • Scale
    All values can be multiplied with a scale factor 10^-n. If you enter 1, values will be divided by 10, if you enter -3, values will be multiplied by 1000.
  • Stack all lines
    By default, all data lines in a telemetry view are shown as lines. If you select the stacking option, the data lines are interpreted to be summable and a "Total" line is added automatically. The telemetry can then also be shown as an area graph where the single lines are stacked on top of each other, with the upper bound showing the total value of all data lines.
  Data lines can collect their data from two different sources:
  • MBean telemetries

    In this case, you select a numeric attribute of an MBean. The MBean browser will be shown and on clicking OK, a data line will be added. The line caption is set to the attribute name, but you can edit the line and change the caption to the desired value. The edit dialog also lets you edit the MBean object name and the path to the value manually.

    MBean telemetries can quickly be added from the MBean browser view by selecting a numeric attribute and clicking the  [Add telemetry] tool bar button. The telemetry is then added if it not already exists and the telemetry view is displayed.

    Note that when starting a profiling session, the platform MBean server is not initialized automatically. This is a precaution to avoid problems with the initialization of other MBean servers. To initialize the platform server in cases where no other MBeans are published, click on the hyperlink attached to the error message in the telemetry or activate the MBean browser view. To initialize the platform server in your code, simply call ManagementFactory.getPlatformMBeanServer();

  • Script telemetries

    Telemetries can draw their data from the return value of a script that is invoked once per second. When adding a script telemetry, a script editor is displayed where you can enter an expression or a script with a return value of type long. The entries 42 and return 42; are equivalent. You can use the "scriptContext" parameter of type com.jprofiler.api.agent.ScriptContext to save values across subsequent script invocations.

    Unlike for the MBean data lines, a line name cannot be inferred from the script, so you have to enter a line name in the script dialog.

    The standard way to obtain interesting data is to call static methods in your own classes. Note that only classes loaded by the system class loader are accessible to the script. If you have a static method in a class loaded by a web application class loader, you cannot call it from the script. A workaround would by to periodically set a system property via System.setProperty("myData", String.valueOf(longValue)); and call Long.getLong("myData") in your script.

    If a script throws an exception, the value 0 will be plotted and an error message will be shown in the telemetry that contains a hyperlink to show the stack trace.