Skip to content

Add JVM metrics for total heap memory usage from MemoryMXBean #519

@liustanley

Description

@liustanley

I opened open-telemetry/opentelemetry-java-instrumentation#9859 and was told to open an issue here in the specification in order to propose this change.

Is your feature request related to a problem? Please describe.

The heap memory JVM metrics are currently being obtained from MemoryPoolMXBean.

I'm having difficulty calculating the correct maximum total values from the current jvm.memory.* metrics because they're divided by the memory pool attribute. For example, if I want to calculate the maximum total heap memory usage, it's possible to sum up the values from:

max:process.runtime.jvm.memory.usage{type:heap, pool:eden_space} + max:process.runtime.jvm.memory.usage{type:heap, pool:tenured_gen} + max:process.runtime.jvm.memory.usage{type:heap, pool:survivor_space}

But if a service has multiple JVM instances, then it becomes difficult to distinguish between the JVM instances and this query will sum across all JVM instances in this service.

If there was another metric for process.runtime.jvm.total.memory.usage (from MemoryMXBean), then we could query max:process.runtime.jvm.total.memory.usage{type:heap} for the correct total maximum heap memory across all JVM instances in the same service.

Describe the solution you'd like

I'd like to add the following heap memory JVM metrics from MemoryMXBean:

  • process.runtime.jvm.total.memory.usage
  • process.runtime.jvm.total.memory.committed
  • process.runtime.jvm.total.memory.init
  • process.runtime.jvm.total.memory.limit

I can help open a PR for this if the feature request is approved.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions