groups:
  - id: attributes.jvm.memory
    type: attribute_group
    brief: "Describes JVM memory metric attributes."
    prefix: jvm.memory
    attributes:
      - id: type
        type:
          allow_custom_values: false
          members:
            - id: heap
              value: 'heap'
              brief: 'Heap memory.'
            - id: non_heap
              value: 'non_heap'
              brief: 'Non-heap memory'
        requirement_level: recommended
        brief: The type of memory.
        examples: ["heap", "non_heap"]
      - id: pool.name
        type: string
        requirement_level: recommended
        brief: Name of the memory pool.
        examples: ["G1 Old Gen", "G1 Eden space", "G1 Survivor Space"]
        note: >
          Pool names are generally obtained via
          [MemoryPoolMXBean#getName()](https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/MemoryPoolMXBean.html#getName()).

  - id: metric.jvm.memory.usage
    type: metric
    metric_name: jvm.memory.usage
    extends: attributes.jvm.memory
    brief: "Measure of memory used."
    instrument: updowncounter
    unit: "By"

  - id: metric.jvm.memory.committed
    type: metric
    metric_name: jvm.memory.committed
    extends: attributes.jvm.memory
    brief: "Measure of memory committed."
    instrument: updowncounter
    unit: "By"

  - id: metric.jvm.memory.limit
    type: metric
    metric_name: jvm.memory.limit
    extends: attributes.jvm.memory
    brief: "Measure of max obtainable memory."
    instrument: updowncounter
    unit: "By"

  - id: metric.jvm.memory.usage_after_last_gc
    type: metric
    metric_name: jvm.memory.usage_after_last_gc
    extends: attributes.jvm.memory
    brief: "Measure of memory used, as measured after the most recent garbage collection event on this pool."
    instrument: updowncounter
    unit: "By"

  - id: metric.jvm.gc.duration
    type: metric
    metric_name: jvm.gc.duration
    brief: "Duration of JVM garbage collection actions."
    instrument: histogram
    unit: "s"
    prefix: jvm.gc
    attributes:
      - id: name
        type: string
        requirement_level: recommended
        brief: Name of the garbage collector.
        examples: ["G1 Young Generation", "G1 Old Generation"]
        note: >
          Garbage collector name is generally obtained via
          [GarbageCollectionNotificationInfo#getGcName()](https://docs.oracle.com/en/java/javase/11/docs/api/jdk.management/com/sun/management/GarbageCollectionNotificationInfo.html#getGcName()).
      - id: action
        type: string
        requirement_level: recommended
        brief: Name of the garbage collector action.
        examples: ["end of minor GC", "end of major GC"]
        note: >
          Garbage collector action is generally obtained via
          [GarbageCollectionNotificationInfo#getGcAction()](https://docs.oracle.com/en/java/javase/11/docs/api/jdk.management/com/sun/management/GarbageCollectionNotificationInfo.html#getGcAction()).

  - id: metric.jvm.thread.count
    type: metric
    metric_name: jvm.thread.count
    brief: "Number of executing platform threads."
    instrument: updowncounter
    unit: "{thread}"
    attributes:
      - id: jvm.thread.daemon
        type: boolean
        requirement_level: recommended
        brief: "Whether the thread is daemon or not."
      - id: jvm.thread.state
        requirement_level: recommended
        type:
          allow_custom_values: false
          members:
            - id: new
              value: 'new'
              brief: 'A thread that has not yet started is in this state.'
            - id: runnable
              value: 'runnable'
              brief: 'A thread executing in the Java virtual machine is in this state.'
            - id: blocked
              value: 'blocked'
              brief: 'A thread that is blocked waiting for a monitor lock is in this state.'
            - id: waiting
              value: 'waiting'
              brief: 'A thread that is waiting indefinitely for another thread to perform a particular action is in this state.'
            - id: timed_waiting
              value: 'timed_waiting'
              brief: 'A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.'
            - id: terminated
              value: 'terminated'
              brief: 'A thread that has exited is in this state.'
        brief: "State of the thread."
        examples: ["runnable", "blocked"]

  - id: metric.jvm.class.loaded
    type: metric
    metric_name: jvm.class.loaded
    brief: "Number of classes loaded since JVM start."
    instrument: counter
    unit: "{class}"

  - id: metric.jvm.class.unloaded
    type: metric
    metric_name: jvm.class.unloaded
    brief: "Number of classes unloaded since JVM start."
    instrument: counter
    unit: "{class}"

  - id: metric.jvm.class.count
    type: metric
    metric_name: jvm.class.count
    brief: "Number of classes currently loaded."
    instrument: updowncounter
    unit: "{class}"

  - id: metric.jvm.cpu.count
    type: metric
    metric_name: jvm.cpu.count
    brief: "Number of processors available to the Java virtual machine."
    instrument: updowncounter
    unit: "{cpu}"

  - id: metric.jvm.cpu.time
    type: metric
    metric_name: jvm.cpu.time
    brief: "CPU time used by the process as reported by the JVM."
    instrument: counter
    unit: "s"

  - id: metric.jvm.cpu.recent_utilization
    type: metric
    metric_name: jvm.cpu.recent_utilization
    brief: "Recent CPU utilization for the process as reported by the JVM."
    note: >
      The value range is [0.0,1.0].
      This utilization is not defined as being for the specific interval since last measurement
      (unlike `system.cpu.utilization`).
      [Reference](https://docs.oracle.com/en/java/javase/17/docs/api/jdk.management/com/sun/management/OperatingSystemMXBean.html#getProcessCpuLoad()).
    instrument: gauge
    unit: "1"
