Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jmx-metrics] Collect in callback #949

Merged
merged 16 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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