[ 
https://issues.apache.org/jira/browse/CAMEL-21422?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Raymond updated CAMEL-21422:
----------------------------
    Description: 
The ManagedRoute class 
([https://www.javadoc.io/doc/org.apache.camel/camel-management/latest/org/apache/camel/management/mbean/ManagedRoute.html)]
 has three methods to get the CPU Usage:

{{[getLoad01|https://www.javadoc.io/static/org.apache.camel/camel-management/4.8.1/org/apache/camel/management/mbean/ManagedRoute.html#getLoad01()]()}}
{{[getLoad0|https://www.javadoc.io/static/org.apache.camel/camel-management/4.8.1/org/apache/camel/management/mbean/ManagedRoute.html#getLoad01()]5()}}
{{[getLoad|https://www.javadoc.io/static/org.apache.camel/camel-management/4.8.1/org/apache/camel/management/mbean/ManagedRoute.html#getLoad01()]15()}}

{{I noticed a bug and maybe also things that could be improved:}}

{{1. Empty string}}

{{The methods sometimes return an empty string. As I like to do calculations 
and tried to convert it to a BigDecimal I}} sometimes got:
{code:java}
java.lang.NumberFormatException: null at 
java.base/java.math.BigDecimal.<init>(BigDecimal.java:703){code}
{color:#1d1c1d}
Probably better to always at least return 0

Note that statistics are enabled:
{color}
{code:java}
//enable performance stats
context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.RoutesOnly);
context.getManagementStrategy().getManagementAgent().setLoadStatisticsEnabled(true);{code}

{color:#1d1c1d}But sometimes it still gives an empty (as like if it suddenly 
turned off). I don't know how to properly reproduce it, but I started like 100 
routes, and measure the CPU. At first, it goes well, but after a while it 
returns empty values. According to a check, the statistics is still enabled at 
the time. 

2. Return type

The default return type is a String. As I understand this is a percentage, I 
would expect a return type that match that, like a BigDecimal (or a two decimal 
Double)

3. Method name

The name of the method is getLoad01(). This seems unclear:

What does load mean (cpu, network, memory)? And what does 01 mean?

Maybe 

BigDecimal cpuLoad = managedRoute.getCPULoad(LoadInterval.1minute)

Where loadInterval is an enumeration with all possible (int) values.

4. Time interval

If possible,{color}{color:#1d1c1d} that time interval could have more options 
between 1 minute to 1 hour.

5. Three decimals

To really get fine-grained statistics (especially on very powerful machine), a 
CPU stastics on three decimals would be helpful


--------------------------------------


{color}

 

  was:
The ManagedRoute class 
([https://www.javadoc.io/doc/org.apache.camel/camel-management/latest/org/apache/camel/management/mbean/ManagedRoute.html)]
 has three methods to get the CPU Usage:

{{[getLoad01|https://www.javadoc.io/static/org.apache.camel/camel-management/4.8.1/org/apache/camel/management/mbean/ManagedRoute.html#getLoad01()]()}}
{{[getLoad0|https://www.javadoc.io/static/org.apache.camel/camel-management/4.8.1/org/apache/camel/management/mbean/ManagedRoute.html#getLoad01()]5()}}
{{[getLoad|https://www.javadoc.io/static/org.apache.camel/camel-management/4.8.1/org/apache/camel/management/mbean/ManagedRoute.html#getLoad01()]15()}}

{{I noticed things that could be improved:}}

{{1. Empty string}}

{{The methods sometimes return an empty string. As I like to do calculations 
and tried to convert it to a BigDecimal I}} sometimes got:
{code:java}
java.lang.NumberFormatException: null at 
java.base/java.math.BigDecimal.<init>(BigDecimal.java:703){code}
{color:#1d1c1d}
Probably better to always at least return 0

Note that statistics are enabled:

{color}
{color:#808080}//enable performance stats
{color}{color:#9876aa}context{color}.getManagementStrategy().getManagementAgent().setLoadStatisticsEnabled({color:#cc7832}true{color}){color:#cc7832};{color}
{color:#1d1c1d}
But sometimes it still gives an empty (as if it suddenly turned off)

2. Return type

The default return type is a String. As I understand this is a percentage, I 
would expect a return type that match that, like a BigDecimal (or a two decimal 
Double)

3. Method name

The name of the method is getLoad01(). This seems unclear:

What does load mean (cpu, network, memory)? And what does 01 mean?

Maybe 

BigDecimal cpuLoad = managedRoute.getCPULoad(LoadInterval.1minute)

Where loadInterval is an enumeration with all possible (int) values.

4. Time interval

If possible,{color}{color:#1d1c1d} that time interval could have more options 
between 1 minute to 1 hour.

5. Three decimals

To really get fine-grained statistics (especially on very powerful machine), a 
CPU stastics on three decimals would be helpful


--------------------------------------



{color}


> CPU Load sometimes returns empty String
> ---------------------------------------
>
>                 Key: CAMEL-21422
>                 URL: https://issues.apache.org/jira/browse/CAMEL-21422
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-management
>    Affects Versions: 4.8.1
>            Reporter: Raymond
>            Priority: Minor
>
> The ManagedRoute class 
> ([https://www.javadoc.io/doc/org.apache.camel/camel-management/latest/org/apache/camel/management/mbean/ManagedRoute.html)]
>  has three methods to get the CPU Usage:
> {{[getLoad01|https://www.javadoc.io/static/org.apache.camel/camel-management/4.8.1/org/apache/camel/management/mbean/ManagedRoute.html#getLoad01()]()}}
> {{[getLoad0|https://www.javadoc.io/static/org.apache.camel/camel-management/4.8.1/org/apache/camel/management/mbean/ManagedRoute.html#getLoad01()]5()}}
> {{[getLoad|https://www.javadoc.io/static/org.apache.camel/camel-management/4.8.1/org/apache/camel/management/mbean/ManagedRoute.html#getLoad01()]15()}}
> {{I noticed a bug and maybe also things that could be improved:}}
> {{1. Empty string}}
> {{The methods sometimes return an empty string. As I like to do calculations 
> and tried to convert it to a BigDecimal I}} sometimes got:
> {code:java}
> java.lang.NumberFormatException: null at 
> java.base/java.math.BigDecimal.<init>(BigDecimal.java:703){code}
> {color:#1d1c1d}
> Probably better to always at least return 0
> Note that statistics are enabled:
> {color}
> {code:java}
> //enable performance stats
> context.getManagementStrategy().getManagementAgent().setStatisticsLevel(ManagementStatisticsLevel.RoutesOnly);
> context.getManagementStrategy().getManagementAgent().setLoadStatisticsEnabled(true);{code}
> {color:#1d1c1d}But sometimes it still gives an empty (as like if it suddenly 
> turned off). I don't know how to properly reproduce it, but I started like 
> 100 routes, and measure the CPU. At first, it goes well, but after a while it 
> returns empty values. According to a check, the statistics is still enabled 
> at the time. 
> 2. Return type
> The default return type is a String. As I understand this is a percentage, I 
> would expect a return type that match that, like a BigDecimal (or a two 
> decimal Double)
> 3. Method name
> The name of the method is getLoad01(). This seems unclear:
> What does load mean (cpu, network, memory)? And what does 01 mean?
> Maybe 
> BigDecimal cpuLoad = managedRoute.getCPULoad(LoadInterval.1minute)
> Where loadInterval is an enumeration with all possible (int) values.
> 4. Time interval
> If possible,{color}{color:#1d1c1d} that time interval could have more options 
> between 1 minute to 1 hour.
> 5. Three decimals
> To really get fine-grained statistics (especially on very powerful machine), 
> a CPU stastics on three decimals would be helpful
> --------------------------------------
> {color}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to