Skip to content

Commit

Permalink
[jmx-metrics] Collect in callback (#949)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Fitzpatrick <10867373+rmfitzpatrick@users.noreply.github.com>
Co-authored-by: jason plumb <75337021+breedx-splk@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 26, 2023
1 parent ef14fb0 commit 47f05de
Show file tree
Hide file tree
Showing 7 changed files with 433 additions and 232 deletions.
5 changes: 5 additions & 0 deletions jmx-metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ mutually exclusive with `otel.jmx.groovy.script`. The currently supported target
[`CompositeData`](https://docs.oracle.com/javase/7/docs/api/javax/management/openmbean/CompositeData.html) instances,
each key of their `CompositeType` `keySet` will be `.`-appended to the specified `instrumentName`, whose resulting
instrument will be updated for each respective value.
- If the underlying MBean(s) held by the provided MBeanHelper are a mixed set of
[`CompositeData`](https://docs.oracle.com/javase/7/docs/api/javax/management/openmbean/CompositeData.html) instances
and simple values, the InstrumentHelper will not attempt to collect the metric. This is to prevent generating
metrics identified with the `instrumentName` and also the `instrumentName` with the `keySet` `.`-appended,
which breaks OpenTelemetry metric conventions.

`otel.instrument()` provides additional signatures to obtain and update the returned `InstrumentHelper`:

Expand Down
16 changes: 9 additions & 7 deletions jmx-metrics/src/integrationTest/resources/script.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
import io.opentelemetry.api.common.Attributes

def loadMatches = otel.queryJmx("org.apache.cassandra.metrics:type=Storage,name=Load")
def load = loadMatches.first()
if (!loadMatches.isEmpty()) {
def load = loadMatches.first()

def lvr = otel.longHistogram(
"cassandra.storage.load",
"Size, in bytes, of the on disk data size this node manages",
"By"
)
lvr.record(load.Count, Attributes.builder().put("myKey", "myVal").build())
def lvr = otel.longHistogram(
"cassandra.storage.load",
"Size, in bytes, of the on disk data size this node manages",
"By"
)
lvr.record(load.Count, Attributes.builder().put("myKey", "myVal").build())
}
Loading

0 comments on commit 47f05de

Please sign in to comment.