From 7199c5be88199db08760387bc8f82099e8d8ed28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Qu=C3=A9rel?= <l.querel@f5.com> Date: Wed, 31 Jul 2024 04:54:17 -0700 Subject: [PATCH] chore(jq): Fix metric order in JQ filters (issue #268) (#275) --- Cargo.lock | 60 ++---- .../semconv_jq_fn/semconv_metrics.json | 2 +- .../expected_output/test/metric/jvm.md | 178 +++++++++--------- .../expected_output/test/metrics.md | 178 +++++++++--------- .../weaver_forge/templates/test/weaver.yaml | 30 ++- defaults/jq/semconv.jq | 12 +- 6 files changed, 222 insertions(+), 238 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d053bc51..1637325d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,7 +39,7 @@ dependencies = [ "once_cell", "serde", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -222,15 +222,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "bit-set" version = "0.5.3" @@ -1797,9 +1788,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hifijson" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18ae468bcb4dfecf0e4949ee28abbc99076b6a0077f51ddbc94dbfff8e6a870c" +checksum = "9958ab3ce3170c061a27679916bd9b969eceeb5e8b120438e6751d0987655c42" [[package]] name = "hmac" @@ -2099,20 +2090,18 @@ dependencies = [ [[package]] name = "jaq-std" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6e83f491752a1bbc4fa05a8e80d4ce1139119f9c3fd8e3400b604776c2e0129" +checksum = "bfbaa55578fd3b70433b594a370741e0c364e4afff92cc0099623fce87311bc1" dependencies = [ - "bincode", - "jaq-parse", "jaq-syn", ] [[package]] name = "jaq-syn" -version = "1.1.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4d60101fb791b20c982731d848ed6e7d25363656497647c2093b68bd88398d6" +checksum = "1ba44fe4428c71304604261ecbae047ee9cfb60c4f1a6bd222ebbb31726d3948" dependencies = [ "serde", ] @@ -2255,9 +2244,9 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" dependencies = [ "hashbrown", ] @@ -2794,11 +2783,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +checksum = "2288c0e17cc8d342c712bb43a257a80ebffce59cdb33d5000d8348f3ec02528b" dependencies = [ - "zerocopy 0.6.6", + "zerocopy", + "zerocopy-derive", ] [[package]] @@ -4631,34 +4621,14 @@ dependencies = [ "toml", ] -[[package]] -name = "zerocopy" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" -dependencies = [ - "byteorder", - "zerocopy-derive 0.6.6", -] - [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy-derive" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "byteorder", + "zerocopy-derive", ] [[package]] diff --git a/crates/weaver_forge/expected_output/semconv_jq_fn/semconv_metrics.json b/crates/weaver_forge/expected_output/semconv_jq_fn/semconv_metrics.json index 0ecb7806..c203bf46 100644 --- a/crates/weaver_forge/expected_output/semconv_jq_fn/semconv_metrics.json +++ b/crates/weaver_forge/expected_output/semconv_jq_fn/semconv_metrics.json @@ -1 +1 @@ -[{"metrics":[{"attributes":[{"brief":"The type of memory.","examples":["heap","non_heap"],"name":"jvm.memory.type","requirement_level":"recommended","stability":"stable","type":{"allow_custom_values":false,"members":[{"brief":"Heap memory.","deprecated":null,"id":"heap","note":null,"stability":null,"value":"heap"},{"brief":"Non-heap memory","deprecated":null,"id":"non_heap","note":null,"stability":null,"value":"non_heap"}]}},{"brief":"Name of the memory pool.","examples":["G1 Old Gen","G1 Eden space","G1 Survivor Space"],"name":"jvm.memory.pool.name","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()).\n","requirement_level":"recommended","stability":"stable","type":"string"}],"brief":"Measure of memory used.","events":[],"id":"metric.jvm.memory.used","instrument":"updowncounter","lineage":{"attributes":{"jvm.memory.pool.name":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"},"jvm.memory.type":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"}},"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.memory.used","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"By"},{"attributes":[{"brief":"The type of memory.","examples":["heap","non_heap"],"name":"jvm.memory.type","requirement_level":"recommended","stability":"stable","type":{"allow_custom_values":false,"members":[{"brief":"Heap memory.","deprecated":null,"id":"heap","note":null,"stability":null,"value":"heap"},{"brief":"Non-heap memory","deprecated":null,"id":"non_heap","note":null,"stability":null,"value":"non_heap"}]}},{"brief":"Name of the memory pool.","examples":["G1 Old Gen","G1 Eden space","G1 Survivor Space"],"name":"jvm.memory.pool.name","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()).\n","requirement_level":"recommended","stability":"stable","type":"string"}],"brief":"Measure of memory committed.","events":[],"id":"metric.jvm.memory.committed","instrument":"updowncounter","lineage":{"attributes":{"jvm.memory.pool.name":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"},"jvm.memory.type":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"}},"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.memory.committed","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"By"},{"attributes":[{"brief":"The type of memory.","examples":["heap","non_heap"],"name":"jvm.memory.type","requirement_level":"recommended","stability":"stable","type":{"allow_custom_values":false,"members":[{"brief":"Heap memory.","deprecated":null,"id":"heap","note":null,"stability":null,"value":"heap"},{"brief":"Non-heap memory","deprecated":null,"id":"non_heap","note":null,"stability":null,"value":"non_heap"}]}},{"brief":"Name of the memory pool.","examples":["G1 Old Gen","G1 Eden space","G1 Survivor Space"],"name":"jvm.memory.pool.name","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()).\n","requirement_level":"recommended","stability":"stable","type":"string"}],"brief":"Measure of max obtainable memory.","events":[],"id":"metric.jvm.memory.limit","instrument":"updowncounter","lineage":{"attributes":{"jvm.memory.pool.name":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"},"jvm.memory.type":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"}},"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.memory.limit","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"By"},{"attributes":[{"brief":"The type of memory.","examples":["heap","non_heap"],"name":"jvm.memory.type","requirement_level":"recommended","stability":"stable","type":{"allow_custom_values":false,"members":[{"brief":"Heap memory.","deprecated":null,"id":"heap","note":null,"stability":null,"value":"heap"},{"brief":"Non-heap memory","deprecated":null,"id":"non_heap","note":null,"stability":null,"value":"non_heap"}]}},{"brief":"Name of the memory pool.","examples":["G1 Old Gen","G1 Eden space","G1 Survivor Space"],"name":"jvm.memory.pool.name","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()).\n","requirement_level":"recommended","stability":"stable","type":"string"}],"brief":"Measure of memory used, as measured after the most recent garbage collection event on this pool.","events":[],"id":"metric.jvm.memory.used_after_last_gc","instrument":"updowncounter","lineage":{"attributes":{"jvm.memory.pool.name":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"},"jvm.memory.type":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"}},"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.memory.used_after_last_gc","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"By"},{"attributes":[{"brief":"Name of the garbage collector.","examples":["G1 Young Generation","G1 Old Generation"],"name":"jvm.gc.name","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()).\n","requirement_level":"recommended","stability":"stable","type":"string"},{"brief":"Name of the garbage collector action.","examples":["end of minor GC","end of major GC"],"name":"jvm.gc.action","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()).\n","requirement_level":"recommended","stability":"stable","type":"string"}],"brief":"Duration of JVM garbage collection actions.","events":[],"id":"metric.jvm.gc.duration","instrument":"histogram","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.gc.duration","name":null,"prefix":"jvm.gc","root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"s"},{"attributes":[{"brief":"Whether the thread is daemon or not.","name":"jvm.thread.daemon","requirement_level":"recommended","stability":"stable","type":"boolean"},{"brief":"State of the thread.","examples":["runnable","blocked"],"name":"jvm.thread.state","requirement_level":"recommended","stability":"stable","type":{"allow_custom_values":false,"members":[{"brief":"A thread that has not yet started is in this state.","deprecated":null,"id":"new","note":null,"stability":null,"value":"new"},{"brief":"A thread executing in the Java virtual machine is in this state.","deprecated":null,"id":"runnable","note":null,"stability":null,"value":"runnable"},{"brief":"A thread that is blocked waiting for a monitor lock is in this state.","deprecated":null,"id":"blocked","note":null,"stability":null,"value":"blocked"},{"brief":"A thread that is waiting indefinitely for another thread to perform a particular action is in this state.","deprecated":null,"id":"waiting","note":null,"stability":null,"value":"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.","deprecated":null,"id":"timed_waiting","note":null,"stability":null,"value":"timed_waiting"},{"brief":"A thread that has exited is in this state.","deprecated":null,"id":"terminated","note":null,"stability":null,"value":"terminated"}]}}],"brief":"Number of executing platform threads.","events":[],"id":"metric.jvm.thread.count","instrument":"updowncounter","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.thread.count","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"{thread}"},{"attributes":[],"brief":"Number of classes loaded since JVM start.","events":[],"id":"metric.jvm.class.loaded","instrument":"counter","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.class.loaded","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"{class}"},{"attributes":[],"brief":"Number of classes unloaded since JVM start.","events":[],"id":"metric.jvm.class.unloaded","instrument":"counter","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.class.unloaded","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"{class}"},{"attributes":[],"brief":"Number of classes currently loaded.","events":[],"id":"metric.jvm.class.count","instrument":"updowncounter","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.class.count","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"{class}"},{"attributes":[],"brief":"Number of processors available to the Java virtual machine.","events":[],"id":"metric.jvm.cpu.count","instrument":"updowncounter","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.cpu.count","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"{cpu}"},{"attributes":[],"brief":"CPU time used by the process as reported by the JVM.","events":[],"id":"metric.jvm.cpu.time","instrument":"counter","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.cpu.time","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"s"},{"attributes":[],"brief":"Recent CPU utilization for the process as reported by the JVM.","events":[],"id":"metric.jvm.cpu.recent_utilization","instrument":"gauge","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.cpu.recent_utilization","name":null,"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()).\n","root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"1"}],"root_namespace":"jvm"}] \ No newline at end of file +[{"metrics":[{"attributes":[],"brief":"Number of classes currently loaded.","events":[],"id":"metric.jvm.class.count","instrument":"updowncounter","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.class.count","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"{class}"},{"attributes":[],"brief":"Number of classes loaded since JVM start.","events":[],"id":"metric.jvm.class.loaded","instrument":"counter","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.class.loaded","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"{class}"},{"attributes":[],"brief":"Number of classes unloaded since JVM start.","events":[],"id":"metric.jvm.class.unloaded","instrument":"counter","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.class.unloaded","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"{class}"},{"attributes":[],"brief":"Number of processors available to the Java virtual machine.","events":[],"id":"metric.jvm.cpu.count","instrument":"updowncounter","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.cpu.count","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"{cpu}"},{"attributes":[],"brief":"Recent CPU utilization for the process as reported by the JVM.","events":[],"id":"metric.jvm.cpu.recent_utilization","instrument":"gauge","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.cpu.recent_utilization","name":null,"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()).\n","root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"1"},{"attributes":[],"brief":"CPU time used by the process as reported by the JVM.","events":[],"id":"metric.jvm.cpu.time","instrument":"counter","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.cpu.time","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"s"},{"attributes":[{"brief":"Name of the garbage collector.","examples":["G1 Young Generation","G1 Old Generation"],"name":"jvm.gc.name","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()).\n","requirement_level":"recommended","stability":"stable","type":"string"},{"brief":"Name of the garbage collector action.","examples":["end of minor GC","end of major GC"],"name":"jvm.gc.action","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()).\n","requirement_level":"recommended","stability":"stable","type":"string"}],"brief":"Duration of JVM garbage collection actions.","events":[],"id":"metric.jvm.gc.duration","instrument":"histogram","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.gc.duration","name":null,"prefix":"jvm.gc","root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"s"},{"attributes":[{"brief":"The type of memory.","examples":["heap","non_heap"],"name":"jvm.memory.type","requirement_level":"recommended","stability":"stable","type":{"allow_custom_values":false,"members":[{"brief":"Heap memory.","deprecated":null,"id":"heap","note":null,"stability":null,"value":"heap"},{"brief":"Non-heap memory","deprecated":null,"id":"non_heap","note":null,"stability":null,"value":"non_heap"}]}},{"brief":"Name of the memory pool.","examples":["G1 Old Gen","G1 Eden space","G1 Survivor Space"],"name":"jvm.memory.pool.name","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()).\n","requirement_level":"recommended","stability":"stable","type":"string"}],"brief":"Measure of memory committed.","events":[],"id":"metric.jvm.memory.committed","instrument":"updowncounter","lineage":{"attributes":{"jvm.memory.pool.name":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"},"jvm.memory.type":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"}},"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.memory.committed","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"By"},{"attributes":[{"brief":"The type of memory.","examples":["heap","non_heap"],"name":"jvm.memory.type","requirement_level":"recommended","stability":"stable","type":{"allow_custom_values":false,"members":[{"brief":"Heap memory.","deprecated":null,"id":"heap","note":null,"stability":null,"value":"heap"},{"brief":"Non-heap memory","deprecated":null,"id":"non_heap","note":null,"stability":null,"value":"non_heap"}]}},{"brief":"Name of the memory pool.","examples":["G1 Old Gen","G1 Eden space","G1 Survivor Space"],"name":"jvm.memory.pool.name","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()).\n","requirement_level":"recommended","stability":"stable","type":"string"}],"brief":"Measure of max obtainable memory.","events":[],"id":"metric.jvm.memory.limit","instrument":"updowncounter","lineage":{"attributes":{"jvm.memory.pool.name":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"},"jvm.memory.type":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"}},"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.memory.limit","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"By"},{"attributes":[{"brief":"The type of memory.","examples":["heap","non_heap"],"name":"jvm.memory.type","requirement_level":"recommended","stability":"stable","type":{"allow_custom_values":false,"members":[{"brief":"Heap memory.","deprecated":null,"id":"heap","note":null,"stability":null,"value":"heap"},{"brief":"Non-heap memory","deprecated":null,"id":"non_heap","note":null,"stability":null,"value":"non_heap"}]}},{"brief":"Name of the memory pool.","examples":["G1 Old Gen","G1 Eden space","G1 Survivor Space"],"name":"jvm.memory.pool.name","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()).\n","requirement_level":"recommended","stability":"stable","type":"string"}],"brief":"Measure of memory used.","events":[],"id":"metric.jvm.memory.used","instrument":"updowncounter","lineage":{"attributes":{"jvm.memory.pool.name":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"},"jvm.memory.type":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"}},"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.memory.used","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"By"},{"attributes":[{"brief":"The type of memory.","examples":["heap","non_heap"],"name":"jvm.memory.type","requirement_level":"recommended","stability":"stable","type":{"allow_custom_values":false,"members":[{"brief":"Heap memory.","deprecated":null,"id":"heap","note":null,"stability":null,"value":"heap"},{"brief":"Non-heap memory","deprecated":null,"id":"non_heap","note":null,"stability":null,"value":"non_heap"}]}},{"brief":"Name of the memory pool.","examples":["G1 Old Gen","G1 Eden space","G1 Survivor Space"],"name":"jvm.memory.pool.name","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()).\n","requirement_level":"recommended","stability":"stable","type":"string"}],"brief":"Measure of memory used, as measured after the most recent garbage collection event on this pool.","events":[],"id":"metric.jvm.memory.used_after_last_gc","instrument":"updowncounter","lineage":{"attributes":{"jvm.memory.pool.name":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"},"jvm.memory.type":{"inherited_fields":["brief","examples","note","requirement_level","stability"],"source_group":"attributes.jvm.memory"}},"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.memory.used_after_last_gc","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"By"},{"attributes":[{"brief":"Whether the thread is daemon or not.","name":"jvm.thread.daemon","requirement_level":"recommended","stability":"stable","type":"boolean"},{"brief":"State of the thread.","examples":["runnable","blocked"],"name":"jvm.thread.state","requirement_level":"recommended","stability":"stable","type":{"allow_custom_values":false,"members":[{"brief":"A thread that has not yet started is in this state.","deprecated":null,"id":"new","note":null,"stability":null,"value":"new"},{"brief":"A thread executing in the Java virtual machine is in this state.","deprecated":null,"id":"runnable","note":null,"stability":null,"value":"runnable"},{"brief":"A thread that is blocked waiting for a monitor lock is in this state.","deprecated":null,"id":"blocked","note":null,"stability":null,"value":"blocked"},{"brief":"A thread that is waiting indefinitely for another thread to perform a particular action is in this state.","deprecated":null,"id":"waiting","note":null,"stability":null,"value":"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.","deprecated":null,"id":"timed_waiting","note":null,"stability":null,"value":"timed_waiting"},{"brief":"A thread that has exited is in this state.","deprecated":null,"id":"terminated","note":null,"stability":null,"value":"terminated"}]}}],"brief":"Number of executing platform threads.","events":[],"id":"metric.jvm.thread.count","instrument":"updowncounter","lineage":{"source_file":"data/jvm-metrics.yaml"},"metric_name":"jvm.thread.count","name":null,"root_namespace":"jvm","span_kind":null,"stability":"stable","type":"metric","unit":"{thread}"}],"root_namespace":"jvm"}] \ No newline at end of file diff --git a/crates/weaver_forge/expected_output/test/metric/jvm.md b/crates/weaver_forge/expected_output/test/metric/jvm.md index 7dbbb85f..495b201d 100644 --- a/crates/weaver_forge/expected_output/test/metric/jvm.md +++ b/crates/weaver_forge/expected_output/test/metric/jvm.md @@ -1,45 +1,106 @@ ## Metrics Namespace `jvm` -## Metric `jvm.memory.used` +## Metric `jvm.class.count` Instrument: updowncounter -Unit: By +Unit: {class} Stability: stable ### Attributes -#### Attribute `jvm.memory.type` + +## Metric `jvm.class.loaded` -The type of memory. +Instrument: counter +Unit: {class} +Stability: stable + +### Attributes + + + +## Metric `jvm.class.unloaded` + +Instrument: counter +Unit: {class} +Stability: stable + +### Attributes + +## Metric `jvm.cpu.count` + +Instrument: updowncounter +Unit: {cpu} +Stability: stable + +### Attributes + + + +## Metric `jvm.cpu.recent_utilization` + +Instrument: gauge +Unit: 1 +Stability: stable + +### Attributes + + + +## Metric `jvm.cpu.time` + +Instrument: counter +Unit: s +Stability: stable + +### Attributes + + + +## Metric `jvm.gc.duration` + +Instrument: histogram +Unit: s +Stability: stable + +### Attributes + + +#### Attribute `jvm.gc.name` + +Name of the garbage collector. + + +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()). + - Requirement Level: Recommended -- Type: Enum [heap, non_heap] +- Type: string - Examples: [ - "heap", - "non_heap", + "G1 Young Generation", + "G1 Old Generation", ] - Stability: Stable -#### Attribute `jvm.memory.pool.name` +#### Attribute `jvm.gc.action` -Name of the memory pool. +Name of the garbage collector action. -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()). +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()). - Requirement Level: Recommended - Type: string - Examples: [ - "G1 Old Gen", - "G1 Eden space", - "G1 Survivor Space", + "end of minor GC", + "end of major GC", ] - Stability: Stable @@ -136,7 +197,7 @@ Pool names are generally obtained via [MemoryPoolMXBean#getName()](https://docs. -## Metric `jvm.memory.used_after_last_gc` +## Metric `jvm.memory.used` Instrument: updowncounter Unit: By @@ -181,46 +242,45 @@ Pool names are generally obtained via [MemoryPoolMXBean#getName()](https://docs. -## Metric `jvm.gc.duration` +## Metric `jvm.memory.used_after_last_gc` -Instrument: histogram -Unit: s +Instrument: updowncounter +Unit: By Stability: stable ### Attributes -#### Attribute `jvm.gc.name` - -Name of the garbage collector. +#### Attribute `jvm.memory.type` +The type of memory. -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()). - Requirement Level: Recommended -- Type: string +- Type: Enum [heap, non_heap] - Examples: [ - "G1 Young Generation", - "G1 Old Generation", + "heap", + "non_heap", ] - Stability: Stable -#### Attribute `jvm.gc.action` +#### Attribute `jvm.memory.pool.name` -Name of the garbage collector action. +Name of the memory pool. -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()). +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()). - Requirement Level: Recommended - Type: string - Examples: [ - "end of minor GC", - "end of major GC", + "G1 Old Gen", + "G1 Eden space", + "G1 Survivor Space", ] - Stability: Stable @@ -264,64 +324,4 @@ State of the thread. - Stability: Stable - -## Metric `jvm.class.loaded` - -Instrument: counter -Unit: {class} -Stability: stable - -### Attributes - - - -## Metric `jvm.class.unloaded` - -Instrument: counter -Unit: {class} -Stability: stable - -### Attributes - - - -## Metric `jvm.class.count` - -Instrument: updowncounter -Unit: {class} -Stability: stable - -### Attributes - - - -## Metric `jvm.cpu.count` - -Instrument: updowncounter -Unit: {cpu} -Stability: stable - -### Attributes - - - -## Metric `jvm.cpu.time` - -Instrument: counter -Unit: s -Stability: stable - -### Attributes - - - -## Metric `jvm.cpu.recent_utilization` - -Instrument: gauge -Unit: 1 -Stability: stable - -### Attributes - - \ No newline at end of file diff --git a/crates/weaver_forge/expected_output/test/metrics.md b/crates/weaver_forge/expected_output/test/metrics.md index 1850ee4f..81a9a02e 100644 --- a/crates/weaver_forge/expected_output/test/metrics.md +++ b/crates/weaver_forge/expected_output/test/metrics.md @@ -2,45 +2,106 @@ # Metric Namespace `jvm` -## Metric `jvm.memory.used` +## Metric `jvm.class.count` Instrument: updowncounter -Unit: By +Unit: {class} Stability: stable ### Attributes -#### Attribute `jvm.memory.type` + +## Metric `jvm.class.loaded` -The type of memory. +Instrument: counter +Unit: {class} +Stability: stable + +### Attributes + + + +## Metric `jvm.class.unloaded` + +Instrument: counter +Unit: {class} +Stability: stable + +### Attributes + +## Metric `jvm.cpu.count` + +Instrument: updowncounter +Unit: {cpu} +Stability: stable + +### Attributes + + + +## Metric `jvm.cpu.recent_utilization` + +Instrument: gauge +Unit: 1 +Stability: stable + +### Attributes + + + +## Metric `jvm.cpu.time` + +Instrument: counter +Unit: s +Stability: stable + +### Attributes + + + +## Metric `jvm.gc.duration` + +Instrument: histogram +Unit: s +Stability: stable + +### Attributes + + +#### Attribute `jvm.gc.name` + +Name of the garbage collector. + + +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()). + - Requirement Level: Recommended -- Type: Enum [heap, non_heap] +- Type: string - Examples: [ - "heap", - "non_heap", + "G1 Young Generation", + "G1 Old Generation", ] - Stability: Stable -#### Attribute `jvm.memory.pool.name` +#### Attribute `jvm.gc.action` -Name of the memory pool. +Name of the garbage collector action. -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()). +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()). - Requirement Level: Recommended - Type: string - Examples: [ - "G1 Old Gen", - "G1 Eden space", - "G1 Survivor Space", + "end of minor GC", + "end of major GC", ] - Stability: Stable @@ -137,7 +198,7 @@ Pool names are generally obtained via [MemoryPoolMXBean#getName()](https://docs. -## Metric `jvm.memory.used_after_last_gc` +## Metric `jvm.memory.used` Instrument: updowncounter Unit: By @@ -182,46 +243,45 @@ Pool names are generally obtained via [MemoryPoolMXBean#getName()](https://docs. -## Metric `jvm.gc.duration` +## Metric `jvm.memory.used_after_last_gc` -Instrument: histogram -Unit: s +Instrument: updowncounter +Unit: By Stability: stable ### Attributes -#### Attribute `jvm.gc.name` - -Name of the garbage collector. +#### Attribute `jvm.memory.type` +The type of memory. -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()). - Requirement Level: Recommended -- Type: string +- Type: Enum [heap, non_heap] - Examples: [ - "G1 Young Generation", - "G1 Old Generation", + "heap", + "non_heap", ] - Stability: Stable -#### Attribute `jvm.gc.action` +#### Attribute `jvm.memory.pool.name` -Name of the garbage collector action. +Name of the memory pool. -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()). +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()). - Requirement Level: Recommended - Type: string - Examples: [ - "end of minor GC", - "end of major GC", + "G1 Old Gen", + "G1 Eden space", + "G1 Survivor Space", ] - Stability: Stable @@ -266,65 +326,5 @@ State of the thread. -## Metric `jvm.class.loaded` - -Instrument: counter -Unit: {class} -Stability: stable - -### Attributes - - - -## Metric `jvm.class.unloaded` - -Instrument: counter -Unit: {class} -Stability: stable - -### Attributes - - - -## Metric `jvm.class.count` - -Instrument: updowncounter -Unit: {class} -Stability: stable - -### Attributes - - - -## Metric `jvm.cpu.count` - -Instrument: updowncounter -Unit: {cpu} -Stability: stable - -### Attributes - - - -## Metric `jvm.cpu.time` - -Instrument: counter -Unit: s -Stability: stable - -### Attributes - - - -## Metric `jvm.cpu.recent_utilization` - -Instrument: gauge -Unit: 1 -Stability: stable - -### Attributes - - - \ No newline at end of file diff --git a/crates/weaver_forge/templates/test/weaver.yaml b/crates/weaver_forge/templates/test/weaver.yaml index a4f9446a..9cdbe59c 100644 --- a/crates/weaver_forge/templates/test/weaver.yaml +++ b/crates/weaver_forge/templates/test/weaver.yaml @@ -27,10 +27,16 @@ templates: filter: semconv_grouped_attributes application_mode: single - pattern: "**/event.md" - filter: semconv_signal("event"; {}) | semconv_group_signals_by_root_namespace("events") + filter: > + semconv_signal("event"; {}) + | group_by(.root_namespace) + | map({ root_namespace: .[0].root_namespace, events: . | sort_by(.name) }) application_mode: each - pattern: "**/events.md" - filter: semconv_signal("event"; {}) | semconv_group_signals_by_root_namespace("events") + filter: > + semconv_signal("event"; {}) + | group_by(.root_namespace) + | map({ root_namespace: .[0].root_namespace, events: . | sort_by(.name) }) application_mode: single - pattern: "**/metric.md" filter: semconv_grouped_metrics @@ -39,14 +45,26 @@ templates: filter: semconv_grouped_metrics application_mode: single - pattern: "**/resource.md" - filter: semconv_signal("resource"; {}) | semconv_group_signals_by_root_namespace("resources") + filter: > + semconv_signal("resource"; {}) + | group_by(.root_namespace) + | map({ root_namespace: .[0].root_namespace, resources: . | sort_by(.id) }) application_mode: each - pattern: "**/resources.md" - filter: semconv_signal("resource"; {}) | semconv_group_signals_by_root_namespace("resources") + filter: > + semconv_signal("resource"; {}) + | group_by(.root_namespace) + | map({ root_namespace: .[0].root_namespace, resources: . | sort_by(.id) }) application_mode: single - pattern: "**/span.md" - filter: semconv_signal("span"; {}) | semconv_group_signals_by_root_namespace("spans") + filter: > + semconv_signal("span"; {}) + | group_by(.root_namespace) + | map({ root_namespace: .[0].root_namespace, spans: . | sort_by(.id) }) application_mode: each - pattern: "**/spans.md" - filter: semconv_signal("span"; {}) | semconv_group_signals_by_root_namespace("spans") + filter: > + semconv_signal("span"; {}) + | group_by(.root_namespace) + | map({ root_namespace: .[0].root_namespace, spans: . | sort_by(.id) }) application_mode: single \ No newline at end of file diff --git a/defaults/jq/semconv.jq b/defaults/jq/semconv.jq index c4c15716..4c249db6 100644 --- a/defaults/jq/semconv.jq +++ b/defaults/jq/semconv.jq @@ -52,12 +52,6 @@ def semconv_grouped_attributes: semconv_grouped_attributes({}); # Generic Signal Functions -# Groups the signals by their root namespace and sorts them by name. -# $signal is the type of signal to group. -def semconv_group_signals_by_root_namespace($signal): - group_by(.root_namespace) - | map({ root_namespace: .[0].root_namespace, ($signal): . | sort_by(.name) }); - # Extracts and processes semantic convention signals based on provided options. # $signal is the type of signal to process. # $options is an object that can contain: @@ -86,8 +80,10 @@ def semconv_signal($signal; $options): | sort_by(.root_namespace); # Metric Functions -# Groups the metrics by their root namespace. -def semconv_group_metrics_by_root_namespace: semconv_group_signals_by_root_namespace("metrics"); +# Groups the metrics by their root namespace and sorts metrics by metric_name. +def semconv_group_metrics_by_root_namespace: + group_by(.root_namespace) + | map({ root_namespace: .[0].root_namespace, metrics: . | sort_by(.metric_name) }); # Extracts and processes semantic convention metrics based on provided options. # $options is an object that can contain: