Skip to content

Commit 5c66b8e

Browse files
committed
[jmx-scraper] Create weaver model for jmx-scraper metrics #2072
- created metrics.yaml weaver model - created attriutes.yaml - tested with weaver registry generate
1 parent 091ebd2 commit 5c66b8e

File tree

6 files changed

+241
-0
lines changed

6 files changed

+241
-0
lines changed

jmx-scraper/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# https://github.com/open-telemetry/weaver/releases
2+
# v0.18.0
3+
WEAVER_CONTAINER=otel/weaver@sha256:5425ade81dc22ddd840902b0638b4b6a9186fb654c5b50c1d1ccd31299437390
4+
5+
# Next - we want to run docker as our local file user, so generated code is not
6+
# owned by root, and we don't give unecessary access.
7+
#
8+
# Determine if "docker" is actually podman
9+
DOCKER_VERSION_OUTPUT := $(shell docker --version 2>&1)
10+
DOCKER_IS_PODMAN := $(shell echo $(DOCKER_VERSION_OUTPUT) | grep -c podman)
11+
ifeq ($(DOCKER_IS_PODMAN),0)
12+
DOCKER_COMMAND := docker
13+
else
14+
DOCKER_COMMAND := podman
15+
endif
16+
DOCKER_RUN=$(DOCKER_COMMAND) run
17+
DOCKER_USER=$(shell id -u):$(shell id -g)
18+
DOCKER_USER_IS_HOST_USER_ARG=-u $(DOCKER_USER)
19+
ifeq ($(DOCKER_COMMAND),podman)
20+
# On podman, additional arguments are needed to make "-u" work
21+
# correctly with the host user ID and host group ID.
22+
#
23+
# Error: OCI runtime error: crun: setgroups: Invalid argument
24+
DOCKER_USER_IS_HOST_USER_ARG=--userns=keep-id -u $(DOCKER_USER)
25+
endif
26+
27+
28+
.PHONY: generate-metadata
29+
generate-metadata:
30+
$(DOCKER_RUN) \
31+
$(DOCKER_USER_IS_HOST_USER_ARG) \
32+
--mount 'type=bind,source=$(PWD)/model,target=/home/weaver/model,readonly' \
33+
--mount 'type=bind,source=$(PWD)/templates,target=/home/weaver/templates,readonly' \
34+
--mount 'type=bind,source=$(PWD)/,target=/home/weaver/target' \
35+
${WEAVER_CONTAINER} registry generate \
36+
--registry=/home/weaver/model \
37+
metadata \
38+
--future \
39+
/home/weaver/target

jmx-scraper/model/attributes.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
groups:
2+
- id: metric.attributes
3+
type: attribute_group
4+
brief: "Metric attributes."
5+
attributes:
6+
- id: pool.name
7+
brief: "Pool name."
8+
type: string
9+
stability: beta
10+
examples: [ "Memory pool 1", "Code Cache", "Metaspace", "Compressed Class Space"]
11+
12+
- id: gc.name
13+
brief: "Garbage Collector name."
14+
type: string
15+
stability: beta
16+
examples: [ "Parallel GC", "G1 Young Generation"]

