KEY ELEMENTS IN API RESPONSE

HeapHero’s JSON APIs are used for application monitoring, analyzing code quality during CI/CD pipeline and several other purposes. API response contains rich set of information (i.e. lot of elements). In this article, we intend to highlight to few key elements in the API response. If values of these elements exceed or drops below the certain threshold, then you might consider raising alerts/warnings

1. PROBLEM

HeapHero API has the intelligence to detect problems in the heap dumps automatically. Whenever HeapHero detects problem, detail about the detected problem will reported in ‘problem’ element. ‘problem’ is THE PRIMARY ELEMENT in the response. If you encounter ‘problem’ element in the response, you are highly encouraged to generate alert/warning.

How to read ‘problem’ element?

There are multiple sections in the JSON response. Based on which section experiencing issues, ‘problem’ element can be found in that particular section. Example:

{
    "largeObjects": [
        {
            "objectName": "java.lang.ref.Finalizer",
            "percentage": 99.51948,
            "size": "45.71mb",
            "problem": "Object might be causing memory leak."
        },
        :
     ],   
:
:
}

JSON expression to read ‘problem’ elements at any level in the JSON response will be:

$..problem

2. VISUAL REPORT

You might want to integrate the graphical visualization of the heap dump analysis to Jenkins report or any other dashboards. API response contains ‘graphURL’ element which has a hyperlink to the visual report. This is the same visual Report that you will get when you upload the heap dumps in to the web portal. Visual report contains graphs, detailed metrics, help texts, … As old saying goes: “one picture is worth 1000 words” :-), we highly encourage you to integrate visualization of the data in your reports.

How to read ‘graphURL’ element?

‘graphURL’ element will be found in the root level of the JSON API response. Example:

{
"graphURL": "http://192.168.0.122:9000/my-heap-report.jsp?p=Qzpcd29ya3NwYWNlXHRtcFx0aWVyMWFwcFxzaGFyZWRcMjAxOC03LTEwXGFwaS1lMDk0YTM0ZS1jM2ViLTRjOWEtODI1NC1mMGRkMTA3MjQ1Y2M5N2NmN2ZkZi1iZGFiLTQ3MmUtODViMC1iMGE5ZjljM2E2ZWYudHh0Lmpzb24="
:
:
}

JSON expression to read ‘graphURL’ element from the JSON response is:

SELRES_08aa33e1-59b5-4520-98bc-dc2696ef1ae4SELRES_b9bac671-95e8-4fcc-8602-c4cd9fdbabf2$.graphURLSELRES_b9bac671-95e8-4fcc-8602-c4cd9fdbabf2SELRES_08aa33e1-59b5-4520-98bc-dc2696ef1ae4

3. Wasted Memory

In modern computing world lot of memory is wasted because of poor programming practices such as: duplicate object creation, duplicate string creation, inefficient collections implementations, sub-optimal data type definitions, inefficient finalizations,.. Heap Hero API detects an amount of memory wasted due to all these inefficient programming practices. This can be a key metric to track. In case if amount wasted memory goes beyond certain percentage, then CI/CD build can be failed, or warnings can be generated.

How to read wasted memory?

Amount of wasted memory is reported through 2 elements ‘wastedMemoryPercentage’ and ‘wastedMemorySize’. ‘wastedMemoryPercentage’ shows amount of memory wasted due to inefficient programming on the percentage basis. ‘wastedMemorySize’ shows amount of memory wasted in units such as kb, mb, gb, tb. Example:

{
    "wastedMemorySize": "45.81mb",
    "wastedMemoryPercentage": "47.8%",
	:
	:    
	:
	:
}

JSON expression to read ‘wastedMemorySize’ and ‘wastedMemoryPercentage’ elements from the JSON response is:

$.wastedMemorySize
$.wastedMemoryPercentage

4. Object Count

You might also want to track the total number of objects that are present in the application’s memory. Object count can spike up because of inefficient code, new introduction of 3rd party libraries, frameworks. Too many objects can cause OutOfMemoryError, memory leak, CPU spike in production.

How to read Object count?

Total number of objects present in the application memory is reported in the ‘objectCount’ element. Example:

{
    "objectCount": "1,416,307",
    :
    :
    :
}  

JSON expression to read ‘objectCount’ element from the JSON response is:

$.objectCount

5. Class Count

You might also want to track the total number of classes that are present in the application’s memory. Sometimes class count can spike because of an introduction of any 3rd party libraries, frameworks. Spike in classes count, can cause problems in Metaspace/PermGen space of the memory.

How to read Class count?

Total number of objects present in the application memory is reported in the ‘classCount’ element. Example:

{
    "classCount": "471",
    :
    :
    :
}    

JSON expression to read ‘classCount’ elements from the JSON response is:

$.classCount

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: