[ 
https://issues.apache.org/jira/browse/CAMEL-21422?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17896959#comment-17896959
 ] 

Raymond commented on CAMEL-21422:
---------------------------------

The wikipedia page states:

"Therefore, it is not technically accurate that the 1-minute load average only 
includes the last 60 seconds of activity, as it includes 37% of the activity 
from the past, but it is correct to state that it includes _mostly_ the last 
minute. "

That's funny and good to know.

Note that I was already dealt with empty string like this:


 
{code:java}
public static BigDecimal parseBigDecimal(String value) {
if (value == null || value.isEmpty()) {
return BigDecimal.ZERO; // or handle as needed
}
return new BigDecimal(value);
}
 
{code}
Still, when I was putting a lot of load on some routes, and then I got numbers. 
However suddenly the strings were getting empty. Thus, even though the routes 
were processing data I got empty strings.

The problem was sometimes it worked, and sometimes it didn't. So couldn't find 
a good reproducible case. I can retest this with 4.9.0 if this now works after 
the PR. If not, I can try again to find a reproducible case.

> 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
>             Fix For: 4.9.0
>
>
> 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