Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Statistics Objects always return null despite change in container stats #2383

Copy link
Copy link
Open
@DeshyDan

Description

@DeshyDan
Issue body actions

Description

When calling getContainerStats(String containerId), the Statistics object returned is null, even though the logs show a value. Specifically, when calling cpuUsage.getTotalUsage(), the function returns null, but the log output suggests that a value is present.

Code Sample

Here is the code used to retrieve container stats:

public Statistics getContainerStats(String containerId) {  
    InvocationBuilder.AsyncResultCallback<Statistics> callback = new InvocationBuilder.AsyncResultCallback<>();  
    dockerClient.statsCmd(containerId).exec(callback);  
    Statistics stats;  
    try {  
        stats = callback.awaitResult();  
        callback.close();  
    } catch (IOException e) {  
        log.error("Failed to get container stats: {}", containerId, e);  
        throw new RuntimeException("Failed to get container stats", e);  
    }  
    return stats;  
}

To fetch CPU usage:

private long getTotalCpuUsage(CpuStatsConfig cpuStats) {  
    CpuUsageConfig cpuUsage = cpuStats.getCpuUsage();  
    log.info("Total CPU usage: {}", cpuUsage.getTotalUsage());  
    return cpuUsage.getTotalUsage();  
}

Observed Behavior

  • The cpuUsage.getTotalUsage() method always returns null.
  • However, the log statement log.info("Total CPU usage: {}", cpuUsage.getTotalUsage()); correctly displays a value.

Expected Behavior

  • cpuUsage.getTotalUsage() should return the same value as seen in the logs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.