jmx-scraper/model/metrics.yaml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
groups:
2+
- id: jvm.class.loaded
3+
type: metric
4+
brief: "Number of classes loaded by the JVM."
5+
metric_name: jvm.class.loaded
6+
instrument: updowncounter
7+
unit: "{class}"
8+
stability: beta
9+
10+
- id: jvm.gc.collections.count
11+
type: metric
12+
brief: "Total number of garbage collection that have occurred."
13+
metric_name: jvm.gc.collections.count
14+
instrument: counter
15+
unit: "{collection}"
16+
stability: beta
17+
attributes:
18+
- ref: gc.name
19+
requirement_level: required
20+
21+
- id: jvm.gc.collections.elapsed
22+
type: metric
23+
brief: "Approximate accumulated garbage collection elapsed time in milliseconds."
24+
metric_name: jvm.gc.collections.elapsed
25+
instrument: counter
26+
unit: ms
27+
stability: beta
28+
attributes:
29+
- ref: gc.name
30+
requirement_level: required
31+
32+
- id: jvm.memory.heap.committed
33+
type: metric
34+
brief: "Current committed heap memory usage."
35+
metric_name: jvm.memory.heap.committed
36+
instrument: gauge
37+
unit: By
38+
stability: beta
39+
40+
- id: jvm.memory.heap.init
41+
type: metric
42+
brief: "Initial heap memory usage."
43+
metric_name: jvm.memory.heap.init
44+
instrument: gauge
45+
unit: By
46+
stability: beta
47+
48+
- id: jvm.memory.heap.max
49+
type: metric
50+
brief: "Maximum heap memory usage."
51+
metric_name: jvm.memory.heap.max
52+
instrument: gauge
53+
unit: By
54+
stability: beta
55+
56+
- id: jvm.memory.heap.used
57+
type: metric
58+
brief: "Current heap memory usage."
59+
metric_name: jvm.memory.heap.used
60+
instrument: gauge
61+
unit: By
62+
stability: beta
63+
64+
- id: jvm.memory.nonheap.committed
65+
type: metric
66+
brief: "Current committed non-heap memory usage."
67+
metric_name: jvm.memory.nonheap.committed
68+
instrument: gauge
69+
unit: By
70+
stability: beta
71+
72+
- id: jvm.memory.nonheap.init
73+
type: metric
74+
brief: "Initial non-heap memory usage."
75+
metric_name: jvm.memory.nonheap.init
76+
instrument: gauge
77+
unit: By
78+
stability: beta
79+
80+
- id: jvm.memory.nonheap.max
81+
type: metric
82+
brief: "Maximum non-heap memory usage."
83+
metric_name: jvm.memory.nonheap.max
84+
instrument: gauge
85+
unit: By
86+
stability: beta
87+
88+
- id: jvm.memory.nonheap.used
89+
type: metric
90+
brief: "Current non-heap memory usage."
91+
metric_name: jvm.memory.nonheap.used
92+
instrument: gauge
93+
unit: By
94+
stability: beta
95+
96+
- id: jvm.memory.pool.committed
97+
type: metric
98+
brief: "Current memory pool committed usage."
99+
metric_name: jvm.memory.pool.committed
100+
instrument: gauge
101+
unit: By
102+
stability: beta
103+
attributes:
104+
- ref: pool.name
105+
requirement_level: required
106+
107+
- id: jvm.memory.pool.init
108+
type: metric
109+
brief: "Initial memory pool usage."
110+
metric_name: jvm.memory.pool.init
111+
instrument: gauge
112+
unit: By
113+
stability: beta
114+
attributes:
115+
- ref: pool.name
116+
requirement_level: required
117+
118+
- id: jvm.memory.pool.max
119+
type: metric
120+
brief: "Maximum memory pool usage."
121+
metric_name: jvm.memory.pool.max
122+
instrument: gauge
123+
unit: By
124+
stability: beta
125+
attributes:
126+
- ref: pool.name
127+
requirement_level: required
128+
129+
- id: jvm.memory.pool.used
130+
type: metric
131+
brief: "Current memory pool used usage."
132+
metric_name: jvm.memory.pool.used
133+
instrument: gauge
134+
unit: By
135+
stability: beta
136+
attributes:
137+
- ref: pool.name
138+
requirement_level: required
139+
140+
- id: jvm.threads.count
141+
type: metric
142+
brief: "Current number of thread count"
143+
metric_name: jvm.threads.count
144+
instrument: gauge
145+
unit: "{thread}"
146+
stability: beta
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: JMX scraper
2+
semconv_version: v0.1.0
3+
schema_base_url: https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/jmx-scraper/model
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
type: jmxscraper
2+
3+
status:
4+
class: jvm
5+
stability:
6+
beta: [metrics]
7+
distributions: [contrib]
8+
codeowners:
9+
active: [mcmho]
10+
seeking_new: true
11+
12+
attributes:
13+
{% for attr in (ctx.groups | selectattr("id", "equalto", "metric.attributes") | first).attributes %} {{ attr.name | safe }}:
14+
description: {{ attr.brief | safe }}
15+
type: {{ attr.type | safe }}
16+
{% endfor %}
17+
metrics:
18+
{% for m in ctx.groups | selectattr("type", "equalto", "metric") %} {{ m.id | safe }}:
19+
description: {{ m.brief | safe }}
20+
{% if m.instrument == "counter" %}sum:
21+
aggregation_temporality: cumulative
22+
monotonic: true
23+
value_type: int
24+
{% elif m.instrument == "updowncounter" %}sum:
25+
monotonic: false
26+
aggregation_temporality: cumulative
27+
value_type: int
28+
{% else %}gauge:
29+
value_type: int
30+
{% endif %}unit: {{ m.unit }}
31+
{% if m.attributes %} attributes:{% for attr in m.attributes %}
32+
- {{ attr.name | safe }}{% endfor %}
33+
{% endif %}{% endfor %}

jmx-scraper/weaver.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
templates:
2+
- pattern: metadata.yaml.j2
3+
filter: '.'
4+
application_mode: single

0 commit comments

Comments
 (0)