diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 9388145cb7..8b9c3884d1 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -20,7 +20,6 @@ body: - ibm-mq-metrics - jfr-connection - jfr-events - - jmx-metrics - jmx-scraper - maven-extension - micrometer-meter-provider diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 49334a9017..af2a6e837b 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -20,7 +20,6 @@ body: - ibm-mq-metrics - jfr-connection - jfr-events - - jmx-metrics - jmx-scraper - maven-extension - micrometer-meter-provider diff --git a/.github/component_owners.yml b/.github/component_owners.yml index 56a0619eb1..c0066ef925 100644 --- a/.github/component_owners.yml +++ b/.github/component_owners.yml @@ -52,9 +52,6 @@ components: - dsgrieve jfr-events: - sfriberg - jmx-metrics: - - breedx-splk - - sylvainjuge jmx-scraper: - breedx-splk - robsunday diff --git a/.github/scripts/draft-change-log-entries.sh b/.github/scripts/draft-change-log-entries.sh index 62e3e6b208..467015ef3f 100755 --- a/.github/scripts/draft-change-log-entries.sh +++ b/.github/scripts/draft-change-log-entries.sh @@ -43,7 +43,6 @@ component_names["ibm-mq-metrics/"]="IBM MQ metrics" component_names["inferred-spans/"]="Inferred spans" component_names["jfr-connection/"]="JFR connection" component_names["jfr-events/"]="JFR events" -component_names["jmx-metrics/"]="JMX metrics" component_names["jmx-scraper/"]="JMX scraper" component_names["kafka-exporter/"]="Kafka exporter" component_names["maven-extension/"]="Maven extension" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 92357d52a3..9f44417144 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -116,14 +116,9 @@ jobs: - name: Download artifacts from Maven Central (when already published) if: ${{ inputs.already-published }} run: | - mkdir -p jmx-metrics/build/libs mkdir -p jmx-scraper/build/libs mkdir -p ibm-mq-metrics/build/libs - curl -L -o jmx-metrics/build/libs/opentelemetry-jmx-metrics-$VERSION-alpha.jar \ - "https://repo1.maven.org/maven2/io/opentelemetry/contrib/opentelemetry-jmx-metrics/$VERSION-alpha/opentelemetry-jmx-metrics-$VERSION-alpha.jar" - curl -L -o jmx-metrics/build/libs/opentelemetry-jmx-metrics-$VERSION-alpha.jar.asc \ - "https://repo1.maven.org/maven2/io/opentelemetry/contrib/opentelemetry-jmx-metrics/$VERSION-alpha/opentelemetry-jmx-metrics-$VERSION-alpha.jar.asc" curl -L -o jmx-scraper/build/libs/opentelemetry-jmx-scraper-$VERSION-alpha.jar \ "https://repo1.maven.org/maven2/io/opentelemetry/contrib/opentelemetry-jmx-scraper/$VERSION-alpha/opentelemetry-jmx-scraper-$VERSION-alpha.jar" curl -L -o jmx-scraper/build/libs/opentelemetry-jmx-scraper-$VERSION-alpha.jar.asc \ @@ -176,8 +171,6 @@ jobs: - name: Simplify paths for attaching run: | - cp jmx-metrics/build/libs/opentelemetry-jmx-metrics-$VERSION-alpha.jar opentelemetry-jmx-metrics.jar - cp jmx-metrics/build/libs/opentelemetry-jmx-metrics-$VERSION-alpha.jar.asc opentelemetry-jmx-metrics.jar.asc cp jmx-scraper/build/libs/opentelemetry-jmx-scraper-$VERSION-alpha.jar opentelemetry-jmx-scraper.jar cp jmx-scraper/build/libs/opentelemetry-jmx-scraper-$VERSION-alpha.jar.asc opentelemetry-jmx-scraper.jar.asc cp ibm-mq-metrics/build/libs/opentelemetry-ibm-mq-metrics-$VERSION-alpha-all.jar opentelemetry-ibm-mq-metrics-all.jar @@ -186,7 +179,6 @@ jobs: - uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 with: subject-path: | - opentelemetry-jmx-metrics.jar opentelemetry-jmx-scraper.jar opentelemetry-ibm-mq-metrics-all.jar @@ -199,8 +191,6 @@ jobs: --title "Version $VERSION" \ --notes-file /tmp/release-notes.txt \ v$VERSION \ - opentelemetry-jmx-metrics.jar \ - opentelemetry-jmx-metrics.jar.asc \ opentelemetry-jmx-scraper.jar \ opentelemetry-jmx-scraper.jar.asc \ opentelemetry-ibm-mq-metrics-all.jar \ diff --git a/CHANGELOG.md b/CHANGELOG.md index 2878679e13..32c0b5394e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +### JMX metrics + +- Remove the deprecated `jmx-metrics` (JMX Gatherer) module. Use the + [JMX Scraper](https://github.com/open-telemetry/opentelemetry-java-contrib/blob/main/jmx-scraper/README.md) instead, see the + [migration guide](https://github.com/open-telemetry/opentelemetry-java-contrib/blob/main/jmx-scraper/README.md#migration-from-jmx-gatherer). + ## Version 1.62.1 (2026-11-06) ### 🛠️ Bug fixes diff --git a/README.md b/README.md index 8dc5cb7a5e..d65fec501a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,6 @@ feature or via instrumentation, this project is hopefully for you. | beta | [IBM MQ Metrics](./ibm-mq-metrics/README.md) | | alpha | [JFR Connection](./jfr-connection/README.md) | | alpha | [JFR Events](./jfr-events/README.md) | -| alpha | [JMX Metric Gatherer](./jmx-metrics/README.md) | | alpha | [JMX Metric Scraper](./jmx-scraper/README.md) | | alpha | [Kafka Support](./kafka-exporter/README.md) | | alpha | [OpenTelemetry Maven Extension](./maven-extension/README.md) | diff --git a/jmx-metrics/README.md b/jmx-metrics/README.md deleted file mode 100644 index badffda32d..0000000000 --- a/jmx-metrics/README.md +++ /dev/null @@ -1,339 +0,0 @@ -# JMX Metric Gatherer - -[![Maven](https://img.shields.io/maven-central/v/io.opentelemetry.contrib/opentelemetry-jmx-metrics?label=Maven&color=orange)](https://central.sonatype.com/artifact/io.opentelemetry.contrib/opentelemetry-jmx-metrics) - -**Deprecation notice**: the JMX Metric Gatherer is deprecated and replaced by -[JMX Scraper](../jmx-scraper/). -See [migration instructions](../jmx-scraper/README.md#migration-from-jmx-gatherer). - -This utility provides an easy framework for gathering and reporting metrics based on queried -MBeans from a JMX server. It loads included and/or custom Groovy scripts and establishes a helpful, -bound `otel` object with methods for obtaining MBeans and constructing OpenTelemetry instruments: - -## Usage - -The JMX Metric Gatherer is intended to be run as an uber jar and configured -with properties from the command line, properties file, and stdin (`-`). -Its metric-gathering scripts are specified by supported -`otel.jmx.target.system` values and/or an `otel.jmx.groovy.script` path to run -your own. - -```bash -java -D -jar opentelemetry-jmx-metrics-.jar [-config {session.properties, '-'}] -``` - -### `session.properties` - -```properties -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://:/jmxrmi -otel.jmx.target.system = jvm,kafka -otel.jmx.interval.milliseconds = 5000 -otel.jmx.username = my-username -otel.jmx.password = my-password -otel.jmx.remote.registry.ssl=false -otel.metrics.exporter = otlp -otel.exporter.otlp.endpoint = http://my-opentelemetry-collector:4317 -``` - -As configured in this example, the metric gatherer will establish an MBean server connection using the -specified `otel.jmx.service.url` (required) and credentials and configure an OTLP gRPC metrics exporter reporting to -`otel.exporter.otlp.endpoint`. If SSL is enabled on the RMI registry for your server, the -`otel.jmx.remote.registry.ssl` property must be set to `true`. After loading the included JVM and -Kafka metric-gathering scripts determined by the comma-separated list in `otel.jmx.target.system`, -it will then run the scripts on the desired interval length of `otel.jmx.interval.milliseconds` and -export the resulting metrics. - -Some metrics (e.g. `tomcat.sessions`) are configured to query multiple MBeans. -By default, only the value in the first MBean is recorded for the metric and -all other values are dropped. -To aggregate the MBean values together, set the -`otel.jmx.aggregate.across.mbeans` property to `true`. - -For custom metrics and unsupported targets, you can provide your own MBean querying scripts to produce -OpenTelemetry instruments: - -```bash -java -Dotel.jmx.groovy.script=./script.groovy -jar opentelemetry-jmx-metrics-.jar [-config {optional.properties, '-'}] -``` - -### `script.groovy` - -```groovy -// Query the target JMX server for the desired MBean and create a helper representing the first result -def loadMBean = otel.mbean("io.example.service:type=MyType,name=Load") - -// Create a LongValueCallback which will set the instrument value to the -// loadMBean's most recent `Count` attribute's long value. The instrument will have a -// name of "my.type.load" and the specified description and unit, respectively. -otel.instrument( - loadMBean, "my.type.load", - "Load, in bytes, of the service of MyType", - "By", "Count", otel.&longValueCallback -) -``` - -The specified `script.groovy` file will be run on the desired `otel.jmx.interval.milliseconds` (10000 by default), -resulting in an exported `my.type.load` instrument with the observed value of the desired MBean's `Count` -attribute as queried in each interval. - -## Target Systems - -The JMX Metric Gatherer provides built in metric producing Groovy scripts for supported target systems -capable of being specified via the `otel.jmx.target.system` property as a comma-separated list. The -currently supported target systems are: - -| `otel.jmx.target.system` | -| ----------------------------------------------------------- | -| [`jvm`](./docs/target-systems/jvm.md) | -| [`activemq`](./docs/target-systems/activemq.md) | -| [`cassandra`](./docs/target-systems/cassandra.md) | -| [`hbase`](./docs/target-systems/hbase.md) | -| [`hadoop`](./docs/target-systems/hadoop.md) | -| [`jetty`](./docs/target-systems/jetty.md) | -| [`kafka`](./docs/target-systems/kafka.md) | -| [`kafka-consumer`](./docs/target-systems/kafka-consumer.md) | -| [`kafka-producer`](./docs/target-systems/kafka-producer.md) | -| [`solr`](./docs/target-systems/solr.md) | -| [`tomcat`](./docs/target-systems/tomcat.md) | -| [`wildfly`](./docs/target-systems/wildfly.md) | - -## JMX Query Helpers - -* `otel.queryJmx(String objectNameStr)` - * This method will query the connected JMX application for the given `objectNameStr`, which can - include wildcards. The return value will be a sorted `List` of zero or more - [`GroovyMBean` objects](http://docs.groovy-lang.org/latest/html/api/groovy/jmx/GroovyMBean.html), - which are conveniently wrapped to make accessing attributes on the MBean simple. - See for more information about their usage. - -* `otel.queryJmx(javax.management.ObjectName objectName)` - * This helper has the same functionality as its other signature, but takes an `ObjectName` - instance if constructing raw names is undesired. - -## JMX `MBeanHelper` and `InstrumentHelper` Access Methods - -* `otel.mbean(String objectNameStr)` - * This method will query for the given `objectNameStr` using `otel.queryJmx()` as previously described, - but returns an `MBeanHelper` instance representing the alphabetically first matching MBean for usage by - subsequent `InstrumentHelper` instances (available via `otel.instrument()`) as described below. It is - intended to be used in cases where your `objectNameStr` will return a single element `List` - to avoid redundant item access. - -* `otel.mbeans(String objectNameStr)` - * This method will query for the given `objectNameStr` using `otel.queryJmx()` as previously described, - but returns an `MBeanHelper` instance representing all matching MBeans for usage by subsequent `InstrumentHelper` - instances (available via `otel.instrument()`) as described below. It is intended to be used in cases - where your given `objectNameStr` can return a multiple element `List`. - -* `otel.mbeans(List objectNameStrs)` - * This method is equivalent to the above method, except that it adds support - for multiple ObjectNames. - This is meant for cases where there are multiple mbeans related to the same - metric and they can be separated using labels in `otel.instrument()`. - -* `otel.instrument(` - `MBeanHelper mBeanHelper, String instrumentName, String description,` - `String unit, Map labelFuncs, String attribute,` - `Closure instrument)` - * This method provides the ability to easily create and automatically update - instrument instances from an `MBeanHelper`'s underlying MBeans via an - OpenTelemetry instrument helper method pointer as described below. - * The method parameters map to those of the instrument helpers, while the - additional `Map labelFuncs` specifies updated instrument - labels that have access to the inspected MBean: - - ```groovy - // This example's resulting datapoint(s) will have Labels consisting of the specified key - // and a dynamically evaluated value from the GroovyMBean being examined. - [ "myLabelKey": { mbean -> mbean.name().getKeyProperty("myObjectNameProperty") } ] - ``` - - * If the underlying MBean(s) held by the provided MBeanHelper are - [`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`, and the 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 prevents generating metrics identified both by `instrumentName` and by - `instrumentName` with the `keySet` `.` appended, which would break - OpenTelemetry metric conventions. - -`otel.instrument()` provides additional signatures to obtain and update the returned `InstrumentHelper`: - -* `otel.instrument(MBeanHelper mBeanHelper, String name, String description, String unit, String attribute, Closure instrument)` - `labelFuncs` are an empty map. -* `otel.instrument(MBeanHelper mBeanHelper, String name, String description, String attribute, Closure instrument)` - `unit` is `"1"` and `labelFuncs` are an empty map. -* `otel.instrument(MBeanHelper mBeanHelper, String name, String attribute, Closure instrument)` - `description` is an empty string, `unit` is `"1"`, and `labelFuncs` are an - empty map. - -In cases where you'd like to share instrument names while creating datapoints -for multiple MBean attributes: - -* `otel.instrument(` - `MBeanHelper mBeanHelper, String instrumentName, String description,` - `String unit, Map labelFuncs,` - `Map> attributeLabelFuncs,` - `Closure instrument)` - -* An example of this in Tomcat is to consolidate different thread types into - one `"tomcat.threads"` metric using both `currentThreadCount` and - `currentThreadsBusy` MBean attributes, labeling with their applicable - `"Thread Type"`: - - ```groovy - otel.instrument(otel.mbean("Catalina:type=ThreadPool,name=*"), "tomcat.threads", "description", "1", - ["proto_handler" : { mbean -> mbean.name().getKeyProperty("name") }], - ["currentThreadCount": ["Thread Type": {mbean -> "current"}], - "currentThreadsBusy": ["Thread Type": {mbean -> "busy"}]], - otel.&doubleValueObserver) - ``` - -`otel.instrument()` provides additional signatures to allow this more -expressive MBean attribute access: - -* `otel.instrument(` - `MBeanHelper mBeanHelper, String name, String description, String unit,` - `Map> attributeLabelFuncs, Closure instrument)` - `labelFuncs` are an empty map. -* `otel.instrument(` - `MBeanHelper mBeanHelper, String name, String description,` - `Map> attributeLabelFuncs, Closure instrument)` - `unit` is `"1"` and `labelFuncs` are an empty map. -* `otel.instrument(` - `MBeanHelper mBeanHelper, String name,` - `Map> attributeLabelFuncs, Closure instrument)` - `description` is an empty string, `unit` is `"1"`, and `labelFuncs` are an - empty map. - -### MBeans with non-numeric attributes - -In cases where you'd like to create metrics based on non-numeric MBean -attributes, the mbean helper methods let you pass a map of closures to -transform the original extracted attribute into one that can be consumed by the -instrument callbacks. - -* `otel.mbean(String objectNameStr, Map> attributeTransformation)` - -* `otel.mbeans(String objectNameStr, Map> attributeTransformation)` - -* `otel.mbeans(List objectNameStrs, Map> attributeTransformation)` - -These methods provide the ability to easily convert the attributes extracted -from the mbeans at the time of creation for the `MBeanHelper`. - - ```groovy - // In this example a String based health attribute is converted to a numeric binary value - def someBean = otel.mbean( - "SomeMBean", ["CustomAttrFromString": { mbean -> mbean.getProperty("Attribute") == "running" ? 1 : 0 }] - ) - otel.instrument(someBean, "my-metric", "CustomAttrFromString", otel.&longUpDownCounterCallback) - ``` - -## OpenTelemetry Synchronous Instrument Helpers - -* `otel.doubleCounter(String name, String description, String unit)` - -* `otel.longCounter(String name, String description, String unit)` - -* `otel.doubleUpDownCounter(String name, String description, String unit)` - -* `otel.longUpDownCounter(String name, String description, String unit)` - -* `otel.doubleHistogram(String name, String description, String unit)` - -* `otel.longHistogram(String name, String description, String unit)` - -These methods will return a new or previously registered instance of the applicable metric -instruments. Each one provides three additional signatures where unit and description -aren't desired upon invocation. - -* `otel.(String name, String description)` - `unit` is "1". - -* `otel.(String name)` - `description` is empty string and `unit` is "1". - -## OpenTelemetry Asynchronous Instrument Helpers - -* `otel.doubleCounterCallback(String name, String description, String unit, Closure updater)` - -* `otel.longCounterCallback(String name, String description, String unit, Closure updater)` - -* `otel.doubleUpDownCounterCallback(String name, String description, String unit, Closure updater)` - -* `otel.longUpDownCounterCallback(String name, String description, String unit, Closure updater)` - -* `otel.doubleValueCallback(String name, String description, String unit, Closure updater)` - -* `otel.longValueCallback(String name, String description, String unit, Closure updater)` - -These methods will return a new or previously registered instance of the applicable metric -instruments. Each one provides two additional signatures where unit and description aren't -desired upon invocation. - -* `otel.(String name, String description, Closure updater)` - `unit` is "1". - -* `otel.(String name, Closure updater)` - `description` is empty string and `unit` is "1". - -Though asynchronous instrument callbacks are exclusively set by their builders in the OpenTelemetry API, -the JMX Metric Gatherer asynchronous instrument helpers allow using the specified updater Closure for -each instrument as run on the desired interval: - -```groovy -def loadMBean = otel.mbean("io.example.service:type=MyType,name=Load") -otel.longValueCallback( - "my.type.load", "Load, in bytes, of the service of MyType", "By", - { measurement -> measurement.observe(storageLoadMBean.getAttribute("Count")) } -) -``` - -## Compatibility - -This metric extension supports Java 8+, though SASL is only supported where -`com.sun.security.sasl.Provider` is available. - -## Configuration - -The following properties are supported via the command line or specified config properties file `(-config)`. -Those provided as command line properties take priority of those contained in a properties file. Properties -file contents can also be provided via stdin on startup when using `-config -` as an option. - -| Property | Required | Description | -| ---------------------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `otel.jmx.service.url` | **yes** | The service URL for the JMX RMI/JMXMP endpoint (generally of the form `service:jmx:rmi:///jndi/rmi://:/jmxrmi` or `service:jmx:jmxmp://:`). | -| `otel.jmx.groovy.script` | if not using `otel.jmx.target.system` | The path for the desired Groovy script. | -| `otel.jmx.target.system` | if not using `otel.jmx.groovy.script` | A comma-separated list of the supported target applications with built in Groovy scripts. | -| `otel.jmx.interval.milliseconds` | no | How often, in milliseconds, the Groovy script should be run. Value will also be used for `otel.metric.export.interval`, if unset, to control asynchronous updates and metric exporting. 10000 by default. | -| `otel.jmx.username` | no | Username for JMX authentication, if applicable. | -| `otel.jmx.password` | no | Password for JMX authentication, if applicable. | -| `otel.jmx.remote.profile` | no | Supported JMX remote profiles are TLS in combination with SASL profiles: SASL/PLAIN, SASL/DIGEST-MD5 and SASL/CRAM-MD5. Thus valid `jmxRemoteProfiles` values are: `SASL/PLAIN`, `SASL/DIGEST-MD5`, `SASL/CRAM-MD5`, `TLS SASL/PLAIN`, `TLS SASL/DIGEST-MD5` and `TLS SASL/CRAM-MD5`. | -| `otel.jmx.realm` | no | The realm is required by profile SASL/DIGEST-MD5. | -| `otel.metrics.exporter` | no | The type of metric exporter to use: (`otlp`, `prometheus`, `inmemory`, `logging`). `logging` by default. | -| `otel.exporter.otlp.endpoint` | no | The otlp exporter endpoint to use, Required for `otlp`. | -| `otel.exporter.otlp.headers` | no | Any headers to include in otlp exporter metric submissions. Of the form `header1=value1,header2=value2` | -| `otel.exporter.otlp.timeout` | no | The otlp exporter request timeout (in milliseconds). Default is 1000. | -| `otel.exporter.prometheus.host` | no | The prometheus collector server host. Default is `0.0.0.0`. | -| `otel.exporter.prometheus.port` | no | The prometheus collector server port. Default is `9464`. | -| `javax.net.ssl.keyStore` | no | The key store path is required if client authentication is enabled on the target JVM. | -| `javax.net.ssl.keyStorePassword` | no | The key store file password if required. | -| `javax.net.ssl.keyStoreType` | no | The key store type. | -| `javax.net.ssl.trustStore` | no | The trusted store path if the TLS profile is required. | -| `javax.net.ssl.trustStorePassword` | no | The trust store file password if required. | - -## Component owners - -* [Jason Plumb](https://github.com/breedx-splk), Splunk -* [Sylvain Juge](https://github.com/sylvainjuge), Elastic - -## Emeritus owners - -* [Miguel Rodriguez](https://github.com/Mrod1598), ObservIQ -* [Ryan Fitzpatrick](https://github.com/rmfitzpatrick), Splunk -* [Sam DeHaan](https://github.com/dehaansa), ObservIQ - -Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). diff --git a/jmx-metrics/build.gradle.kts b/jmx-metrics/build.gradle.kts deleted file mode 100644 index 57ef279a2b..0000000000 --- a/jmx-metrics/build.gradle.kts +++ /dev/null @@ -1,99 +0,0 @@ -plugins { - id("otel.java-conventions") - application - id("com.gradleup.shadow") - - id("otel.groovy-conventions") - id("otel.publish-conventions") -} - -description = "JMX metrics gathering Groovy script runner" -otelJava.moduleName.set("io.opentelemetry.contrib.jmxmetrics") - -application.mainClass.set("io.opentelemetry.contrib.jmxmetrics.JmxMetrics") - -val groovyVersion = "3.0.25" - -dependencies { - api(platform("org.codehaus.groovy:groovy-bom:$groovyVersion")) - - implementation("org.codehaus.groovy:groovy-jmx") - implementation("org.codehaus.groovy:groovy") - implementation("io.prometheus:simpleclient") - implementation("io.prometheus:simpleclient_httpserver") - implementation("io.opentelemetry:opentelemetry-api") - implementation("io.opentelemetry:opentelemetry-sdk") - implementation("io.opentelemetry:opentelemetry-sdk-metrics") - implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") - implementation("io.opentelemetry:opentelemetry-sdk-testing") - implementation("io.opentelemetry:opentelemetry-exporter-logging") - implementation("io.opentelemetry:opentelemetry-exporter-otlp") - implementation("io.opentelemetry:opentelemetry-exporter-prometheus") - - annotationProcessor("com.google.auto.value:auto-value") - compileOnly("com.google.auto.value:auto-value-annotations") - - testImplementation("org.slf4j:slf4j-api") - testImplementation("org.slf4j:slf4j-simple") - testImplementation("org.junit-pioneer:junit-pioneer") - testImplementation("org.awaitility:awaitility") -} - -testing { - suites { - register("integrationTest") { - dependencies { - implementation("com.linecorp.armeria:armeria-grpc") - implementation("com.linecorp.armeria:armeria-junit5") - implementation("io.opentelemetry.proto:opentelemetry-proto:1.11.1-alpha") - implementation("org.testcontainers:testcontainers-junit-jupiter") - implementation("org.slf4j:slf4j-simple") - } - } - } -} - -tasks { - shadowJar { - mergeServiceFiles() - - duplicatesStrategy = DuplicatesStrategy.INCLUDE // required for mergeServiceFiles() - - manifest { - attributes["Implementation-Version"] = project.version - } - // This should always be standalone, so remove "-all" to prevent unnecessary artifact. - archiveClassifier.set("") - } - - jar { - archiveClassifier.set("noshadow") - } - - withType().configureEach { - dependsOn(shadowJar) - inputs.files(layout.files(shadowJar)) - systemProperty("shadow.jar.path", shadowJar.get().archiveFile.get().asFile.absolutePath) - - systemProperty("gradle.project.version", "${project.version}") - } - - // Because we reconfigure publishing to only include the shadow jar, the Gradle metadata is not correct. - // Since we are fully bundled and have no dependencies, Gradle metadata wouldn't provide any advantage over - // the POM anyways so in practice we shouldn't be losing anything. - withType().configureEach { - enabled = false - } -} - -// Don't publish non-shadowed jar (shadowJar is in shadowRuntimeElements) -with(components["java"] as AdhocComponentWithVariants) { - configurations.forEach { - withVariantsFromConfiguration(configurations["apiElements"]) { - skip() - } - withVariantsFromConfiguration(configurations["runtimeElements"]) { - skip() - } - } -} diff --git a/jmx-metrics/docs/target-systems/activemq.md b/jmx-metrics/docs/target-systems/activemq.md deleted file mode 100644 index eaed68d325..0000000000 --- a/jmx-metrics/docs/target-systems/activemq.md +++ /dev/null @@ -1,91 +0,0 @@ -# ActiveMQ Metrics - -The JMX Metric Gatherer provides built in ActiveMQ metric gathering capabilities. -These metrics are sourced from: - -## Metrics - -### activemq.consumer.count - -* Name: `activemq.consumer.count` -* Description: The number of consumers currently reading from the broker. -* Unit: `consumers` -* Labels: `destination` -* Instrument Type: ObservableLongUpDownCounter - -### activemq.producer.count - -* Name: `activemq.producer.count` -* Description: The number of producers currently attached to the broker. -* Unit: `producers` -* Labels: `destination` -* Instrument Type: ObservableLongUpDownCounter - -### activemq.connectin.count - -* Name: `activemq.connectin.count` -* Description: The total number of current connections. -* Unit: `connections` -* Instrument Type: ObservableLongUpDownCounter - -### activemq.memory.usage - -* Name: `activemq.memory.usage` -* Description: The percentage of configured memory used. -* Unit: `%` -* Labels: `destination` -* Instrument Type: ObservableDoubleValue - -### activemq.disk.store_usage - -* Name: `activemq.disk.store_usage` -* Description: The percentage of configured disk used for persistent messages. -* Unit: `%` -* Instrument Type: ObservableDoubleValue - -### activemq.disk.temp_usage - -* Name: `activemq.disk.temp_usage` -* Description: The percentage of configured disk used for non-persistent messages. -* Unit: `%` -* Instrument Type: ObservableDoubleValue - -### activemq.message.current - -* Name: `activemq.message.current` -* Description: The current number of messages waiting to be consumed. -* Unit: `messages` -* Labels: `destination` -* Instrument Type: ObservableLongUpDownCounter - -### activemq.message.expired - -* Name: `activemq.message.expired` -* Description: The total number of messages not delivered because they expired. -* Unit: `messages` -* Labels: `destination` -* Instrument Type: ObservableLongCounter - -### activemq.message.enqueued - -* Name: `activemq.message.enqueued` -* Description: The total number of messages received by the broker. -* Unit: `messages` -* Labels: `destination` -* Instrument Type: ObservableLongCounter - -### activemq.message.dequeued - -* Name: `activemq.message.dequeued` -* Description: The total number of messages delivered to consumers. -* Unit: `messages` -* Labels: `destination` -* Instrument Type: ObservableLongCounter - -### activemq.message.wait_time.avg - -* Name: `activemq.message.wait_time.avg` -* Description: The average time a message was held on a destination. -* Unit: `ms` -* Labels: `destination` -* Instrument Type: ObservableDoubleValue diff --git a/jmx-metrics/docs/target-systems/cassandra.md b/jmx-metrics/docs/target-systems/cassandra.md deleted file mode 100644 index e6248de150..0000000000 --- a/jmx-metrics/docs/target-systems/cassandra.md +++ /dev/null @@ -1,124 +0,0 @@ -# Casandra Metrics - -The JMX Metric Gatherer provides built in Cassandra metric gathering capabilities. -These metrics are sourced from Cassandra's exposed Dropwizard Metrics for each node: . - -## Client Request Metrics - -### cassandra.client.request.range_slice.latency.50p - -* Name: `cassandra.client.request.range_slice.latency.50p` -* Description: Token range read request latency - 50th percentile -* Unit: `µs` -* Instrument Type: DoubleValueObserver - -### cassandra.client.request.range_slice.latency.99p - -* Name: `cassandra.client.request.range_slice.latency.99p` -* Description: Token range read request latency - 99th percentile -* Unit: `µs` -* Instrument Type: DoubleValueObserver - -### cassandra.client.request.range_slice.latency.max - -* Name: `cassandra.client.request.range_slice.latency.max` -* Description: Maximum token range read request latency -* Unit: `µs` -* Instrument Type: DoubleValueObserver - -### cassandra.client.request.read.latency.50p - -* Name: `cassandra.client.request.read.latency.50p` -* Description: Standard read request latency - 50th percentile -* Unit: `µs` -* Instrument Type: DoubleValueObserver - -### cassandra.client.request.read.latency.99p - -* Name: `cassandra.client.request.read.latency.99p` -* Description: Standard read request latency - 99th percentile -* Unit: `µs` -* Instrument Type: DoubleValueObserver - -### cassandra.client.request.read.latency.max - -* Name: `cassandra.client.request.read.latency.max` -* Description: Maximum standard read request latency -* Unit: `µs` -* Instrument Type: DoubleValueObserver - -### cassandra.client.request.write.latency.50p - -* Name: `cassandra.client.request.write.latency.50p` -* Description: Regular write request latency - 50th percentile -* Unit: `µs` -* Instrument Type: DoubleValueObserver - -### cassandra.client.request.write.latency.99p - -* Name: `cassandra.client.request.write.latency.99p` -* Description: Regular write request latency - 99th percentile -* Unit: `µs` -* Instrument Type: DoubleValueObserver - -### cassandra.client.request.write.latency.max - -* Name: `cassandra.client.request.write.latency.max` -* Description: Maximum regular write request latency -* Unit: `µs` -* Instrument Type: DoubleValueObserver - -### cassandra.client.request.count - -* Name: `cassandra.client.request.count` -* Description: Number of requests by operation -* Labels: `operation` -* Unit: `1` -* Instrument Type: LongSumObserver - -### cassandra.client.request.error.count - -* Name: `cassandra.client.request.error.count` -* Description: Number of request errors by operation -* Labels: `operation`, `status` -* Unit: `1` -* Instrument Type: LongSumObserver - -## Compaction Metrics - -### cassandra.compaction.tasks.completed - -* Name: `cassandra.compaction.tasks.completed` -* Description: Number of completed compactions since server [re]start -* Unit: `1` -* Instrument Type: LongSumObserver - -### cassandra.compaction.tasks.pending - -* Name: `cassandra.compaction.tasks.pending` -* Description: Estimated number of compactions remaining to perform -* Unit: `1` -* Instrument Type: LongValueObserver - -## Storage Metrics - -### cassandra.storage.load.count - -* Name: `cassandra.storage.load.count` -* Description: Size of the on disk data size this node manages -* Unit: `by` -* Instrument Type: LongValueObserver - -### cassandra.storage.total_hints.count - -* Name: `cassandra.storage.total_hints.count` -* Description: Number of hint messages written to this node since [re]start -* Unit: `1` -* Instrument Type: LongSumObserver - -### cassandra.storage.total_hints.in_progress.count - -* Name: `cassandra.storage.total_hints.in_progress.count` -* Description: Number of hints attempting to be sent currently -* Unit: `1` -* Instrument Type: LongValueObserver diff --git a/jmx-metrics/docs/target-systems/hadoop.md b/jmx-metrics/docs/target-systems/hadoop.md deleted file mode 100644 index b729a29b98..0000000000 --- a/jmx-metrics/docs/target-systems/hadoop.md +++ /dev/null @@ -1,78 +0,0 @@ -# Hadoop Metrics - -The JMX Metric Gatherer provides built in Hadoop metric gathering capabilities. -These metrics are sourced from: - -## Name Node Metrics - -### hadoop.name_node.capacity.usage - -* Name: `hadoop.name_node.capacity.usage` -* Description: The current used capacity across all data nodes reporting to the name node. -* Unit: `by` -* Labels: `node_name` -* Instrument Type: LongUpDownCounterCallback - -### hadoop.name_node.capacity.limit - -* Name: `hadoop.name_node.capacity.limit` -* Description: The total capacity allotted to data nodes reporting to the name node. -* Unit: `by` -* Labels: `node_name` -* Instrument Type: LongUpDownCounterCallback - -### hadoop.name_node.block.count - -* Name: `hadoop.name_node.block.count` -* Description: The total number of blocks on the name node. -* Unit: `{blocks}` -* Labels: `node_name` -* Instrument Type: LongUpDownCounterCallback - -### hadoop.name_node.block.missing - -* Name: `hadoop.name_node.block.missing` -* Description: The number of blocks reported as missing to the name node. -* Unit: `{blocks}` -* Labels: `node_name` -* Instrument Type: LongUpDownCounterCallback - -### hadoop.name_node.block.corrupt - -* Name: `hadoop.name_node.block.corrupt` -* Description: The number of blocks reported as corrupt to the name node. -* Unit: `{blocks}` -* Labels: `node_name` -* Instrument Type: LongUpDownCounterCallback - -### hadoop.name_node.volume.failed - -* Name: `hadoop.name_node.volume.failed` -* Description: The number of failed volumes reported to the name node. -* Unit: `{volumes}` -* Labels: `node_name` -* Instrument Type: LongUpDownCounterCallback - -### hadoop.name_node.file.count - -* Name: `hadoop.name_node.file.count` -* Description: The total number of files being tracked by the name node. -* Unit: `{files}` -* Labels: `node_name` -* Instrument Type: LongUpDownCounterCallback - -### hadoop.name_node.file.load - -* Name: `hadoop.name_node.file.load` -* Description: The current number of concurrent file accesses. -* Unit: `{operations}` -* Labels: `node_name` -* Instrument Type: LongUpDownCounterCallback - -### hadoop.name_node.data_node.count - -* Name: `hadoop.name_node.data_node.count` -* Description: The number of data nodes reporting to the name node. -* Unit: `{nodes}` -* Labels: `node_name`, `state` -* Instrument Type: LongUpDownCounterCallback diff --git a/jmx-metrics/docs/target-systems/hbase.md b/jmx-metrics/docs/target-systems/hbase.md deleted file mode 100644 index 7e007b0ef6..0000000000 --- a/jmx-metrics/docs/target-systems/hbase.md +++ /dev/null @@ -1,411 +0,0 @@ -# Hbase Metrics - -The JMX Metric Gatherer provides built in Hbase metric gathering capabilities. -These metrics are sourced from: - -## Metrics - -### hbase.master.region_server.count - -* Name: `hbase.master.region_server.count` -* Description: The number of region servers. -* Unit: `{servers}` -* Labels: `state` -* Instrument Type: longUpDownCounter - -### hbase.master.regions_in_transition.count - -* Name: `hbase.master.regions_in_transition.count` -* Description: The number of regions that are in transition. -* Unit: `{regions}` -* Instrument Type: longUpDownCounter - -### hbase.master.regions_in_transition.over_threshold - -* Name: `hbase.master.regions_in_transition.over_threshold` -* Description: The number of regions that have been in transition longer than a threshold time. -* Unit: `{regions}` -* Instrument Type: longUpDownCounter - -### hbase.master.regions_in_transition.oldest_age - -* Name: `hbase.master.regions_in_transition.oldest_age` -* Description: The age of the longest region in transition. -* Unit: `ms` -* Instrument Type: longValue - -### hbase.region_server.region.count - -* Name: `hbase.region_server.region.count` -* Description: The number of regions hosted by the region server. -* Unit: `{regions}` -* Labels: `region_server` -* Instrument Type: longUpDownCounter - -### hbase.region_server.disk.store_file.count - -* Name: `hbase.region_server.disk.store_file.count` -* Description: The number of store files on disk currently managed by the region server. -* Unit: `{files}` -* Labels: `region_server` -* Instrument Type: longUpDownCounter - -### hbase.region_server.disk.store_file.size - -* Name: `hbase.region_server.disk.store_file.size` -* Description: Aggregate size of the store files on disk. -* Unit: `By` -* Labels: `region_server` -* Instrument Type: longUpDownCounter - -### hbase.region_server.write_ahead_log.count - -* Name: `hbase.region_server.write_ahead_log.count` -* Description: The number of write ahead logs not yet archived. -* Unit: `{logs}` -* Labels: `region_server` -* Instrument Type: longUpDownCounter - -### hbase.region_server.request.count - -* Name: `hbase.region_server.request.count` -* Description: The number of requests received. -* Unit: `{requests}` -* Labels: `region_server`, `state` -* Instrument Type: longUpDownCounter - -### hbase.region_server.queue.length - -* Name: `hbase.region_server.queue.length` -* Description: The number of RPC handlers actively servicing requests. -* Unit: `{handlers}` -* Labels: `region_server`, `state` -* Instrument Type: longUpDownCounter - -### hbase.region_server.blocked_update.time - -* Name: `hbase.region_server.blocked_update.time` -* Description: Amount of time updates have been blocked so the memstore can be flushed. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.block_cache.operation.count - -* Name: `hbase.region_server.block_cache.operation.count` -* Description: Number of block cache hits/misses. -* Unit: `{operations}` -* Labels: `region_server`, `state` -* Instrument Type: longValue - -### hbase.region_server.files.local - -* Name: `hbase.region_server.files.local` -* Description: Percent of store file data that can be read from the local. -* Unit: `%` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.append.latency.p99 - -* Name: `hbase.region_server.operation.append.latency.p99` -* Description: Append operation 99th Percentile latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.append.latency.max - -* Name: `hbase.region_server.operation.append.latency.max` -* Description: Append operation max latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.append.latency.min - -* Name: `hbase.region_server.operation.append.latency.min` -* Description: Append operation minimum latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.append.latency.mean - -* Name: `hbase.region_server.operation.append.latency.mean` -* Description: Append operation mean latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.append.latency.median - -* Name: `hbase.region_server.operation.append.latency.median` -* Description: Append operation median latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.delete.latency.p99 - -* Name: `hbase.region_server.operation.delete.latency.p99` -* Description: Delete operation 99th Percentile latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.delete.latency.max - -* Name: `hbase.region_server.operation.delete.latency.max` -* Description: Delete operation max latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.delete.latency.min - -* Name: `hbase.region_server.operation.delete.latency.min` -* Description: Delete operation minimum latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.delete.latency.mean - -* Name: `hbase.region_server.operation.delete.latency.mean` -* Description: Delete operation mean latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.delete.latency.median - -* Name: `hbase.region_server.operation.delete.latency.median` -* Description: Delete operation median latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.put.latency.p99 - -* Name: `hbase.region_server.operation.put.latency.p99` -* Description: Put operation 99th Percentile latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.put.latency.max - -* Name: `hbase.region_server.operation.put.latency.max` -* Description: Put operation max latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.put.latency.min - -* Name: `hbase.region_server.operation.put.latency.min` -* Description: Put operation minimum latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.put.latency.mean - -* Name: `hbase.region_server.operation.put.latency.mean` -* Description: Put operation mean latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.put.latency.median - -* Name: `hbase.region_server.operation.put.latency.median` -* Description: Put operation median latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.get.latency.p99 - -* Name: `hbase.region_server.operation.get.latency.p99` -* Description: Get operation 99th Percentile latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.get.latency.max - -* Name: `hbase.region_server.operation.get.latency.max` -* Description: Get operation max latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.get.latency.min - -* Name: `hbase.region_server.operation.get.latency.min` -* Description: Get operation minimum latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.get.latency.mean - -* Name: `hbase.region_server.operation.get.latency.mean` -* Description: Get operation mean latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.get.latency.median - -* Name: `hbase.region_server.operation.get.latency.median` -* Description: Get operation median latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.replay.latency.p99 - -* Name: `hbase.region_server.operation.replay.latency.p99` -* Description: Replay operation 99th Percentile latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.replay.latency.max - -* Name: `hbase.region_server.operation.replay.latency.max` -* Description: Replay operation max latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.replay.latency.min - -* Name: `hbase.region_server.operation.replay.latency.min` -* Description: Replay operation minimum latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.replay.latency.mean - -* Name: `hbase.region_server.operation.replay.latency.mean` -* Description: Replay operation mean latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.replay.latency.median - -* Name: `hbase.region_server.operation.replay.latency.median` -* Description: Replay operation median latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.increment.latency.p99 - -* Name: `hbase.region_server.operation.increment.latency.p99` -* Description: Increment operation 99th Percentile latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.increment.latency.max - -* Name: `hbase.region_server.operation.increment.latency.max` -* Description: Increment operation max latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.increment.latency.min - -* Name: `hbase.region_server.operation.increment.latency.min` -* Description: Increment operation minimum latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.increment.latency.mean - -* Name: `hbase.region_server.operation.increment.latency.mean` -* Description: Increment operation mean latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operation.increment.latency.median - -* Name: `hbase.region_server.operation.increment.latency.median` -* Description: Increment operation median latency. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longValue - -### hbase.region_server.operations.slow - -* Name: `hbase.region_server.operations.slow` -* Description: Number of operations that took over 1000ms to complete. -* Unit: `{operations}` -* Labels: `region_server`, `operation` -* Instrument Type: longUpDownCounter - -### hbase.region_server.open_connection.count - -* Name: `hbase.region_server.open_connection.count` -* Description: The number of open connections at the RPC layer. -* Unit: `{connections}` -* Labels: `region_server` -* Instrument Type: longUpDownCounter - -### hbase.region_server.active_handler.count - -* Name: `hbase.region_server.active_handler.count` -* Description: The number of RPC handlers actively servicing requests. -* Unit: `{handlers}` -* Labels: `region_server` -* Instrument Type: longUpDownCounter - -### hbase.region_server.queue.request.count - -* Name: `hbase.region_server.queue.request.count` -* Description: The number of currently enqueued requests. -* Unit: `{requests}` -* Labels: `region_server`, `state` -* Instrument Type: longUpDownCounter - -### hbase.region_server.authentication.count - -* Name: `hbase.region_server.authentication.count` -* Description: Number of client connection authentication failures/successes. -* Unit: `{authentication requests}` -* Labels: `region_server`, `state` -* Instrument Type: longUpDownCounter - -### hbase.region_server.gc.time - -* Name: `hbase.region_server.gc.time` -* Description: Time spent in garbage collection. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longCounter - -### hbase.region_server.gc.young_gen.time - -* Name: `hbase.region_server.gc.young_gen.time` -* Description: Time spent in garbage collection of the young generation. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longCounter - -### hbase.region_server.gc.old_gen.time - -* Name: `hbase.region_server.gc.old_gen.time` -* Description: Time spent in garbage collection of the old generation. -* Unit: `ms` -* Labels: `region_server` -* Instrument Type: longCounter diff --git a/jmx-metrics/docs/target-systems/jetty.md b/jmx-metrics/docs/target-systems/jetty.md deleted file mode 100644 index c70d7e480b..0000000000 --- a/jmx-metrics/docs/target-systems/jetty.md +++ /dev/null @@ -1,49 +0,0 @@ -# Jetty Metrics - -The JMX Metric Gatherer provides built in Jetty metric gathering capabilities. -Details about using JMX with WildFly can be found here: - -## Metrics - -### jetty.select.count - -* Name: `jetty.select.count` -* Description: The number of select calls. -* Unit: `{operations}` -* Instrument Type: longCounterCallback - -### jetty.session.count - -* Name: `jetty.session.count` -* Description: The number of sessions created. -* Unit: `{sessions}` -* Instrument Type: LongCounterCallback - -### jetty.session.time.total - -* Name: `jetty.session.time.total` -* Description: The total time sessions have been active. -* Unit: `s` -* Instrument Type: longUpDownCounterCallback - -### jetty.session.time.max - -* Name: `jetty.session.time.max` -* Description: The maximum amount of time a session has been active. -* Unit: `s` -* Instrument Type: longValueCallback - -### jetty.thread.count - -* Name: `jetty.thread.count` -* Description: The current number of threads. -* Unit: `{threads}` -* Labels: `state` -* Instrument Type: longValueCallback - -### jetty.thread.queue.count - -* Name: `jetty.thread.queue.count` -* Description: The current number of threads in the queue. -* Unit: `{threads}` -* Instrument Type: longValueCallback diff --git a/jmx-metrics/docs/target-systems/jvm.md b/jmx-metrics/docs/target-systems/jvm.md deleted file mode 100644 index a9f35cc097..0000000000 --- a/jmx-metrics/docs/target-systems/jvm.md +++ /dev/null @@ -1,117 +0,0 @@ -# JVM Metrics - -The JMX Metric Gatherer provides built in JVM metric gathering capabilities. - -## Metrics - -### jvm.classes.loaded - -* Name: `jvm.classes.loaded` -* Description: The number of loaded classes -* Unit: `1` -* Instrument Type: LongValueObserver - -### jvm.gc.collections.count - -* Name: `jvm.gc.collections.count` -* Description: The total number of garbage collections that have occurred -* Unit: `1` -* Instrument Type: LongSumObserver - -### jvm.gc.collections.elapsed - -* Name: `jvm.gc.collections.elapsed` -* Description: The approximate accumulated collection elapsed time -* Unit: `ms` -* Instrument Type: LongSumObserver - -### jvm.memory.heap.init - -* Name: `jvm.memory.heap.init` -* Description: The initial amount of memory that the JVM requests from the operating system for the heap -* Unit: `by` -* Instrument Type: LongValueObserver - -### jvm.memory.heap.max - -* Name: `jvm.memory.heap.max` -* Description: The maximum amount of memory can be used for the heap -* Unit: `by` -* Instrument Type: LongValueObserver - -### jvm.memory.heap.used - -* Name: `jvm.memory.heap.used` -* Description: The current heap memory usage -* Unit: `by` -* Instrument Type: LongValueObserver - -### jvm.memory.heap.committed - -* Name: `jvm.memory.heap.committed` -* Description: The amount of memory that is guaranteed to be available for the heap -* Unit: `by` -* Instrument Type: LongValueObserver - -### jvm.memory.nonheap.init - -* Name: `jvm.memory.nonheap.init` -* Description: The initial amount of memory that the JVM requests from the operating system for non-heap purposes -* Unit: `by` -* Instrument Type: LongValueObserver - -### jvm.memory.nonheap.max - -* Name: `jvm.memory.nonheap.max` -* Description: The maximum amount of memory can be used for non-heap purposes -* Unit: `by` -* Instrument Type: LongValueObserver - -### jvm.memory.nonheap.used - -* Name: `jvm.memory.nonheap.used` -* Description: The current non-heap memory usage -* Unit: `by` -* Instrument Type: LongValueObserver - -### jvm.memory.nonheap.committed - -* Name: `jvm.memory.nonheap.committed` -* Description: The amount of memory that is guaranteed to be available for non-heap purposes -* Unit: `by` -* Instrument Type: LongValueObserver - -### jvm.memory.pool.init - -* Name: `jvm.memory.pool.init` -* Description: The initial amount of memory that the JVM requests from the operating system for the memory pool -* Unit: `by` -* Instrument Type: LongValueObserver - -### jvm.memory.pool.max - -* Name: `jvm.memory.pool.max` -* Description: The maximum amount of memory can be used for the memory pool -* Unit: `by` -* Instrument Type: LongValueObserver - -### jvm.memory.pool.used - -* Name: `jvm.memory.pool.used` -* Description: The current memory pool memory usage -* Unit: `by` -* Instrument Type: LongValueObserver - -### jvm.memory.pool.committed - -* Name: `jvm.memory.pool.committed` -* Description: The amount of memory that is guaranteed to be available for the memory pool -* Unit: `by` -* Instrument Type: LongValueObserver - -### jvm.threads.count - -* Name: `jvm.threads.count` -* Description: The current number of threads -* Unit: `1` -* Instrument Type: LongValueObserver diff --git a/jmx-metrics/docs/target-systems/kafka-consumer.md b/jmx-metrics/docs/target-systems/kafka-consumer.md deleted file mode 100644 index ac133ae8d2..0000000000 --- a/jmx-metrics/docs/target-systems/kafka-consumer.md +++ /dev/null @@ -1,72 +0,0 @@ -# Kafka Consumer Metrics - -The JMX Metric Gatherer provides built in Kafka consumer metric gathering capabilities for versions v0.8.2.x and above. -These metrics are sourced from Kafka's exposed JMX metrics for each instance: - -## Consumer Metrics - -### kafka.consumer.fetch-rate - -* Name: `kafka.consumer.fetch-rate` -* Description: The number of fetch requests for all topics per second. -* Unit: `1` -* Labels: `client-id` -* Instrument Type: DoubleValueObserver - -### kafka.consumer.records-lag-max - -* Name: `kafka.consumer.records-lag-max` -* Description: Number of messages the consumer lags behind the producer. -* Unit: `1` -* Labels: `client-id` -* Instrument Type: DoubleValueObserver - -### kafka.consumer.total.bytes-consumed-rate - -* Name: `kafka.consumer.total.bytes-consumed-rate` -* Description: The average number of bytes consumed for all topics per second. -* Unit: `by` -* Labels: `client-id` -* Instrument Type: DoubleValueObserver - -### kafka.consumer.total.fetch-size-avg - -* Name: `kafka.consumer.total.fetch-size-avg` -* Description: The average number of bytes fetched per request for all topics. -* Unit: `by` -* Labels: `client-id` -* Instrument Type: DoubleValueObserver - -### kafka.consumer.total.records-consumed-rate - -* Name: `kafka.consumer.total.records-consumed-rate` -* Description: The average number of records consumed for all topics per second. -* Unit: `1` -* Labels: `client-id` -* Instrument Type: DoubleValueObserver - -## Per-Topic Consumer Metrics - -### kafka.consumer.bytes-consumed-rate - -* Name: `kafka.consumer.bytes-consumed-rate` -* Description: The average number of bytes consumed per second -* Unit: `by` -* Labels: `client-id`, `topic` -* Instrument Type: DoubleValueObserver - -### kafka.consumer.fetch-size-avg - -* Name: `kafka.consumer.fetch-size-avg` -* Description: The average number of bytes fetched per request -* Unit: `by` -* Labels: `client-id`, `topic` -* Instrument Type: DoubleValueObserver - -### kafka.consumer.records-consumed-rate - -* Name: `kafka.consumer.records-consumed-rate` -* Description: The average number of records consumed per second -* Unit: `1` -* Labels: `client-id`, `topic` -* Instrument Type: DoubleValueObserver diff --git a/jmx-metrics/docs/target-systems/kafka-producer.md b/jmx-metrics/docs/target-systems/kafka-producer.md deleted file mode 100644 index 6788208df6..0000000000 --- a/jmx-metrics/docs/target-systems/kafka-producer.md +++ /dev/null @@ -1,88 +0,0 @@ -# Kafka Producer Metrics - -The JMX Metric Gatherer provides built in Kafka producer metric gathering capabilities for versions v0.8.2.x and above. -These metrics are sourced from Kafka's exposed JMX metrics for each instance: - -## Producer Metrics - -### kafka.producer.io-wait-time-ns-avg - -* Name: `kafka.producer.io-wait-time-ns-avg` -* Description: The average length of time the I/O thread spent waiting for a socket ready for reads or writes. -* Unit: `ns` -* Labels: `client-id` -* Instrument Type: DoubleValueObserver - -### kafka.producer.outgoing-byte-rate - -* Name: `kafka.producer.outgoing-byte-rate` -* Description: The average number of outgoing bytes sent per second to all servers. -* Unit: `by` -* Labels: `client-id` -* Instrument Type: DoubleValueObserver - -### kafka.producer.request-latency-avg - -* Name: `kafka.producer.request-latency-avg` -* Description: The average request latency. -* Unit: `ms` -* Labels: `client-id` -* Instrument Type: DoubleValueObserver - -### kafka.producer.request-rate - -* Name: `kafka.producer.request-rate` -* Description: The average number of requests sent per second. -* Unit: `1` -* Labels: `client-id` -* Instrument Type: DoubleValueObserver - -### kafka.producer.response-rate - -* Name: `kafka.producer.response-rate` -* Description: Responses received per second. -* Unit: `1` -* Labels: `client-id` -* Instrument Type: DoubleValueObserver - -## Per-Topic Producer Metrics - -### kafka.producer.byte-rate - -* Name: `kafka.producer.byte-rate` -* Description: The average number of bytes sent per second for a topic. -* Unit: `by` -* Labels: `client-id`, `topic` -* Instrument Type: DoubleValueObserver - -### kafka.producer.compression-rate - -* Name: `kafka.producer.compression-rate` -* Description: The average compression rate of record batches for a topic. -* Unit: `1` -* Labels: `client-id`, `topic` -* Instrument Type: DoubleValueObserver - -### kafka.producer.record-error-rate - -* Name: `kafka.producer.record-error-rate` -* Description: The average per-second number of record sends that resulted in errors for a topic. -* Unit: `1` -* Labels: `client-id`, `topic` -* Instrument Type: DoubleValueObserver - -### kafka.producer.record-retry-rate - -* Name: `kafka.producer.record-retry-rate` -* Description: The average per-second number of retried record sends for a topic. -* Unit: `1` -* Labels: `client-id`, `topic` -* Instrument Type: DoubleValueObserver - -### kafka.producer.record-send-rate - -* Name: `kafka.producer.record-send-rate` -* Description: The average number of records sent per second for a topic. -* Unit: `1` -* Labels: `client-id`, `topic` -* Instrument Type: DoubleValueObserver diff --git a/jmx-metrics/docs/target-systems/kafka.md b/jmx-metrics/docs/target-systems/kafka.md deleted file mode 100644 index 4ca96468c9..0000000000 --- a/jmx-metrics/docs/target-systems/kafka.md +++ /dev/null @@ -1,164 +0,0 @@ -# Kafka Metrics - -The JMX Metric Gatherer provides built in Kafka metric gathering capabilities for versions v0.8.2.x and above. -These metrics are sourced from Kafka's exposed JMX metrics for each instance: - -## Broker Metrics - -### kafka.message.count - -* Name: `kafka.message.count` -* Description: The number of messages received by the broker -* Unit: `{messages}` -* Instrument Type: LongCounterObserver - -### kafka.request.count - -* Name: `kafka.request.count` -* Description: The number of requests received by the broker -* Unit: `{requests}` -* Attributes: `type` -* Instrument Type: LongCounterObserver - -### kafka.request.failed - -* Name: `kafka.request.failed` -* Description: The number of requests to the broker resulting in a failure -* Unit: `{requests}` -* Attributes: `type` -* Instrument Type: LongCounterObserver - -### kafka.request.time.total - -* Name: `kafka.request.time.total` -* Description: The total time the broker has taken to service requests -* Unit: `ms` -* Attributes: `type` -* Instrument Type: LongCounterObserver - -### kafka.request.time.50p - -* Name: `kafka.request.time.50p` -* Description: The 50th percentile time the broker has taken to service requests -* Unit: `ms` -* Attributes: `type` -* Instrument Type: DoubleValueObserver - -### kafka.request.time.99p - -* Name: `kafka.request.time.99p` -* Description: The 99th percentile time the broker has taken to service requests -* Unit: `ms` -* Attributes: `type` -* Instrument Type: DoubleValueObserver - -### kafka.request.time.avg - -* Name: `kafka.request.time.avg` -* Description: The average time the broker has taken to service requests -* Unit: `ms` -* Attributes: `type` -* Instrument Type: DoubleValueObserver - -### kafka.network.io - -* Name: `kafka.network.io` -* Description: The bytes received or sent by the broker -* Unit: `by` -* Attributes: `state` -* Instrument Type: LongCounterObserver - -### kafka.purgatory.size - -* Name: `kafka.purgatory.size` -* Description: The number of requests waiting in purgatory -* Unit: `{requests}` -* Attributes: `type` -* Instrument Type: LongValueObserver - -### kafka.partition.count - -* Name: `kafka.partition.count` -* Description: The number of partitions on the broker -* Unit: `{partitions}` -* Instrument Type: LongValueObserver - -### kafka.partition.offline - -* Name: `kafka.partition.offline` -* Description: The number of partitions offline -* Unit: `{partitions}` -* Instrument Type: LongValueObserver - -### kafka.partition.under_replicated - -* Name: `kafka.partition.under_replicated` -* Description: The number of under replicated partitions -* Unit: `{partitions}` -* Instrument Type: LongValueObserver - -### kafka.isr.operation.count - -* Name: `kafka.isr.operation.count` -* Description: The number of in-sync replica shrink and expand operations -* Unit: `{operations}` -* Attributes: `operation` -* Instrument Type: LongCounterObserver - -### kafka.max.lag - -* Name: `kafka.max.lag` -* Description: Max lag in messages between follower and leader replicas -* Unit: `{messages}` -* Instrument Type: LongValueObserver - -### kafka.controller.active.count - -* Name: `kafka.controller.active.count` -* Description: Controller is active on broker -* Unit: `{controllers}` -* Instrument Type: LongValueObserver - -### kafka.leader.election.rate - -* Name: `kafka.leader.election.rate` -* Description: Leader election rate - increasing indicates broker failures -* Unit: `{elections}` -* Instrument Type: LongCounterObserver - -### kafka.unclean.election.rate - -* Name: `kafka.unclean.election.rate` -* Description: Unclean leader election rate - increasing indicates broker failures -* Unit: `{elections}` -* Instrument Type: LongCounterObserver - -### kafka.request.queue - -* Name: `kafka.request.queue` -* Description: Size of the request queue -* Unit: `{requests}` -* Instrument Type: LongValueObserver - -## Log metrics - -### kafka.logs.flush.time.count - -* Name: `kafka.logs.flush.time.count` -* Description: Log flush count -* Unit: `ms` -* Instrument Type: LongSumObserver - -### kafka.logs.flush.time.median - -* Name: `kafka.logs.flush.time.median` -* Description: Log flush time - 50th percentile -* Unit: `ms` -* Instrument Type: DoubleValueObserver - -### kafka.logs.flush.time.99p - -* Name: `kafka.logs.flush.time.99p` -* Description: Log flush time - 99th percentile -* Unit: `ms` -* Instrument Type: DoubleValueObserver diff --git a/jmx-metrics/docs/target-systems/solr.md b/jmx-metrics/docs/target-systems/solr.md deleted file mode 100644 index 615780c6cf..0000000000 --- a/jmx-metrics/docs/target-systems/solr.md +++ /dev/null @@ -1,94 +0,0 @@ -# Solr Metrics - -The JMX Metric Gatherer provides built in Solr metric gathering capabilities. -Details about using JMX with Solr can be found here: - -## Metrics - -### solr.document.count - -* Name: `solr.document.count` -* Description: The total number of indexed documents. -* Unit: `{documents}` -* Labels: `core` -* Instrument Type: ObservableLongUpDownCounter - -### solr.index.size - -* Name: `solr.index.size` -* Description: The total index size. -* Unit: `by` -* Labels: `core` -* Instrument Type: ObservableLongUpDownCounter - -### solr.request.count - -* Name: `solr.request.count` -* Description: The number of queries made. -* Unit: `{queries}` -* Labels: `core`, `type`, `handler` -* Instrument Type: ObservableLongCounter - -### solr.request.time.average - -* Name: `solr.request.time.average` -* Description: The average time of a query, based on Solr's histogram configuration. -* Unit: `ms` -* Labels: `core`, `type`, `handler` -* Instrument Type: ObservableDoubleValue - -### solr.request.error.count - -* Name: `solr.request.error.count` -* Description: The number of queries resulting in an error. -* Unit: `{queries}` -* Labels: `core`, `type`, `handler` -* Instrument Type: ObservableLongCounter - -### solr.request.timeout.count - -* Name: `solr.request.timeout.count` -* Description: The number of queries resulting in a timeout. -* Unit: `{queries}` -* Labels: `core`, `type`, `handler` -* Instrument Type: ObservableLongCounter - -### solr.cache.eviction.count - -* Name: `solr.cache.eviction.count` -* Description: The number of evictions from a cache. -* Unit: `{evictions}` -* Labels: `core`, `cache` -* Instrument Type: ObservableLongCounter - -### solr.cache.hit.count - -* Name: `solr.cache.hit.count` -* Description: The number of hits from a cache. -* Unit: `{hits}` -* Labels: `core`, `cache` -* Instrument Type: ObservableLongCounter - -### solr.cache.insert.count - -* Name: `solr.cache.insert.count` -* Description: The number of inserts from a cache. -* Unit: `{inserts}` -* Labels: `core`, `cache` -* Instrument Type: ObservableLongCounter - -### solr.cache.lookup.count - -* Name: `solr.cache.lookup.count` -* Description: The number of lookups from a cache. -* Unit: `{lookups}` -* Labels: `core`, `cache` -* Instrument Type: ObservableLongCounter - -### solr.cache.size - -* Name: `solr.cache.size` -* Description: The size of the cache occupied in memory. -* Unit: `by` -* Labels: `core`, `cache` -* Instrument Type: ObservableLongUpDownCounter diff --git a/jmx-metrics/docs/target-systems/tomcat.md b/jmx-metrics/docs/target-systems/tomcat.md deleted file mode 100644 index e3d00caad4..0000000000 --- a/jmx-metrics/docs/target-systems/tomcat.md +++ /dev/null @@ -1,61 +0,0 @@ -# Tomcat Metrics - -The JMX Metric Gatherer provides built in Tomcat metric gathering capabilities. -These metrics are sourced from: - -## Metrics - -### tomcat.sessions - -* Name: `tomcat.sessions` -* Description: The number of active sessions. -* Unit: `sessions` -* Instrument Type: DoubleValueCallback - -### tomcat.errors - -* Name: `tomcat.errors` -* Description: The number of errors encountered. -* Unit: `errors` -* Labels: `proto_handler` -* Instrument Type: LongCounterCallback - -### tomcat.processing_time - -* Name: `tomcat.processing_time` -* Description: The total processing time. -* Unit: `ms` -* Labels: `proto_handler` -* Instrument Type: LongCounterCallback - -### tomcat.traffic - -* Name: `tomcat.traffic` -* Description: The number of bytes transmitted and received. -* Unit: `by` -* Labels: `proto_handler`, `direction` -* Instrument Type: LongCounterCallback - -### tomcat.threads - -* Name: `tomcat.threads` -* Description: The number of threads. -* Unit: `threads` -* Labels: `proto_handler`, `state` -* Instrument Type: LongValueCallback - -### tomcat.max_time - -* Name: `tomcat.max_time` -* Description: Maximum time to process a request. -* Unit: `ms` -* Labels: `proto_handler` -* Instrument Type: longValueCallback - -### tomcat.request_count - -* Name: `tomcat.request_count` -* Description: The total requests. -* Unit: `requests` -* Labels: `proto_handler` -* Instrument Type: LongCounterCallback diff --git a/jmx-metrics/docs/target-systems/wildfly.md b/jmx-metrics/docs/target-systems/wildfly.md deleted file mode 100644 index 106fa4c46f..0000000000 --- a/jmx-metrics/docs/target-systems/wildfly.md +++ /dev/null @@ -1,104 +0,0 @@ -# WildFly Metrics - -The JMX Metric Gatherer provides built in WildFly metric gathering capabilities. -Details about using JMX with WildFly can be found here: - -## Deployment Metrics - -### wildfly.session.count - -* Name: `wildfly.session.count` -* Description: The number of sessions created. -* Unit: `{sessions}` -* Labels: `deployment` -* Instrument Type: LongCounterCallback - -### wildfly.session.active - -* Name: `wildfly.session.active` -* Description: The number of currently active sessions. -* Unit: `{sessions}` -* Labels: `deployment` -* Instrument Type: LongUpDownCounterCallback - -### wildfly.session.expired - -* Name: `wildfly.session.expired` -* Description: The number of sessions that have expired. -* Unit: `{sessions}` -* Labels: `deployment` -* Instrument Type: LongCounterCallback - -### wildfly.session.rejected - -* Name: `wildfly.session.rejected` -* Description: The number of sessions that have been rejected. -* Unit: `{sessions}` -* Labels: `deployment` -* Instrument Type: LongCounterCallback - -## Listener Metrics - -### wildfly.request.count - -* Name: `wildfly.request.count` -* Description: The number of requests received. -* Unit: `{requests}` -* Labels: `server`, `listener` -* Instrument Type: LongCounterCallback - -### wildfly.request.time - -* Name: `wildfly.request.time` -* Description: The total amount of time spent on requests. -* Unit: `ns` -* Labels: `server`, `listener` -* Instrument Type: LongCounterCallback - -### wildfly.request.server_error - -* Name: `wildfly.request.server_error` -* Description: The number of requests that have resulted in a 5xx response. -* Unit: `{requests}` -* Labels: `server`, `listener` -* Instrument Type: LongCounterCallback - -### wildfly.network.io - -* Name: `wildfly.network.io` -* Description: The number of bytes transmitted. -* Unit: `by` -* Labels: `server`, `listener`, `state` -* Instrument Type: LongCounterCallback - -## Data Source Metrics - -### wildfly.jdbc.connection.open - -* Name: `wildfly.jdbc.connection.open` -* Description: The number of open jdbc connections. -* Unit: `{connections}` -* Labels: `data_source`, `state` -* Instrument Type: LongUpDownCounterCallback - -### wildfly.jdbc.request.wait - -* Name: `wildfly.jdbc.request.wait` -* Description: The number of jdbc connections that had to wait before opening. -* Unit: `{requests}` -* Labels: `data_source` -* Instrument Type: LongCounterCallback - -### wildfly.jdbc.transaction.count - -* Name: `wildfly.jdbc.transaction.count` -* Description: The number of transactions created. -* Unit: `{transactions}` -* Instrument Type: LongCounterCallback - -### wildfly.jdbc.rollback.count - -* Name: `wildfly.jdbc.rollback.count` -* Description: The number of transactions rolled back. -* Unit: `{transactions}` -* Instrument Type: LongCounterCallback diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java deleted file mode 100644 index 46c8f0de60..0000000000 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.entry; -import static org.awaitility.Awaitility.await; -import static org.testcontainers.Testcontainers.exposeHostPorts; - -import com.linecorp.armeria.server.ServerBuilder; -import com.linecorp.armeria.server.grpc.GrpcService; -import com.linecorp.armeria.testing.junit5.server.ServerExtension; -import io.grpc.stub.StreamObserver; -import io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest; -import io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse; -import io.opentelemetry.proto.collector.metrics.v1.MetricsServiceGrpc; -import io.opentelemetry.proto.common.v1.KeyValue; -import io.opentelemetry.proto.metrics.v1.Metric; -import io.opentelemetry.proto.metrics.v1.NumberDataPoint; -import io.opentelemetry.proto.metrics.v1.ResourceMetrics; -import java.time.Duration; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingDeque; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import org.assertj.core.api.MapAssert; -import org.awaitility.core.ConditionTimeoutException; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.TestInstance; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.Network; -import org.testcontainers.containers.output.Slf4jLogConsumer; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.utility.MountableFile; - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Testcontainers(disabledWithoutDocker = true) -public abstract class AbstractIntegrationTest { - - private static final Logger logger = LoggerFactory.getLogger(AbstractIntegrationTest.class); - - private final boolean configFromStdin; - private final String configName; - - private GenericContainer scraper; - private OtlpGrpcServer otlpServer; - - protected AbstractIntegrationTest(boolean configFromStdin, String configName) { - this.configFromStdin = configFromStdin; - this.configName = configName; - } - - @BeforeAll - void beforeAll() { - otlpServer = new OtlpGrpcServer(); - otlpServer.start(); - exposeHostPorts(otlpServer.httpPort()); - String otlpEndpoint = "http://host.testcontainers.internal:" + otlpServer.httpPort(); - - scraper = buildScraper(otlpEndpoint); - scraper.start(); - } - - @AfterAll - // No need to block other tests waiting on return. - @SuppressWarnings("FutureReturnValueIgnored") - void afterAll() { - otlpServer.stop(); - scraper.stop(); - } - - @BeforeEach - void beforeEach() { - otlpServer.reset(); - } - - protected GenericContainer buildScraper(String otlpEndpoint) { - String scraperJarPath = System.getProperty("shadow.jar.path"); - - List scraperCommand = new ArrayList<>(); - scraperCommand.add("java"); - scraperCommand.add("-cp"); - scraperCommand.add("/app/OpenTelemetryJava.jar"); - scraperCommand.add("-Dotel.jmx.username=cassandra"); - scraperCommand.add("-Dotel.jmx.password=cassandra"); - scraperCommand.add("-Dotel.exporter.otlp.endpoint=" + otlpEndpoint); - scraperCommand.add("io.opentelemetry.contrib.jmxmetrics.JmxMetrics"); - scraperCommand.add("-config"); - - if (configFromStdin) { - String cmd = String.join(" ", scraperCommand); - scraperCommand = Arrays.asList("sh", "-c", "cat /app/" + configName + " | " + cmd + " -"); - } else { - scraperCommand.add("/app/" + configName); - } - - return new GenericContainer<>("openjdk:8u272-jre-slim") - .withNetwork(Network.SHARED) - .withCopyFileToContainer( - MountableFile.forHostPath(scraperJarPath), "/app/OpenTelemetryJava.jar") - .withCopyFileToContainer( - MountableFile.forClasspathResource("script.groovy"), "/app/script.groovy") - .withCopyFileToContainer( - MountableFile.forClasspathResource(configName), "/app/" + configName) - .withCommand(scraperCommand.toArray(new String[0])) - .withLogConsumer(new Slf4jLogConsumer(logger)) - .withStartupTimeout(Duration.ofMinutes(2)) - .waitingFor(Wait.forLogMessage(".*Started GroovyRunner.*", 1)); - } - - protected static GenericContainer cassandraContainer() { - return new GenericContainer<>("cassandra:3.11") - .withNetwork(Network.SHARED) - .withEnv("LOCAL_JMX", "no") - .withCopyFileToContainer( - MountableFile.forClasspathResource("cassandra/jmxremote.password", 0400), - "/etc/cassandra/jmxremote.password") - .withNetworkAliases("cassandra") - .withExposedPorts(7199) - .withStartupTimeout(Duration.ofMinutes(2)) - .waitingFor(Wait.forLogMessage(".*Startup complete.*", 1)); - } - - protected final void waitAndAssertMetrics(Iterable> assertions) { - waitAndAssertMetrics(() -> { - List metrics = - otlpServer.getMetrics().stream() - .map(ExportMetricsServiceRequest::getResourceMetricsList) - .flatMap(rm -> rm.stream().map(ResourceMetrics::getScopeMetricsList)) - .flatMap(Collection::stream) - .filter(sm -> - sm.getScope().getName().equals("io.opentelemetry.contrib.jmxmetrics") - && sm.getScope().getVersion().equals(expectedMeterVersion())) - .flatMap(sm -> sm.getMetricsList().stream()) - .collect(Collectors.toList()); - - assertThat(metrics).isNotEmpty(); - - for (Consumer assertion : assertions) { - assertThat(metrics).anySatisfy(assertion); - } - }); - } - - private static void waitAndAssertMetrics(Runnable assertion) { - try { - await().atMost(Duration.ofSeconds(30)).untilAsserted(assertion::run); - } catch (Throwable t) { - if (t instanceof ConditionTimeoutException) { - // Don't throw this failure since the stack is the awaitility thread, causing confusion. - // Instead, just assert one more time on the test thread, which will fail with a better - // stack trace - that is on the same thread as the test. - assertion.run(); - } else { - throw t; - } - } - } - - @SafeVarargs - @SuppressWarnings("varargs") - protected final void waitAndAssertMetrics(Consumer... assertions) { - waitAndAssertMetrics(Arrays.asList(assertions)); - } - - protected void assertGauge(Metric metric, String name, String description, String unit) { - assertThat(metric.getName()).isEqualTo(name); - assertThat(metric.getDescription()).isEqualTo(description); - assertThat(metric.getUnit()).isEqualTo(unit); - assertThat(metric.hasGauge()).isTrue(); - assertThat(metric.getGauge().getDataPointsList()) - .satisfiesExactly(point -> assertThat(point.getAttributesList()).isEmpty()); - } - - protected void assertSum(Metric metric, String name, String description, String unit) { - assertSum(metric, name, description, unit, /* isMonotonic= */ true); - } - - protected void assertSum( - Metric metric, String name, String description, String unit, boolean isMonotonic) { - assertThat(metric.getName()).isEqualTo(name); - assertThat(metric.getDescription()).isEqualTo(description); - assertThat(metric.getUnit()).isEqualTo(unit); - assertThat(metric.hasSum()).isTrue(); - assertThat(metric.getSum().getDataPointsList()) - .satisfiesExactly(point -> assertThat(point.getAttributesList()).isEmpty()); - assertThat(metric.getSum().getIsMonotonic()).isEqualTo(isMonotonic); - } - - protected void assertTypedGauge( - Metric metric, String name, String description, String unit, List types) { - assertThat(metric.getName()).isEqualTo(name); - assertThat(metric.getDescription()).isEqualTo(description); - assertThat(metric.getUnit()).isEqualTo(unit); - assertThat(metric.hasGauge()).isTrue(); - assertTypedPoints(metric.getGauge().getDataPointsList(), types); - } - - protected void assertTypedSum( - Metric metric, String name, String description, String unit, List types) { - assertThat(metric.getName()).isEqualTo(name); - assertThat(metric.getDescription()).isEqualTo(description); - assertThat(metric.getUnit()).isEqualTo(unit); - assertThat(metric.hasSum()).isTrue(); - assertTypedPoints(metric.getSum().getDataPointsList(), types); - } - - @SafeVarargs - protected final void assertSumWithAttributes( - Metric metric, - String name, - String description, - String unit, - Consumer>... attributeGroupAssertions) { - assertThat(metric.getName()).isEqualTo(name); - assertThat(metric.getDescription()).isEqualTo(description); - assertThat(metric.getUnit()).isEqualTo(unit); - assertThat(metric.hasSum()).isTrue(); - assertAttributedPoints(metric.getSum().getDataPointsList(), attributeGroupAssertions); - } - - @SafeVarargs - protected final void assertGaugeWithAttributes( - Metric metric, - String name, - String description, - String unit, - Consumer>... attributeGroupAssertions) { - assertThat(metric.getName()).isEqualTo(name); - assertThat(metric.getDescription()).isEqualTo(description); - assertThat(metric.getUnit()).isEqualTo(unit); - assertThat(metric.hasGauge()).isTrue(); - assertAttributedPoints(metric.getGauge().getDataPointsList(), attributeGroupAssertions); - } - - private static String expectedMeterVersion() { - // Automatically set by gradle when running the tests - String version = System.getProperty("gradle.project.version"); - assertThat(version).isNotBlank(); - return version; - } - - @SuppressWarnings("unchecked") - private static void assertTypedPoints(List points, List types) { - Consumer>[] assertions = - types.stream() - .map(type -> - (Consumer>) - attrs -> attrs.containsOnly(entry("name", type))) - .toArray(Consumer[]::new); - - assertAttributedPoints(points, assertions); - } - - @SuppressWarnings("unchecked") - private static void assertAttributedPoints( - List points, - Consumer>... attributeGroupAssertions) { - Consumer>[] assertions = - Arrays.stream(attributeGroupAssertions) - .map(assertion -> (Consumer>) m -> assertion.accept(assertThat(m))) - .toArray(Consumer[]::new); - assertThat(points) - .extracting(numberDataPoint -> - numberDataPoint.getAttributesList().stream() - .collect( - Collectors.toMap( - KeyValue::getKey, keyValue -> keyValue.getValue().getStringValue()))) - .satisfiesExactlyInAnyOrder(assertions); - } - - private static class OtlpGrpcServer extends ServerExtension { - - private final BlockingQueue metricRequests = - new LinkedBlockingDeque<>(); - - List getMetrics() { - return new ArrayList<>(metricRequests); - } - - void reset() { - metricRequests.clear(); - } - - @Override - protected void configure(ServerBuilder sb) { - sb.service( - GrpcService.builder() - .addService( - new MetricsServiceGrpc.MetricsServiceImplBase() { - @Override - public void export( - ExportMetricsServiceRequest request, - StreamObserver responseObserver) { - metricRequests.add(request); - responseObserver.onNext(ExportMetricsServiceResponse.getDefaultInstance()); - responseObserver.onCompleted(); - } - }) - .build()); - sb.http(0); - } - } -} diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/OtlpIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/OtlpIntegrationTest.java deleted file mode 100644 index eee64a382d..0000000000 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/OtlpIntegrationTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics; - -import static org.assertj.core.api.Assertions.assertThat; - -import io.opentelemetry.proto.common.v1.AnyValue; -import io.opentelemetry.proto.common.v1.KeyValue; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.junit.jupiter.Container; - -abstract class OtlpIntegrationTest extends AbstractIntegrationTest { - OtlpIntegrationTest(boolean configFromStdin) { - super(configFromStdin, "otlp_config.properties"); - } - - @Container GenericContainer cassandra = cassandraContainer(); - - @Test - void endToEnd() { - waitAndAssertMetrics(metric -> { - assertThat(metric.getName()).isEqualTo("cassandra.storage.load"); - assertThat(metric.getDescription()) - .isEqualTo("Size, in bytes, of the on disk data size this node manages"); - assertThat(metric.getUnit()).isEqualTo("By"); - assertThat(metric.hasHistogram()).isTrue(); - assertThat(metric.getHistogram().getDataPointsList()) - .satisfiesExactly(point -> - assertThat(point.getAttributesList()) - .containsExactly( - KeyValue.newBuilder() - .setKey("myKey") - .setValue(AnyValue.newBuilder().setStringValue("myVal")) - .build())); - }); - } - - static class ConfigFromStdin extends OtlpIntegrationTest { - ConfigFromStdin() { - super(true); - } - } - - static class ConfigFromFile extends OtlpIntegrationTest { - ConfigFromFile() { - super(false); - } - } -} diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java deleted file mode 100644 index f1d110c7e4..0000000000 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/ActivemqIntegrationTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics.target_systems; - -import static org.assertj.core.api.Assertions.entry; - -import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest; -import java.time.Duration; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.Network; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.images.builder.ImageFromDockerfile; -import org.testcontainers.junit.jupiter.Container; - -class ActivemqIntegrationTest extends AbstractIntegrationTest { - - ActivemqIntegrationTest() { - super(/* configFromStdin= */ false, "target-systems/activemq.properties"); - } - - @Container - GenericContainer activemq = - new GenericContainer<>( - new ImageFromDockerfile() - .withFileFromClasspath("config/env", "activemq/config/env") - .withFileFromClasspath("Dockerfile", "activemq/Dockerfile")) - .withNetwork(Network.SHARED) - .withEnv("LOCAL_JMX", "no") - .withNetworkAliases("activemq") - .withExposedPorts(10991) - .withStartupTimeout(Duration.ofMinutes(2)) - .waitingFor(Wait.forListeningPort()); - - @Test - void endToEnd() { - waitAndAssertMetrics( - metric -> - assertSumWithAttributes( - metric, - "activemq.consumer.count", - "The number of consumers currently reading from the broker.", - "{consumer}", - attrs -> - attrs.containsOnly( - entry("destination", "ActiveMQ.Advisory.MasterBroker"), - entry("broker", "localhost"))), - metric -> - assertSumWithAttributes( - metric, - "activemq.producer.count", - "The number of producers currently attached to the broker.", - "{producer}", - attrs -> - attrs.containsOnly( - entry("destination", "ActiveMQ.Advisory.MasterBroker"), - entry("broker", "localhost"))), - metric -> - assertSum( - metric, - "activemq.connection.count", - "The total number of current connections.", - "{connection}", - /* isMonotonic= */ false), - metric -> - assertGaugeWithAttributes( - metric, - "activemq.memory.usage", - "The percentage of configured memory used.", - "%", - attrs -> - attrs.containsOnly( - entry("destination", "ActiveMQ.Advisory.MasterBroker"), - entry("broker", "localhost"))), - metric -> - assertGauge( - metric, - "activemq.disk.store_usage", - "The percentage of configured disk used for persistent messages.", - "%"), - metric -> - assertGauge( - metric, - "activemq.disk.temp_usage", - "The percentage of configured disk used for non-persistent messages.", - "%"), - metric -> - assertSumWithAttributes( - metric, - "activemq.message.current", - "The current number of messages waiting to be consumed.", - "{message}", - attrs -> - attrs.containsOnly( - entry("destination", "ActiveMQ.Advisory.MasterBroker"), - entry("broker", "localhost"))), - metric -> - assertSumWithAttributes( - metric, - "activemq.message.current", - "The current number of messages waiting to be consumed.", - "{message}", - attrs -> - attrs.containsOnly( - entry("destination", "ActiveMQ.Advisory.MasterBroker"), - entry("broker", "localhost"))), - metric -> - assertSumWithAttributes( - metric, - "activemq.message.expired", - "The total number of messages not delivered because they expired.", - "{message}", - attrs -> - attrs.containsOnly( - entry("destination", "ActiveMQ.Advisory.MasterBroker"), - entry("broker", "localhost"))), - metric -> - assertSumWithAttributes( - metric, - "activemq.message.enqueued", - "The total number of messages received by the broker.", - "{message}", - attrs -> - attrs.containsOnly( - entry("destination", "ActiveMQ.Advisory.MasterBroker"), - entry("broker", "localhost"))), - metric -> - assertSumWithAttributes( - metric, - "activemq.message.dequeued", - "The total number of messages delivered to consumers.", - "{message}", - attrs -> - attrs.containsOnly( - entry("destination", "ActiveMQ.Advisory.MasterBroker"), - entry("broker", "localhost"))), - metric -> - assertGaugeWithAttributes( - metric, - "activemq.message.wait_time.avg", - "The average time a message was held on a destination.", - "ms", - attrs -> - attrs.containsOnly( - entry("destination", "ActiveMQ.Advisory.MasterBroker"), - entry("broker", "localhost")))); - } -} diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/CassandraIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/CassandraIntegrationTest.java deleted file mode 100644 index 64309ae3db..0000000000 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/CassandraIntegrationTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics.target_systems; - -import static org.assertj.core.api.Assertions.entry; - -import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest; -import java.util.Arrays; -import java.util.List; -import java.util.function.Consumer; -import org.assertj.core.api.MapAssert; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.junit.jupiter.Container; - -class CassandraIntegrationTest extends AbstractIntegrationTest { - - CassandraIntegrationTest() { - super(/* configFromStdin= */ false, "target-systems/cassandra.properties"); - } - - @Container GenericContainer cassandra = cassandraContainer(); - - @Test - void endToEnd() { - waitAndAssertMetrics( - metric -> - assertGauge( - metric, - "cassandra.client.request.range_slice.latency.50p", - "Token range read request latency - 50th percentile", - "us"), - metric -> - assertGauge( - metric, - "cassandra.client.request.range_slice.latency.99p", - "Token range read request latency - 99th percentile", - "us"), - metric -> - assertGauge( - metric, - "cassandra.client.request.range_slice.latency.max", - "Maximum token range read request latency", - "us"), - metric -> - assertGauge( - metric, - "cassandra.client.request.read.latency.50p", - "Standard read request latency - 50th percentile", - "us"), - metric -> - assertGauge( - metric, - "cassandra.client.request.read.latency.99p", - "Standard read request latency - 99th percentile", - "us"), - metric -> - assertGauge( - metric, - "cassandra.client.request.read.latency.max", - "Maximum standard read request latency", - "us"), - metric -> - assertGauge( - metric, - "cassandra.client.request.write.latency.50p", - "Regular write request latency - 50th percentile", - "us"), - metric -> - assertGauge( - metric, - "cassandra.client.request.write.latency.99p", - "Regular write request latency - 99th percentile", - "us"), - metric -> - assertGauge( - metric, - "cassandra.client.request.write.latency.max", - "Maximum regular write request latency", - "us"), - metric -> - assertSum( - metric, - "cassandra.compaction.tasks.completed", - "Number of completed compactions since server [re]start", - "{task}"), - metric -> - assertGauge( - metric, - "cassandra.compaction.tasks.pending", - "Estimated number of compactions remaining to perform", - "{task}"), - metric -> - assertSum( - metric, - "cassandra.storage.load.count", - "Size of the on disk data size this node manages", - "By", - /* isMonotonic= */ false), - metric -> - assertSum( - metric, - "cassandra.storage.total_hints.count", - "Number of hint messages written to this node since [re]start", - "{hint}"), - metric -> - assertSum( - metric, - "cassandra.storage.total_hints.in_progress.count", - "Number of hints attempting to be sent currently", - "{hint}", - /* isMonotonic= */ false), - metric -> - assertSumWithAttributes( - metric, - "cassandra.client.request.count", - "Number of requests by operation", - "{request}", - attrs -> attrs.containsOnly(entry("operation", "RangeSlice")), - attrs -> attrs.containsOnly(entry("operation", "Read")), - attrs -> attrs.containsOnly(entry("operation", "Write"))), - metric -> - assertSumWithAttributes( - metric, - "cassandra.client.request.error.count", - "Number of request errors by operation", - "{error}", - getRequestErrorCountAttributes())); - } - - @SuppressWarnings("unchecked") - private static Consumer>[] getRequestErrorCountAttributes() { - List operations = Arrays.asList("RangeSlice", "Read", "Write"); - List statuses = Arrays.asList("Timeout", "Failure", "Unavailable"); - - return operations.stream() - .flatMap(op -> - statuses.stream() - .map(st -> - (Consumer>) - attrs -> attrs.containsOnly(entry("operation", op), entry("status", st)))) - .toArray(Consumer[]::new); - } -} diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/HadoopIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/HadoopIntegrationTest.java deleted file mode 100644 index c871e28eac..0000000000 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/HadoopIntegrationTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics.target_systems; - -import static org.assertj.core.api.Assertions.entry; - -import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest; -import java.time.Duration; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.Network; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.utility.MountableFile; - -class HadoopIntegrationTest extends AbstractIntegrationTest { - - HadoopIntegrationTest() { - super(/* configFromStdin= */ false, "target-systems/hadoop.properties"); - } - - @Container - GenericContainer hadoop = - new GenericContainer<>("bmedora/hadoop:2.9-base") - .withCopyFileToContainer( - MountableFile.forClasspathResource("hadoop/hadoop-env.sh", 0400), - "/hadoop/etc/hadoop/hadoop-env.sh") - .withCopyFileToContainer( - MountableFile.forClasspathResource("hadoop/yarn-site.xml", 0400), - "/hadoop/etc/hadoop/yarn-site.xml") - .withNetwork(Network.SHARED) - .withNetworkAliases("hadoop") - .withExposedPorts(8004) - .withStartupTimeout(Duration.ofMinutes(2)) - .withCreateContainerCmdModifier(cmd -> cmd.withHostName("test-host")) - .waitingFor(Wait.forListeningPort()); - - @Test - void endToEnd() { - waitAndAssertMetrics( - metric -> - assertSumWithAttributes( - metric, - "hadoop.name_node.capacity.usage", - "The current used capacity across all data nodes reporting to the name node.", - "By", - attrs -> attrs.contains(entry("node_name", "test-host"))), - metric -> - assertSumWithAttributes( - metric, - "hadoop.name_node.capacity.limit", - "The total capacity allotted to data nodes reporting to the name node.", - "By", - attrs -> attrs.containsOnly(entry("node_name", "test-host"))), - metric -> - assertSumWithAttributes( - metric, - "hadoop.name_node.block.count", - "The total number of blocks on the name node.", - "{block}", - attrs -> attrs.containsOnly(entry("node_name", "test-host"))), - metric -> - assertSumWithAttributes( - metric, - "hadoop.name_node.block.missing", - "The number of blocks reported as missing to the name node.", - "{block}", - attrs -> attrs.containsOnly(entry("node_name", "test-host"))), - metric -> - assertSumWithAttributes( - metric, - "hadoop.name_node.block.corrupt", - "The number of blocks reported as corrupt to the name node.", - "{block}", - attrs -> attrs.containsOnly(entry("node_name", "test-host"))), - metric -> - assertSumWithAttributes( - metric, - "hadoop.name_node.volume.failed", - "The number of failed volumes reported to the name node.", - "{volume}", - attrs -> attrs.containsOnly(entry("node_name", "test-host"))), - metric -> - assertSumWithAttributes( - metric, - "hadoop.name_node.file.count", - "The total number of files being tracked by the name node.", - "{file}", - attrs -> attrs.containsOnly(entry("node_name", "test-host"))), - metric -> - assertSumWithAttributes( - metric, - "hadoop.name_node.file.load", - "The current number of concurrent file accesses.", - "{operation}", - attrs -> attrs.containsOnly(entry("node_name", "test-host"))), - metric -> - assertSumWithAttributes( - metric, - "hadoop.name_node.data_node.count", - "The number of data nodes reporting to the name node.", - "{node}", - attrs -> - attrs.containsOnly(entry("node_name", "test-host"), entry("state", "live")), - attrs -> - attrs.containsOnly(entry("node_name", "test-host"), entry("state", "dead")))); - } -} diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/HbaseIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/HbaseIntegrationTest.java deleted file mode 100644 index ba52e11583..0000000000 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/HbaseIntegrationTest.java +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics.target_systems; - -import static org.assertj.core.api.Assertions.entry; - -import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest; -import java.time.Duration; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.Network; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.utility.MountableFile; - -class HbaseIntegrationTest extends AbstractIntegrationTest { - - HbaseIntegrationTest() { - super(/* configFromStdin= */ false, "target-systems/hbase.properties"); - } - - @Container - GenericContainer hbase = - new GenericContainer<>("dajobe/hbase") - .withNetwork(Network.SHARED) - .withEnv("LOCAL_JMX", "no") - .withCopyFileToContainer( - MountableFile.forClasspathResource("hbase/hbase-env.sh", 0400), - "/opt/hbase/conf/hbase-env.sh") - .withNetworkAliases("hbase") - .withExposedPorts(9900) - .withStartupTimeout(Duration.ofMinutes(2)) - .waitingFor(Wait.forListeningPort()); - - @Test - void endToEnd() { - waitAndAssertMetrics( - metric -> - assertSumWithAttributes( - metric, - "hbase.master.region_server.count", - "The number of region servers.", - "{server}", - attrs -> attrs.contains(entry("state", "dead")), - attrs -> attrs.contains(entry("state", "live"))), - metric -> - assertSum( - metric, - "hbase.master.regions_in_transition.count", - "The number of regions that are in transition.", - "{region}", - /* isMonotonic= */ false), - metric -> - assertSum( - metric, - "hbase.master.regions_in_transition.over_threshold", - "The number of regions that have been in transition longer than a threshold time.", - "{region}", - /* isMonotonic= */ false), - metric -> - assertGauge( - metric, - "hbase.master.regions_in_transition.oldest_age", - "The age of the longest region in transition.", - "ms"), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.region.count", - "The number of regions hosted by the region server.", - "{region}", - attrs -> attrs.containsKey("region_server")), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.disk.store_file.count", - "The number of store files on disk currently managed by the region server.", - "{file}", - attrs -> attrs.containsKey("region_server")), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.disk.store_file.size", - "Aggregate size of the store files on disk.", - "By", - attrs -> attrs.containsKey("region_server")), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.write_ahead_log.count", - "The number of write ahead logs not yet archived.", - "{log}", - attrs -> attrs.containsKey("region_server")), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.request.count", - "The number of requests received.", - "{request}", - attrs -> attrs.contains(entry("state", "write")), - attrs -> attrs.contains(entry("state", "read"))), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.queue.length", - "The number of RPC handlers actively servicing requests.", - "{handler}", - attrs -> attrs.contains(entry("state", "flush")), - attrs -> attrs.contains(entry("state", "compaction"))), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.blocked_update.time", - "Amount of time updates have been blocked so the memstore can be flushed.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.request.count", - "The number of requests received.", - "{request}", - attrs -> attrs.contains(entry("state", "write")), - attrs -> attrs.contains(entry("state", "read"))), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.files.local", - "Percent of store file data that can be read from the local.", - "%", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.append.latency.p99", - "Append operation 99th Percentile latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.append.latency.max", - "Append operation max latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.append.latency.min", - "Append operation minimum latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.append.latency.mean", - "Append operation mean latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.append.latency.median", - "Append operation median latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.delete.latency.p99", - "Delete operation 99th Percentile latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.delete.latency.max", - "Delete operation max latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.delete.latency.min", - "Delete operation minimum latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.delete.latency.mean", - "Delete operation mean latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.delete.latency.median", - "Delete operation median latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.put.latency.p99", - "Put operation 99th Percentile latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.put.latency.max", - "Put operation max latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.put.latency.min", - "Put operation minimum latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.put.latency.mean", - "Put operation mean latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.put.latency.median", - "Put operation median latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.get.latency.p99", - "Get operation 99th Percentile latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.get.latency.max", - "Get operation max latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.get.latency.min", - "Get operation minimum latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.get.latency.mean", - "Get operation mean latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.get.latency.median", - "Get operation median latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.replay.latency.p99", - "Replay operation 99th Percentile latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.replay.latency.max", - "Replay operation max latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.replay.latency.min", - "Replay operation minimum latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.replay.latency.mean", - "Replay operation mean latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.replay.latency.median", - "Replay operation median latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.increment.latency.p99", - "Increment operation 99th Percentile latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.increment.latency.max", - "Increment operation max latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.increment.latency.min", - "Increment operation minimum latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.increment.latency.mean", - "Increment operation mean latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertGaugeWithAttributes( - metric, - "hbase.region_server.operation.increment.latency.median", - "Increment operation median latency.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.operations.slow", - "Number of operations that took over 1000ms to complete.", - "{operation}", - attrs -> attrs.contains(entry("operation", "delete")), - attrs -> attrs.contains(entry("operation", "append")), - attrs -> attrs.contains(entry("operation", "get")), - attrs -> attrs.contains(entry("operation", "put")), - attrs -> attrs.contains(entry("operation", "increment"))), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.open_connection.count", - "The number of open connections at the RPC layer.", - "{connection}", - attrs -> attrs.containsKey("region_server")), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.active_handler.count", - "The number of RPC handlers actively servicing requests.", - "{handler}", - attrs -> attrs.containsKey("region_server")), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.queue.request.count", - "The number of currently enqueued requests.", - "{request}", - attrs -> attrs.contains(entry("state", "replication")), - attrs -> attrs.contains(entry("state", "user")), - attrs -> attrs.contains(entry("state", "priority"))), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.authentication.count", - "Number of client connection authentication failures/successes.", - "{authentication request}", - attrs -> attrs.contains(entry("state", "successes")), - attrs -> attrs.contains(entry("state", "failures"))), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.gc.time", - "Time spent in garbage collection.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.gc.young_gen.time", - "Time spent in garbage collection of the young generation.", - "ms", - attrs -> attrs.containsKey("region_server")), - metric -> - assertSumWithAttributes( - metric, - "hbase.region_server.gc.old_gen.time", - "Time spent in garbage collection of the old generation.", - "ms", - attrs -> attrs.containsKey("region_server"))); - } -} diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/JettyIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/JettyIntegrationTest.java deleted file mode 100644 index bb89a2a4a1..0000000000 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/JettyIntegrationTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics.target_systems; - -import static org.assertj.core.api.Assertions.entry; - -import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest; -import java.time.Duration; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.Network; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.images.builder.ImageFromDockerfile; -import org.testcontainers.junit.jupiter.Container; - -class JettyIntegrationTest extends AbstractIntegrationTest { - - JettyIntegrationTest() { - super(/* configFromStdin= */ false, "target-systems/jetty.properties"); - } - - @Container - GenericContainer jetty = - new GenericContainer<>( - new ImageFromDockerfile() - .withDockerfileFromBuilder(builder -> - builder - .from("jetty:11") - .run( - "java", - "-jar", - "/usr/local/jetty/start.jar", - "--add-to-startd=jmx,stats,http") - .run("mkdir -p /var/lib/jetty/webapps/ROOT/") - .run("touch /var/lib/jetty/webapps/ROOT/index.html") - .env( - "JAVA_OPTIONS", - "-Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099") - .build())) - .withNetwork(Network.SHARED) - .withEnv("LOCAL_JMX", "no") - .withNetworkAliases("jetty") - .withExposedPorts(1099, 8080) - .withStartupTimeout(Duration.ofMinutes(2)) - .waitingFor(Wait.forLogMessage(".*Started Server.*", 1)); - - @Test - void endToEnd() throws InterruptedException { - waitAndAssertMetrics( - metric -> - assertSumWithAttributes( - metric, - "jetty.session.count", - "The number of sessions established in total.", - "{session}", - attrs -> attrs.containsKey("resource")), - metric -> - assertSumWithAttributes( - metric, - "jetty.session.time.total", - "The total time sessions have been active.", - "s", - attrs -> attrs.containsKey("resource")), - metric -> - assertGaugeWithAttributes( - metric, - "jetty.session.time.max", - "The maximum amount of time a session has been active.", - "s", - attrs -> attrs.containsKey("resource")), - metric -> - assertSum(metric, "jetty.select.count", "The number of select calls.", "{operation}"), - metric -> - assertGaugeWithAttributes( - metric, - "jetty.thread.count", - "The current number of threads.", - "{thread}", - attrs -> attrs.contains(entry("state", "busy")), - attrs -> attrs.contains(entry("state", "idle"))), - metric -> - assertGauge( - metric, - "jetty.thread.queue.count", - "The current number of threads in the queue.", - "{thread}")); - } -} diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/JvmTargetSystemIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/JvmTargetSystemIntegrationTest.java deleted file mode 100644 index 682e239570..0000000000 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/JvmTargetSystemIntegrationTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics.target_systems; - -import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest; -import java.util.Arrays; -import java.util.List; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.junit.jupiter.Container; - -class JvmTargetSystemIntegrationTest extends AbstractIntegrationTest { - - JvmTargetSystemIntegrationTest() { - super(/* configFromStdin= */ false, "target-systems/jvm.properties"); - } - - @Container GenericContainer cassandra = cassandraContainer(); - - @Test - void endToEnd() { - List gcLabels = - Arrays.asList( - "Code Cache", - "Par Eden Space", - "CMS Old Gen", - "Compressed Class Space", - "Metaspace", - "Par Survivor Space"); - waitAndAssertMetrics( - metric -> assertGauge(metric, "jvm.classes.loaded", "number of loaded classes", "{class}"), - metric -> - assertTypedSum( - metric, - "jvm.gc.collections.count", - "total number of collections that have occurred", - "{collection}", - Arrays.asList("ConcurrentMarkSweep", "ParNew")), - metric -> - assertTypedSum( - metric, - "jvm.gc.collections.elapsed", - "the approximate accumulated collection elapsed time in milliseconds", - "ms", - Arrays.asList("ConcurrentMarkSweep", "ParNew")), - metric -> assertGauge(metric, "jvm.memory.heap.committed", "current heap usage", "By"), - metric -> assertGauge(metric, "jvm.memory.heap.init", "current heap usage", "By"), - metric -> assertGauge(metric, "jvm.memory.heap.max", "current heap usage", "By"), - metric -> assertGauge(metric, "jvm.memory.heap.used", "current heap usage", "By"), - metric -> - assertGauge(metric, "jvm.memory.nonheap.committed", "current non-heap usage", "By"), - metric -> assertGauge(metric, "jvm.memory.nonheap.init", "current non-heap usage", "By"), - metric -> assertGauge(metric, "jvm.memory.nonheap.max", "current non-heap usage", "By"), - metric -> assertGauge(metric, "jvm.memory.nonheap.used", "current non-heap usage", "By"), - metric -> - assertTypedGauge( - metric, "jvm.memory.pool.committed", "current memory pool usage", "By", gcLabels), - metric -> - assertTypedGauge( - metric, "jvm.memory.pool.init", "current memory pool usage", "By", gcLabels), - metric -> - assertTypedGauge( - metric, "jvm.memory.pool.max", "current memory pool usage", "By", gcLabels), - metric -> - assertTypedGauge( - metric, "jvm.memory.pool.used", "current memory pool usage", "By", gcLabels), - metric -> assertGauge(metric, "jvm.threads.count", "number of threads", "{thread}")); - } -} diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/KafkaIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/KafkaIntegrationTest.java deleted file mode 100644 index 25affd9236..0000000000 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/KafkaIntegrationTest.java +++ /dev/null @@ -1,482 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics.target_systems; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.entry; - -import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest; -import io.opentelemetry.proto.metrics.v1.Metric; -import io.opentelemetry.proto.metrics.v1.NumberDataPoint; -import java.io.IOException; -import java.time.Duration; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.function.Consumer; -import org.junit.jupiter.api.Test; -import org.slf4j.LoggerFactory; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.Network; -import org.testcontainers.containers.output.Slf4jLogConsumer; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.lifecycle.Startable; -import org.testcontainers.utility.MountableFile; - -abstract class KafkaIntegrationTest extends AbstractIntegrationTest { - protected KafkaIntegrationTest(String configName) { - super(/* configFromStdin= */ false, configName); - } - - @Container - GenericContainer zookeeper = - new GenericContainer<>("zookeeper:3.5") - .withNetwork(Network.SHARED) - .withNetworkAliases("zookeeper") - .withStartupTimeout(Duration.ofMinutes(2)) - .waitingFor(Wait.forListeningPort()); - - @Container - GenericContainer kafka = - new GenericContainer<>("bitnamilegacy/kafka:2.8.1") - .withNetwork(Network.SHARED) - .withEnv("KAFKA_CFG_ZOOKEEPER_CONNECT", "zookeeper:2181") - .withEnv("ALLOW_PLAINTEXT_LISTENER", "yes") - .withEnv("JMX_PORT", "7199") - .withNetworkAliases("kafka") - .withExposedPorts(7199) - .withStartupTimeout(Duration.ofMinutes(2)) - .waitingFor( - Wait.forLogMessage(".*KafkaServer.*started \\(kafka.server.KafkaServer\\).*", 1)) - .dependsOn(zookeeper); - - Startable createTopics = - new Startable() { - @Override - public void start() { - try { - kafka.execInContainer( - "sh", - "-c", - "unset JMX_PORT; for i in `seq 3`; do kafka-topics.sh --bootstrap-server localhost:9092 --create --topic test-topic-$i; done"); - } catch (IOException | InterruptedException e) { - throw new AssertionError(e); - } - } - - @Override - public void stop() {} - - @Override - public Set getDependencies() { - return Collections.singleton(kafka); - } - }; - - protected GenericContainer kafkaProducerContainer() { - return new GenericContainer<>("bitnamilegacy/kafka:2.8.1") - .withNetwork(Network.SHARED) - .withEnv("KAFKA_CFG_ZOOKEEPER_CONNECT", "zookeeper:2181") - .withEnv("ALLOW_PLAINTEXT_LISTENER", "yes") - .withEnv("JMX_PORT", "7199") - .withNetworkAliases("kafka-producer") - .withExposedPorts(7199) - .withCopyFileToContainer( - MountableFile.forClasspathResource("target-systems/kafka-producer.sh"), - "/usr/bin/kafka-producer.sh") - .withCommand("kafka-producer.sh") - .withStartupTimeout(Duration.ofMinutes(2)) - .withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("kafka-producer"))) - .waitingFor(Wait.forLogMessage(".*Welcome to the Bitnami kafka container.*", 1)) - .dependsOn(createTopics); - } - - List> kafkaBrokerAssertions() { - return Arrays.asList( - metric -> - assertSumWithAttributes( - metric, - "kafka.request.time.total", - "The total time the broker has taken to service requests", - "ms", - attrs -> attrs.containsOnly(entry("type", "produce")), - attrs -> attrs.containsOnly(entry("type", "fetchfollower")), - attrs -> attrs.containsOnly(entry("type", "fetchconsumer"))), - metric -> - assertGaugeWithAttributes( - metric, - "kafka.request.time.50p", - "The 50th percentile time the broker has taken to service requests", - "ms", - attrs -> attrs.containsOnly(entry("type", "produce")), - attrs -> attrs.containsOnly(entry("type", "fetchfollower")), - attrs -> attrs.containsOnly(entry("type", "fetchconsumer"))), - metric -> - assertGaugeWithAttributes( - metric, - "kafka.request.time.99p", - "The 99th percentile time the broker has taken to service requests", - "ms", - attrs -> attrs.containsOnly(entry("type", "produce")), - attrs -> attrs.containsOnly(entry("type", "fetchfollower")), - attrs -> attrs.containsOnly(entry("type", "fetchconsumer"))), - metric -> - assertGaugeWithAttributes( - metric, - "kafka.request.time.avg", - "The average time the broker has taken to service requests", - "ms", - attrs -> attrs.containsOnly(entry("type", "produce")), - attrs -> attrs.containsOnly(entry("type", "fetchfollower")), - attrs -> attrs.containsOnly(entry("type", "fetchconsumer"))), - metric -> - assertGauge( - metric, - "kafka.partition.count", - "The number of partitions on the broker", - "{partition}"), - metric -> - assertGauge( - metric, - "kafka.partition.offline", - "The number of partitions offline", - "{partition}"), - metric -> - assertGauge( - metric, - "kafka.partition.under_replicated", - "The number of under replicated partitions", - "{partition}"), - metric -> - assertSumWithAttributes( - metric, - "kafka.isr.operation.count", - "The number of in-sync replica shrink and expand operations", - "{operation}", - attrs -> attrs.containsOnly(entry("operation", "shrink")), - attrs -> attrs.containsOnly(entry("operation", "expand"))), - metric -> - assertGauge( - metric, - "kafka.controller.active.count", - "For KRaft mode, the number of active controllers in the cluster. For ZooKeeper, indicates whether the broker is the controller broker.", - "{controller}"), - metric -> - assertSum( - metric, - "kafka.leader.election.rate", - "Leader election rate - increasing indicates broker failures", - "{election}"), - metric -> - assertGauge( - metric, - "kafka.max.lag", - "Max lag in messages between follower and leader replicas", - "{message}"), - metric -> - assertSum( - metric, - "kafka.unclean.election.rate", - "Unclean leader election rate - increasing indicates broker failures", - "{election}")); - } - - static class KafkaBrokerTargetIntegrationTest extends KafkaIntegrationTest { - KafkaBrokerTargetIntegrationTest() { - super("target-systems/kafka.properties"); - } - - @Container GenericContainer producer = kafkaProducerContainer(); - - @Test - void endToEnd() { - waitAndAssertMetrics(kafkaBrokerAssertions()); - } - } - - static class KafkaConsumerIntegrationTest extends KafkaIntegrationTest { - KafkaConsumerIntegrationTest() { - super("target-systems/kafka-consumer.properties"); - } - - @Container - GenericContainer consumer = - new GenericContainer<>("bitnamilegacy/kafka:2.8.1") - .withNetwork(Network.SHARED) - .withEnv("KAFKA_CFG_ZOOKEEPER_CONNECT", "zookeeper:2181") - .withEnv("ALLOW_PLAINTEXT_LISTENER", "yes") - .withEnv("JMX_PORT", "7199") - .withNetworkAliases("kafka-consumer") - .withExposedPorts(7199) - .withCommand( - "kafka-console-consumer.sh", - "--bootstrap-server", - "kafka:9092", - "--whitelist", - "test-topic-.*", - "--max-messages", - "100") - .withStartupTimeout(Duration.ofMinutes(2)) - .waitingFor(Wait.forLogMessage(".*Welcome to the Bitnami kafka container.*", 1)) - .dependsOn(createTopics); - - @Test - void endToEnd() { - List topics = Arrays.asList("test-topic-1", "test-topic-2", "test-topic-3"); - waitAndAssertMetrics( - metric -> - assertKafkaGauge( - metric, - "kafka.consumer.bytes-consumed-rate", - "The average number of bytes consumed per second", - "By", - topics), - metric -> - assertKafkaGauge( - metric, - "kafka.consumer.fetch-rate", - "The number of fetch requests for all topics per second", - "{request}"), - metric -> - assertKafkaGauge( - metric, - "kafka.consumer.fetch-size-avg", - "The average number of bytes fetched per request", - "By", - topics), - metric -> - assertKafkaGauge( - metric, - "kafka.consumer.records-consumed-rate", - "The average number of records consumed per second", - "{record}", - topics), - metric -> - assertKafkaGauge( - metric, - "kafka.consumer.records-lag-max", - "Number of messages the consumer lags behind the producer", - "{record}"), - metric -> - assertKafkaGauge( - metric, - "kafka.consumer.total.bytes-consumed-rate", - "The average number of bytes consumed for all topics per second", - "By"), - metric -> - assertKafkaGauge( - metric, - "kafka.consumer.total.fetch-size-avg", - "The average number of bytes fetched per request for all topics", - "By"), - metric -> - assertKafkaGauge( - metric, - "kafka.consumer.total.records-consumed-rate", - "The average number of records consumed for all topics per second", - "{record}")); - } - } - - static class KafkaProducerIntegrationTest extends KafkaIntegrationTest { - KafkaProducerIntegrationTest() { - super("target-systems/kafka-producer.properties"); - } - - @Container GenericContainer producer = kafkaProducerContainer(); - - @Test - void endToEnd() { - List topics = Collections.singletonList("test-topic-1"); - waitAndAssertMetrics( - metric -> - assertKafkaGauge( - metric, - "kafka.producer.byte-rate", - "The average number of bytes sent per second for a topic", - "By", - topics), - metric -> - assertKafkaGauge( - metric, - "kafka.producer.compression-rate", - "The average compression rate of record batches for a topic", - "{ratio}", - topics), - metric -> - assertKafkaGauge( - metric, - "kafka.producer.io-wait-time-ns-avg", - "The average length of time the I/O thread spent waiting for a socket ready for reads or writes", - "ns"), - metric -> - assertKafkaGauge( - metric, - "kafka.producer.outgoing-byte-rate", - "The average number of outgoing bytes sent per second to all servers", - "By"), - metric -> - assertKafkaGauge( - metric, - "kafka.producer.record-error-rate", - "The average per-second number of record sends that resulted in errors for a topic", - "{record}", - topics), - metric -> - assertKafkaGauge( - metric, - "kafka.producer.record-retry-rate", - "The average per-second number of retried record sends for a topic", - "{record}", - topics), - metric -> - assertKafkaGauge( - metric, - "kafka.producer.record-send-rate", - "The average number of records sent per second for a topic", - "{record}", - topics), - metric -> - assertKafkaGauge( - metric, - "kafka.producer.request-latency-avg", - "The average request latency", - "ms"), - metric -> - assertKafkaGauge( - metric, - "kafka.producer.request-rate", - "The average number of requests sent per second", - "{request}"), - metric -> - assertKafkaGauge( - metric, - "kafka.producer.response-rate", - "Responses received per second", - "{response}")); - } - } - - static class KafkaAndJvmIntegrationText extends KafkaIntegrationTest { - KafkaAndJvmIntegrationText() { - super("target-systems/jvm-and-kafka.properties"); - } - - @Test - void endToEnd() { - List gcLabels = - Arrays.asList( - "CodeHeap 'non-nmethods'", - "CodeHeap 'non-profiled nmethods'", - "CodeHeap 'profiled nmethods'", - "Compressed Class Space", - "G1 Eden Space", - "G1 Old Gen", - "G1 Survivor Space", - "Metaspace"); - List> assertions = new ArrayList<>(kafkaBrokerAssertions()); - assertions.addAll( - Arrays.asList( - metric -> - assertGauge(metric, "jvm.classes.loaded", "number of loaded classes", "{class}"), - metric -> - assertTypedSum( - metric, - "jvm.gc.collections.count", - "total number of collections that have occurred", - "{collection}", - Arrays.asList("G1 Young Generation", "G1 Old Generation")), - metric -> - assertTypedSum( - metric, - "jvm.gc.collections.elapsed", - "the approximate accumulated collection elapsed time in milliseconds", - "ms", - Arrays.asList("G1 Young Generation", "G1 Old Generation")), - metric -> - assertGauge(metric, "jvm.memory.heap.committed", "current heap usage", "By"), - metric -> assertGauge(metric, "jvm.memory.heap.init", "current heap usage", "By"), - metric -> assertGauge(metric, "jvm.memory.heap.max", "current heap usage", "By"), - metric -> assertGauge(metric, "jvm.memory.heap.used", "current heap usage", "By"), - metric -> - assertGauge( - metric, "jvm.memory.nonheap.committed", "current non-heap usage", "By"), - metric -> - assertGauge(metric, "jvm.memory.nonheap.init", "current non-heap usage", "By"), - metric -> - assertGauge(metric, "jvm.memory.nonheap.max", "current non-heap usage", "By"), - metric -> - assertGauge(metric, "jvm.memory.nonheap.used", "current non-heap usage", "By"), - metric -> - assertTypedGauge( - metric, - "jvm.memory.pool.committed", - "current memory pool usage", - "By", - gcLabels), - metric -> - assertTypedGauge( - metric, "jvm.memory.pool.init", "current memory pool usage", "By", gcLabels), - metric -> - assertTypedGauge( - metric, "jvm.memory.pool.max", "current memory pool usage", "By", gcLabels), - metric -> - assertTypedGauge( - metric, "jvm.memory.pool.used", "current memory pool usage", "By", gcLabels), - metric -> assertGauge(metric, "jvm.threads.count", "number of threads", "{thread}"))); - - waitAndAssertMetrics(assertions); - } - } - - static void assertKafkaGauge(Metric metric, String name, String description, String unit) { - assertThat(metric.getName()).isEqualTo(name); - assertThat(metric.getDescription()).isEqualTo(description); - assertThat(metric.getUnit()).isEqualTo(unit); - assertThat(metric.hasGauge()).isTrue(); - - assertThat(metric.getGauge().getDataPointsList()) - .satisfiesExactly(point -> - assertThat(point.getAttributesList()) - .singleElement() - .satisfies(attribute -> { - assertThat(attribute.getKey()).isEqualTo("client-id"); - assertThat(attribute.getValue().getStringValue()).isNotEmpty(); - })); - } - - @SuppressWarnings("unchecked") - static void assertKafkaGauge( - Metric metric, String name, String description, String unit, List topics) { - assertThat(metric.getName()).isEqualTo(name); - assertThat(metric.getDescription()).isEqualTo(description); - assertThat(metric.getUnit()).isEqualTo(unit); - assertThat(metric.hasGauge()).isTrue(); - - assertThat(metric.getGauge().getDataPointsList()) - .satisfiesExactlyInAnyOrder( - topics.stream() - .map(topic -> - (Consumer) - point -> - assertThat(point.getAttributesList()) - .satisfiesExactlyInAnyOrder( - attribute -> { - assertThat(attribute.getKey()).isEqualTo("client-id"); - assertThat(attribute.getValue().getStringValue()) - .isNotEmpty(); - }, - attribute -> { - assertThat(attribute.getKey()).isEqualTo("topic"); - assertThat(attribute.getValue().getStringValue()) - .isEqualTo(topic); - })) - .toArray(Consumer[]::new)); - } -} diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/SolrIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/SolrIntegrationTest.java deleted file mode 100644 index d851a679d5..0000000000 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/SolrIntegrationTest.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics.target_systems; - -import static org.assertj.core.api.Assertions.entry; - -import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest; -import io.opentelemetry.proto.metrics.v1.Metric; -import java.time.Duration; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnJre; -import org.junit.jupiter.api.condition.JRE; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.Network; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.junit.jupiter.Container; - -// possible workaround on Java 8: -// https://stackoverflow.com/questions/35466461/how-to-connect-with-jmx-from-host-to-docker-container-in-docker-machine -@DisabledOnJre(JRE.JAVA_8) -class SolrIntegrationTest extends AbstractIntegrationTest { - - SolrIntegrationTest() { - super(/* configFromStdin= */ false, "target-systems/solr.properties"); - } - - @Container - GenericContainer solr = - new GenericContainer<>("solr:8.8.2") - .withNetwork(Network.SHARED) - .withEnv("LOCAL_JMX", "no") - .withEnv("ENABLE_REMOTE_JMX_OPTS", "true") - .withEnv("RMI_PORT", "9990") - .withCommand("solr-precreate", "gettingstarted") - .withNetworkAliases("solr") - .withExposedPorts(9990) - .withStartupTimeout(Duration.ofMinutes(2)) - .waitingFor(Wait.forListeningPort()); - - @Test - void endToEnd() { - waitAndAssertMetrics( - metric -> - assertSumWithAttributes( - metric, - "solr.document.count", - "The total number of indexed documents.", - "{document}", - attrs -> attrs.containsOnly(entry("core", "gettingstarted"))), - metric -> - assertSumWithAttributes( - metric, - "solr.index.size", - "The total index size.", - "By", - attrs -> attrs.containsOnly(entry("core", "gettingstarted"))), - metric -> - assertSolrRequestSumMetric( - metric, "solr.request.count", "The number of queries made.", "{query}"), - metric -> - assertSolrRequestGaugeMetric( - metric, - "solr.request.time.average", - "The average time of a query, based on Solr's histogram configuration.", - "ms"), - metric -> - assertSolrRequestSumMetric( - metric, - "solr.request.error.count", - "The number of queries resulting in an error.", - "{query}"), - metric -> - assertSolrRequestSumMetric( - metric, - "solr.request.timeout.count", - "The number of queries resulting in a timeout.", - "{query}"), - metric -> - assertSolrCacheSumMetric( - metric, - "solr.cache.eviction.count", - "The number of evictions from a cache.", - "{eviction}"), - metric -> - assertSolrCacheSumMetric( - metric, "solr.cache.hit.count", "The number of hits for a cache.", "{hit}"), - metric -> - assertSolrCacheSumMetric( - metric, "solr.cache.insert.count", "The number of inserts to a cache.", "{insert}"), - metric -> - assertSolrCacheSumMetric( - metric, "solr.cache.lookup.count", "The number of lookups to a cache.", "{lookup}"), - metric -> - assertSolrCacheSumMetric( - metric, "solr.cache.size", "The size of the cache occupied in memory.", "By")); - } - - private void assertSolrRequestSumMetric( - Metric metric, String name, String description, String unit) { - assertSumWithAttributes( - metric, - name, - description, - unit, - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), entry("handler", "/get"), entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/update/csv"), - entry("type", "UPDATE")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/query"), - entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/graph"), - entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "update"), - entry("type", "UPDATE")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/update"), - entry("type", "UPDATE")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/debug/dump"), - entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/update/json"), - entry("type", "UPDATE")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/stream"), - entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/export"), - entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/update/json/docs"), - entry("type", "UPDATE")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), entry("handler", "/sql"), entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/select"), - entry("type", "QUERY"))); - } - - private void assertSolrRequestGaugeMetric( - Metric metric, String name, String description, String unit) { - assertGaugeWithAttributes( - metric, - name, - description, - unit, - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), entry("handler", "/get"), entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/update/csv"), - entry("type", "UPDATE")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/query"), - entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/graph"), - entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "update"), - entry("type", "UPDATE")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/update"), - entry("type", "UPDATE")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/debug/dump"), - entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/update/json"), - entry("type", "UPDATE")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/stream"), - entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/export"), - entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/update/json/docs"), - entry("type", "UPDATE")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), entry("handler", "/sql"), entry("type", "QUERY")), - attrs -> - attrs.containsExactly( - entry("core", "gettingstarted"), - entry("handler", "/select"), - entry("type", "QUERY"))); - } - - private void assertSolrCacheSumMetric( - Metric metric, String name, String description, String unit) { - assertSumWithAttributes( - metric, - name, - description, - unit, - attrs -> - attrs.containsExactly(entry("core", "gettingstarted"), entry("cache", "searcher"))); - } -} diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/TomcatIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/TomcatIntegrationTest.java deleted file mode 100644 index fc52986676..0000000000 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/TomcatIntegrationTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics.target_systems; - -import static org.assertj.core.api.Assertions.entry; - -import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest; -import java.time.Duration; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.Network; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.images.builder.ImageFromDockerfile; -import org.testcontainers.junit.jupiter.Container; - -class TomcatIntegrationTest extends AbstractIntegrationTest { - - TomcatIntegrationTest() { - super(/* configFromStdin= */ false, "target-systems/tomcat.properties"); - } - - @Container - GenericContainer tomcat = - new GenericContainer<>( - new ImageFromDockerfile() - .withDockerfileFromBuilder(builder -> - builder - .from("tomcat:9.0") - .run("rm", "-fr", "/usr/local/tomcat/webapps/ROOT") - .add( - "https://tomcat.apache.org/tomcat-9.0-doc/appdev/sample/sample.war", - "/usr/local/tomcat/webapps/ROOT.war") - .env( - "CATALINA_OPTS", - "-Dcom.sun.management.jmxremote.local.only=false " - + "-Dcom.sun.management.jmxremote.authenticate=false " - + "-Dcom.sun.management.jmxremote.ssl=false " - + "-Dcom.sun.management.jmxremote.port=9010 " - + "-Dcom.sun.management.jmxremote.rmi.port=9010") - .build())) - .withNetwork(Network.SHARED) - .withEnv("LOCAL_JMX", "no") - .withNetworkAliases("tomcat") - .withExposedPorts(9010) - .withStartupTimeout(Duration.ofMinutes(2)) - .waitingFor(Wait.forListeningPort()); - - @Test - void endToEnd() { - waitAndAssertMetrics( - metric -> - assertGauge(metric, "tomcat.sessions", "The number of active sessions.", "{session}"), - metric -> - assertSumWithAttributes( - metric, - "tomcat.errors", - "The number of errors encountered.", - "{error}", - attrs -> attrs.containsOnly(entry("proto_handler", "\"http-nio-8080\""))), - metric -> - assertSumWithAttributes( - metric, - "tomcat.processing_time", - "The total processing time.", - "ms", - attrs -> attrs.containsOnly(entry("proto_handler", "\"http-nio-8080\""))), - metric -> - assertSumWithAttributes( - metric, - "tomcat.traffic", - "The number of bytes transmitted and received.", - "By", - attrs -> - attrs.containsOnly( - entry("proto_handler", "\"http-nio-8080\""), entry("direction", "sent")), - attrs -> - attrs.containsOnly( - entry("proto_handler", "\"http-nio-8080\""), - entry("direction", "received"))), - metric -> - assertGaugeWithAttributes( - metric, - "tomcat.threads", - "The number of threads", - "{thread}", - attrs -> - attrs.containsOnly( - entry("proto_handler", "\"http-nio-8080\""), entry("state", "idle")), - attrs -> - attrs.containsOnly( - entry("proto_handler", "\"http-nio-8080\""), entry("state", "busy"))), - metric -> - assertGaugeWithAttributes( - metric, - "tomcat.max_time", - "Maximum time to process a request.", - "ms", - attrs -> attrs.containsOnly(entry("proto_handler", "\"http-nio-8080\""))), - metric -> - assertSumWithAttributes( - metric, - "tomcat.request_count", - "The total requests.", - "{request}", - attrs -> attrs.containsOnly(entry("proto_handler", "\"http-nio-8080\"")))); - } -} diff --git a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/WildflyIntegrationTest.java b/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/WildflyIntegrationTest.java deleted file mode 100644 index c5e208f785..0000000000 --- a/jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/target_systems/WildflyIntegrationTest.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics.target_systems; - -import static org.assertj.core.api.Assertions.entry; - -import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest; -import java.time.Duration; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.Network; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.utility.MountableFile; - -class WildflyIntegrationTest extends AbstractIntegrationTest { - - WildflyIntegrationTest() { - super(/* configFromStdin= */ false, "target-systems/wildfly.properties"); - } - - /* In order to create a JMX connection to WildFLy, the scraper requires an additional - client jar in the classpath. To facilitate this, the scraper runs in the same container, - which gives it access to the client jar packaged with WildFly. */ - @Override - protected GenericContainer buildScraper(String otlpEndpoint) { - String scraperJarPath = System.getProperty("shadow.jar.path"); - - return new GenericContainer<>("jboss/wildfly:23.0.1.Final") - .withNetwork(Network.SHARED) - .withNetworkAliases("wildfly") - .withCopyFileToContainer( - MountableFile.forHostPath(scraperJarPath), "/app/OpenTelemetryJMXMetrics.jar") - .withCopyFileToContainer( - MountableFile.forClasspathResource("script.groovy"), "/app/script.groovy") - .withCopyFileToContainer( - MountableFile.forClasspathResource("target-systems/wildfly.properties"), - "/app/target-systems/wildfly.properties") - .withCopyFileToContainer( - MountableFile.forClasspathResource("wildfly/start.sh", 0007), "/app/start.sh") - .withEnv("OTLP_ENDPOINT", otlpEndpoint) - .withCommand("/app/start.sh") - .withStartupTimeout(Duration.ofMinutes(2)) - .waitingFor(Wait.forLogMessage(".*Started GroovyRunner.*", 1)); - } - - @Test - void endToEnd() { - waitAndAssertMetrics( - metric -> - assertSumWithAttributes( - metric, - "wildfly.request.count", - "The number of requests received.", - "{request}", - attrs -> - attrs.containsOnly( - entry("server", "default-server"), entry("listener", "default"))), - metric -> - assertSumWithAttributes( - metric, - "wildfly.request.time", - "The total amount of time spent on requests.", - "ns", - attrs -> - attrs.containsOnly( - entry("server", "default-server"), entry("listener", "default"))), - metric -> - assertSumWithAttributes( - metric, - "wildfly.request.server_error", - "The number of requests that have resulted in a 5xx response.", - "{request}", - attrs -> - attrs.containsOnly( - entry("server", "default-server"), entry("listener", "default"))), - metric -> - assertSumWithAttributes( - metric, - "wildfly.network.io", - "The number of bytes transmitted.", - "By", - attrs -> - attrs.containsOnly( - entry("server", "default-server"), - entry("listener", "default"), - entry("state", "in")), - attrs -> - attrs.containsOnly( - entry("server", "default-server"), - entry("listener", "default"), - entry("state", "out"))), - metric -> - assertSumWithAttributes( - metric, - "wildfly.jdbc.connection.open", - "The number of open jdbc connections.", - "{connection}", - attrs -> - attrs.containsOnly(entry("data_source", "ExampleDS"), entry("state", "active")), - attrs -> - attrs.containsOnly(entry("data_source", "ExampleDS"), entry("state", "idle"))), - metric -> - assertSumWithAttributes( - metric, - "wildfly.jdbc.request.wait", - "The number of jdbc connections that had to wait before opening.", - "{request}", - attrs -> attrs.containsOnly(entry("data_source", "ExampleDS"))), - metric -> - assertSum( - metric, - "wildfly.jdbc.transaction.count", - "The number of transactions created.", - "{transaction}"), - metric -> - assertSumWithAttributes( - metric, - "wildfly.jdbc.rollback.count", - "The number of transactions rolled back.", - "{transaction}", - attrs -> attrs.containsOnly(entry("cause", "system")), - attrs -> attrs.containsOnly(entry("cause", "resource")), - attrs -> attrs.containsOnly(entry("cause", "application")))); - } -} diff --git a/jmx-metrics/src/integrationTest/resources/activemq/Dockerfile b/jmx-metrics/src/integrationTest/resources/activemq/Dockerfile deleted file mode 100644 index 7d5db75be2..0000000000 --- a/jmx-metrics/src/integrationTest/resources/activemq/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM rmohr/activemq:5.15.9@sha256:b5669f141ac5c455b1010b90d348fe78289bba7e2db5659484d99736b696593c - - -COPY --chown=activemq config/env /opt/activemq/bin/env -ENV ACTIVEMQ_JMX=10991 -EXPOSE $ACTIVEMQ_JMX - -ENV ACTIVEMQ_JMX_OPTS="-Dcom.sun.management.jmxremote.port=10991 -Dcom.sun.management.jmxremote.rmi.port=10991 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false" diff --git a/jmx-metrics/src/integrationTest/resources/activemq/config/env b/jmx-metrics/src/integrationTest/resources/activemq/config/env deleted file mode 100644 index bfcc87c6f4..0000000000 --- a/jmx-metrics/src/integrationTest/resources/activemq/config/env +++ /dev/null @@ -1,117 +0,0 @@ - #!/bin/sh - # ------------------------------------------------------------------------ - # Licensed to the Apache Software Foundation (ASF) under one or more - # contributor license agreements. See the NOTICE file distributed with - # this work for additional information regarding copyright ownership. - # The ASF licenses this file to You under the Apache License, Version 2.0 - # (the "License"); you may not use this file except in compliance with - # the License. You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------ - # - # Configuration file for running Apache Active MQ as standalone provider. - # - # This file overwrites the predefined settings of the sysv init-script. - # You can also use alternate location for default settings - - # invoke the init-script without a argument an review help section "Configuration of this script" - # /etc/default/activemq /.activemqrc /bin/env - - # Active MQ installation dirs - # ACTIVEMQ_HOME="/" - # ACTIVEMQ_BASE="$ACTIVEMQ_HOME" - # ACTIVEMQ_CONF="$ACTIVEMQ_BASE/conf" - # ACTIVEMQ_DATA="$ACTIVEMQ_BASE/data" - # ACTIVEMQ_TMP="$ACTIVEMQ_BASE/tmp" - - # Set jvm memory configuration (minimal/maximum amount of memory) - ACTIVEMQ_OPTS_MEMORY="-Xms64M -Xmx256M" - - if [ -z "$ACTIVEMQ_OPTS" ] ; then - ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config" - fi - - if [ -z "$ACTIVEMQ_OUT" ]; then - ACTIVEMQ_OUT="/dev/null" - fi - - # Uncomment to enable audit logging - #ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS -Dorg.apache.activemq.audit=true" - - # Set jvm jmx configuration - # This enables jmx access over a configured jmx-tcp-port. - # You have to configure the first four settings if you run a ibm jvm, caused by the - # fact that IBM's jvm does not support VirtualMachine.attach(PID). - # JMX access is needed for quering a running activemq instance to gain data or to - # trigger management operations. - # - # Example for ${ACTIVEMQ_CONF}/jmx.access: - # --- - # # The "monitorRole" role has readonly access. - # # The "controlRole" role has readwrite access. - # monitorRole readonly - # controlRole readwrite - # --- - # - # Example for ${ACTIVEMQ_CONF}/jmx.password: - # --- - # # The "monitorRole" role has password "abc123". - # # # The "controlRole" role has password "abcd1234". - # monitorRole abc123 - # controlRole abcd1234 - # --- - # - # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.port=11099 " - # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.password.file=${ACTIVEMQ_CONF}/jmx.password" - # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.access.file=${ACTIVEMQ_CONF}/jmx.access" - # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.ssl=false" - # ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote" - ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote" - - # Set jvm jmx configuration for controlling the broker process - # You only have to configure the first four settings if you run a ibm jvm, caused by the - # fact that IBM's jvm does not support VirtualMachine.attach(PID) - # (see also com.sun.management.jmxremote.port, .jmx.password.file and .jmx.access.file ) - #ACTIVEMQ_SUNJMX_CONTROL="--jmxurl service:jmx:rmi:///jndi/rmi://127.0.0.1:1099/jmxrmi --jmxuser controlRole --jmxpassword abcd1234" - ACTIVEMQ_SUNJMX_CONTROL="" - - # Specify the queue manager URL for using "browse" option of sysv initscript - if [ -z "$ACTIVEMQ_QUEUEMANAGERURL" ]; then - ACTIVEMQ_QUEUEMANAGERURL="--amqurl tcp://localhost:61616" - fi - - # Set additional JSE arguments - if [ -z "$ACTIVEMQ_SSL_OPTS" ] ; then - #ACTIVEMQ_SSL_OPTS="-Djava.security.properties=$ACTIVEMQ_CONF/java.security" - ACTIVEMQ_SSL_OPTS="" - fi - - # Uncomment to enable remote debugging - #ACTIVEMQ_DEBUG_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005" - - # ActiveMQ tries to shutdown the broker by jmx, - # after a specified number of seconds send SIGKILL - if [ -z "$ACTIVEMQ_KILL_MAXSECONDS" ]; then - ACTIVEMQ_KILL_MAXSECONDS=30 - fi - - # Configure a user with non root privileges, if no user is specified do not change user - # (the entire activemq installation should be owned by this user) - ACTIVEMQ_USER="" - - # location of the pidfile - # ACTIVEMQ_PIDFILE="$ACTIVEMQ_DATA/activemq.pid" - - # Location of the java installation - # Specify the location of your java installation using JAVA_HOME, or specify the - # path to the "java" binary using JAVACMD - # (set JAVACMD to "auto" for automatic detection) - #JAVA_HOME="" - JAVACMD="auto" - ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS $ACTIVEMQ_JMX_OPTS -Dhawtio.authenticationEnabled=false -Dhawtio.realm=activemq -Dhawtio.role=admins -Dhawtio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal" diff --git a/jmx-metrics/src/integrationTest/resources/cassandra/jmxremote.password b/jmx-metrics/src/integrationTest/resources/cassandra/jmxremote.password deleted file mode 100644 index 4c792a0a22..0000000000 --- a/jmx-metrics/src/integrationTest/resources/cassandra/jmxremote.password +++ /dev/null @@ -1 +0,0 @@ -cassandra cassandra \ No newline at end of file diff --git a/jmx-metrics/src/integrationTest/resources/hadoop/hadoop-env.sh b/jmx-metrics/src/integrationTest/resources/hadoop/hadoop-env.sh deleted file mode 100644 index 059a5d0b23..0000000000 --- a/jmx-metrics/src/integrationTest/resources/hadoop/hadoop-env.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash - -# Set Hadoop-specific environment variables here. - -# The only required environment variable is JAVA_HOME. All others are -# optional. When running a distributed configuration it is best to -# set JAVA_HOME in this file, so that it is correctly defined on -# remote nodes. - -# The java implementation to use. -export JAVA_HOME=${JAVA_HOME} - -# The jsvc implementation to use. Jsvc is required to run secure datanodes -# that bind to privileged ports to provide authentication of data transfer -# protocol. Jsvc is not required if SASL is configured for authentication of -# data transfer protocol using non-privileged ports. -#export JSVC_HOME=${JSVC_HOME} - -export HADOOP_CONF_DIR=${HADOOP_CONF_DIR:-"/etc/hadoop"} - -# Extra Java CLASSPATH elements. Automatically insert capacity-scheduler. -for f in "$HADOOP_HOME"/contrib/capacity-scheduler/*.jar; do - if [ "$HADOOP_CLASSPATH" ]; then - export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$f - else - export HADOOP_CLASSPATH=$f - fi -done - -# The maximum amount of heap to use, in MB. Default is 1000. -#export HADOOP_HEAPSIZE= -#export HADOOP_NAMENODE_INIT_HEAPSIZE="" - -# Enable extra debugging of Hadoop's JAAS binding, used to set up -# Kerberos security. -# export HADOOP_JAAS_DEBUG=true - -# Extra Java runtime options. Empty by default. -# For Kerberos debugging, an extended option set logs more invormation -# export HADOOP_OPTS="-Djava.net.preferIPv4Stack=true -Dsun.security.krb5.debug=true -Dsun.security.spnego.debug" -export HADOOP_OPTS="$HADOOP_OPTS -Djava.net.preferIPv4Stack=true" - -# Command specific options appended to HADOOP_OPTS when specified -export HADOOP_NAMENODE_OPTS="-Dhadoop.security.logger=${HADOOP_SECURITY_LOGGER:-INFO,RFAS} -Dhdfs.audit.logger=${HDFS_AUDIT_LOGGER:-INFO,NullAppender} $HADOOP_NAMENODE_OPTS" -export HADOOP_NAMENODE_OPTS="-Dcom.sun.management.jmxremote $HADOOP_NAMENODE_OPTS" -export HADOOP_NAMENODE_OPTS="$HADOOP_NAMENODE_OPTS -Dcom.sun.management.jmxremote.authenticate=false" -export HADOOP_NAMENODE_OPTS="$HADOOP_NAMENODE_OPTS -Dcom.sun.management.jmxremote.ssl=false" -export HADOOP_NAMENODE_OPTS="$HADOOP_NAMENODE_OPTS -Dcom.sun.management.jmxremote.port=8004 -Dcom.sun.management.jmxremote.rmi.port=8004" - -export HADOOP_DATANODE_OPTS="-Dhadoop.security.logger=ERROR,RFAS $HADOOP_DATANODE_OPTS" - -export HADOOP_SECONDARYNAMENODE_OPTS="-Dhadoop.security.logger=${HADOOP_SECURITY_LOGGER:-INFO,RFAS} -Dhdfs.audit.logger=${HDFS_AUDIT_LOGGER:-INFO,NullAppender} $HADOOP_SECONDARYNAMENODE_OPTS" - -export HADOOP_NFS3_OPTS="$HADOOP_NFS3_OPTS" -export HADOOP_PORTMAP_OPTS="-Xmx512m $HADOOP_PORTMAP_OPTS" - -# The following applies to multiple commands (fs, dfs, fsck, distcp etc) -export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS" -# set heap args when HADOOP_HEAPSIZE is empty -if [ "$HADOOP_HEAPSIZE" = "" ]; then - export HADOOP_CLIENT_OPTS="-Xmx512m $HADOOP_CLIENT_OPTS" -fi -#HADOOP_JAVA_PLATFORM_OPTS="-XX:-UsePerfData $HADOOP_JAVA_PLATFORM_OPTS" - -# On secure datanodes, user to run the datanode as after dropping privileges. -# This **MUST** be uncommented to enable secure HDFS if using privileged ports -# to provide authentication of data transfer protocol. This **MUST NOT** be -# defined if SASL is configured for authentication of data transfer protocol -# using non-privileged ports. -export HADOOP_SECURE_DN_USER=${HADOOP_SECURE_DN_USER} - -# Where log files are stored. $HADOOP_HOME/logs by default. -#export HADOOP_LOG_DIR=${HADOOP_LOG_DIR}/$USER - -# Where log files are stored in the secure data environment. -#export HADOOP_SECURE_DN_LOG_DIR=${HADOOP_LOG_DIR}/${HADOOP_HDFS_USER} - -### -# HDFS Mover specific parameters -### -# Specify the JVM options to be used when starting the HDFS Mover. -# These options will be appended to the options specified as HADOOP_OPTS -# and therefore may override any similar flags set in HADOOP_OPTS -# -# export HADOOP_MOVER_OPTS="" - -### -# Advanced Users Only! -### - -# The directory where pid files are stored. /tmp by default. -# NOTE: this should be set to a directory that can only be written to by -# the user that will run the hadoop daemons. Otherwise there is the -# potential for a symlink attack. -export HADOOP_PID_DIR=${HADOOP_PID_DIR} -export HADOOP_SECURE_DN_PID_DIR=${HADOOP_PID_DIR} - -# A string representing this instance of hadoop. $USER by default. -export HADOOP_IDENT_STRING=$USER diff --git a/jmx-metrics/src/integrationTest/resources/hadoop/yarn-site.xml b/jmx-metrics/src/integrationTest/resources/hadoop/yarn-site.xml deleted file mode 100644 index 208671b557..0000000000 --- a/jmx-metrics/src/integrationTest/resources/hadoop/yarn-site.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - yarn.nodemanager.aux-services - mapreduce_shuffle - - - yarn.nodemanager.disk-health-checker.max-disk-utilization-per-disk-percentage - 100 - - - yarn.nodemanager.resource.cpu-vcores - 2 - - - yarn.nodemanager.resource.memory-mb - 4096 - - diff --git a/jmx-metrics/src/integrationTest/resources/hbase/hbase-env.sh b/jmx-metrics/src/integrationTest/resources/hbase/hbase-env.sh deleted file mode 100644 index d24e1fc606..0000000000 --- a/jmx-metrics/src/integrationTest/resources/hbase/hbase-env.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# Set environment variables here. - -# This script sets variables multiple times over the course of starting an hbase process, -# so try to keep things idempotent unless you want to take an even deeper look -# into the startup scripts (bin/hbase, etc.) - -# The java implementation to use. Java 1.8+ required. -export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 -export HBASE_OPTS="$HBASE_OPTS -XX:+UseConcMarkSweepGC" -export HBASE_JMX_BASE="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false" -export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.rmi.port=9900 -Dcom.sun.management.jmxremote.port=9900" diff --git a/jmx-metrics/src/integrationTest/resources/otlp_config.properties b/jmx-metrics/src/integrationTest/resources/otlp_config.properties deleted file mode 100644 index d30202c3f6..0000000000 --- a/jmx-metrics/src/integrationTest/resources/otlp_config.properties +++ /dev/null @@ -1,9 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://cassandra:7199/jmxrmi -otel.jmx.groovy.script = /app/script.groovy - -# these will be overridden by cmd line -otel.jmx.username = wrong_username -otel.jmx.password = wrong_password -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/script.groovy b/jmx-metrics/src/integrationTest/resources/script.groovy deleted file mode 100644 index 0ed6c493f1..0000000000 --- a/jmx-metrics/src/integrationTest/resources/script.groovy +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import io.opentelemetry.api.common.Attributes - -def loadMatches = otel.queryJmx("org.apache.cassandra.metrics:type=Storage,name=Load") -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()) -} diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/activemq.properties b/jmx-metrics/src/integrationTest/resources/target-systems/activemq.properties deleted file mode 100644 index e69b6ba2ef..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/activemq.properties +++ /dev/null @@ -1,7 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://activemq:10991/jmxrmi -otel.jmx.target.system = activemq - -# these will be overridden by cmd line -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/cassandra.properties b/jmx-metrics/src/integrationTest/resources/target-systems/cassandra.properties deleted file mode 100644 index 14e366d69b..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/cassandra.properties +++ /dev/null @@ -1,9 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://cassandra:7199/jmxrmi -otel.jmx.target.system = cassandra - -# these will be overridden by cmd line -otel.jmx.username = wrong_username -otel.jmx.password = wrong_password -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/hadoop.properties b/jmx-metrics/src/integrationTest/resources/target-systems/hadoop.properties deleted file mode 100644 index 68030a67be..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/hadoop.properties +++ /dev/null @@ -1,7 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://hadoop:8004/jmxrmi -otel.jmx.target.system = hadoop - -# these will be overridden by cmd line -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/hbase.properties b/jmx-metrics/src/integrationTest/resources/target-systems/hbase.properties deleted file mode 100644 index 19965aa8ea..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/hbase.properties +++ /dev/null @@ -1,7 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://hbase:9900/jmxrmi -otel.jmx.target.system = hbase - -# these will be overridden by cmd line -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/jetty.properties b/jmx-metrics/src/integrationTest/resources/target-systems/jetty.properties deleted file mode 100644 index 09f7325a2f..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/jetty.properties +++ /dev/null @@ -1,7 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://jetty:1099/jmxrmi -otel.jmx.target.system = jetty - -# these will be overridden by cmd line -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/jvm-and-kafka.properties b/jmx-metrics/src/integrationTest/resources/target-systems/jvm-and-kafka.properties deleted file mode 100644 index 716bf09585..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/jvm-and-kafka.properties +++ /dev/null @@ -1,9 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://kafka:7199/jmxrmi -otel.jmx.target.system = jvm,kafka - -# these will be overridden by cmd line -otel.jmx.username = wrong_username -otel.jmx.password = wrong_password -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/jvm.properties b/jmx-metrics/src/integrationTest/resources/target-systems/jvm.properties deleted file mode 100644 index e1db27782e..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/jvm.properties +++ /dev/null @@ -1,9 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://cassandra:7199/jmxrmi -otel.jmx.target.system = jvm - -# these will be overridden by cmd line -otel.jmx.username = wrong_username -otel.jmx.password = wrong_password -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/kafka-consumer.properties b/jmx-metrics/src/integrationTest/resources/target-systems/kafka-consumer.properties deleted file mode 100644 index 7ea8c1179d..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/kafka-consumer.properties +++ /dev/null @@ -1,9 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://kafka-consumer:7199/jmxrmi -otel.jmx.target.system = kafka-consumer - -# these will be overridden by cmd line -otel.jmx.username = wrong_username -otel.jmx.password = wrong_password -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/kafka-producer.properties b/jmx-metrics/src/integrationTest/resources/target-systems/kafka-producer.properties deleted file mode 100644 index cabc611696..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/kafka-producer.properties +++ /dev/null @@ -1,9 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://kafka-producer:7199/jmxrmi -otel.jmx.target.system = kafka-producer - -# these will be overridden by cmd line -otel.jmx.username = wrong_username -otel.jmx.password = wrong_password -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/kafka-producer.sh b/jmx-metrics/src/integrationTest/resources/target-systems/kafka-producer.sh deleted file mode 100755 index 1ef355bde2..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/kafka-producer.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -function msg() { - while true; do - echo 'some message' - sleep .25 - done -} - -msg | kafka-console-producer.sh --bootstrap-server kafka:9092 --topic test-topic-1 diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/kafka.properties b/jmx-metrics/src/integrationTest/resources/target-systems/kafka.properties deleted file mode 100644 index 559399ba9c..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/kafka.properties +++ /dev/null @@ -1,9 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://kafka:7199/jmxrmi -otel.jmx.target.system = kafka - -# these will be overridden by cmd line -otel.jmx.username = wrong_username -otel.jmx.password = wrong_password -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/solr.properties b/jmx-metrics/src/integrationTest/resources/target-systems/solr.properties deleted file mode 100644 index 9135ae3c2e..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/solr.properties +++ /dev/null @@ -1,7 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://solr:9990/jmxrmi -otel.jmx.target.system = solr - -# these will be overridden by cmd line -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/tomcat.properties b/jmx-metrics/src/integrationTest/resources/target-systems/tomcat.properties deleted file mode 100644 index 62abe86833..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/tomcat.properties +++ /dev/null @@ -1,9 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://tomcat:9010/jmxrmi -otel.jmx.target.system = tomcat - -# these will be overridden by cmd line -otel.jmx.username = wrong_username -otel.jmx.password = wrong_password -otel.exporter.otlp.endpoint = http://host.testcontainers.internal diff --git a/jmx-metrics/src/integrationTest/resources/target-systems/wildfly.properties b/jmx-metrics/src/integrationTest/resources/target-systems/wildfly.properties deleted file mode 100644 index 00e183ab18..0000000000 --- a/jmx-metrics/src/integrationTest/resources/target-systems/wildfly.properties +++ /dev/null @@ -1,4 +0,0 @@ -otel.jmx.interval.milliseconds = 3000 -otel.metrics.exporter = otlp -otel.jmx.service.url = service:jmx:remote+http://wildfly:9990 -otel.jmx.target.system = wildfly diff --git a/jmx-metrics/src/integrationTest/resources/wildfly/start.sh b/jmx-metrics/src/integrationTest/resources/wildfly/start.sh deleted file mode 100644 index 670b91a0bc..0000000000 --- a/jmx-metrics/src/integrationTest/resources/wildfly/start.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -/opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 & \ - -/opt/jboss/wildfly/bin/add-user.sh user password --silent & \ - -java -cp /app/OpenTelemetryJMXMetrics.jar:/opt/jboss/wildfly/bin/client/jboss-client.jar \ - -Dotel.jmx.username=user -Dotel.jmx.password=password \ - -Dotel.exporter.otlp.endpoint="$OTLP_ENDPOINT" \ - io.opentelemetry.contrib.jmxmetrics.JmxMetrics -config /app/target-systems/wildfly.properties diff --git a/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/ClientCallbackHandler.java b/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/ClientCallbackHandler.java deleted file mode 100644 index fe077f140c..0000000000 --- a/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/ClientCallbackHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics; - -import javax.annotation.Nullable; -import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.callback.NameCallback; -import javax.security.auth.callback.PasswordCallback; -import javax.security.auth.callback.UnsupportedCallbackException; -import javax.security.sasl.RealmCallback; - -public class ClientCallbackHandler implements CallbackHandler { - private final String username; - @Nullable private final char[] password; - private final String realm; - - /** - * Constructor for the {@link ClientCallbackHandler}, a CallbackHandler implementation for - * authenticating with an MBean server. - * - * @param username - authenticating username - * @param password - authenticating password (plaintext) - * @param realm - authenticating realm - */ - public ClientCallbackHandler(String username, String password, String realm) { - this.username = username; - this.password = password != null ? password.toCharArray() : null; - this.realm = realm; - } - - @Override - public void handle(Callback[] callbacks) throws UnsupportedCallbackException { - for (Callback callback : callbacks) { - if (callback instanceof NameCallback) { - ((NameCallback) callback).setName(this.username); - } else if (callback instanceof PasswordCallback) { - ((PasswordCallback) callback).setPassword(this.password); - } else if (callback instanceof RealmCallback) { - ((RealmCallback) callback).setText(this.realm); - } else { - throw new UnsupportedCallbackException(callback); - } - } - } -} diff --git a/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/ConfigurationException.java b/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/ConfigurationException.java deleted file mode 100644 index 9ee71d6677..0000000000 --- a/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/ConfigurationException.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics; - -public class ConfigurationException extends RuntimeException { - private static final long serialVersionUID = 0L; - - public ConfigurationException(String message, Throwable cause) { - super(message, cause); - } - - public ConfigurationException(String message) { - super(message); - } -} diff --git a/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/GroovyMetricEnvironment.java b/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/GroovyMetricEnvironment.java deleted file mode 100644 index c0b07e73a5..0000000000 --- a/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/GroovyMetricEnvironment.java +++ /dev/null @@ -1,504 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics; - -import groovy.lang.Closure; -import groovy.lang.Tuple2; -import io.opentelemetry.api.common.Attributes; -import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.api.metrics.BatchCallback; -import io.opentelemetry.api.metrics.DoubleCounter; -import io.opentelemetry.api.metrics.DoubleHistogram; -import io.opentelemetry.api.metrics.DoubleUpDownCounter; -import io.opentelemetry.api.metrics.LongCounter; -import io.opentelemetry.api.metrics.LongHistogram; -import io.opentelemetry.api.metrics.LongUpDownCounter; -import io.opentelemetry.api.metrics.Meter; -import io.opentelemetry.api.metrics.ObservableDoubleMeasurement; -import io.opentelemetry.api.metrics.ObservableLongMeasurement; -import io.opentelemetry.api.metrics.ObservableMeasurement; -import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk; -import io.opentelemetry.sdk.metrics.InstrumentType; -import io.opentelemetry.sdk.metrics.InstrumentValueType; -import io.opentelemetry.sdk.metrics.SdkMeterProvider; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Consumer; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import javax.annotation.Nullable; - -public class GroovyMetricEnvironment { - private final SdkMeterProvider meterProvider; - private final Meter meter; - - // Observer updaters can only be specified in the builder as of v0.13.0, so to work with our model - // of running groovy scripts on an interval a reference to the desired updater should be held and - // updated w/ each instrument creation call. Otherwise no observed changes in MBean availability - // would be possible. These registry stores are maps of instrument descriptor hashes to updater - // consumer references. - private final Map>> - longUpdaterRegistry = new ConcurrentHashMap<>(); - private final Map>> - doubleUpdaterRegistry = new ConcurrentHashMap<>(); - private final Map>> batchUpdaterRegistry = - new ConcurrentHashMap<>(); - private final Map>> - batchCallbackRegistry = new ConcurrentHashMap<>(); - private final Map instrumentOnceRegistry = - new ConcurrentHashMap<>(); - - /** - * A central context for creating and exporting metrics, to be used by groovy scripts via {@link - * io.opentelemetry.contrib.jmxmetrics.OtelHelper}. - * - * @param config - used to establish exporter type (logging by default) and connection info - * @param instrumentationName - meter's instrumentationName - * @param instrumentationVersion - meter's instrumentationVersion - */ - public GroovyMetricEnvironment( - final JmxConfig config, - final String instrumentationName, - final String instrumentationVersion) { - - switch (config.metricsExporterType.toLowerCase()) { - case "otlp": - case "prometheus": - case "logging": - // call the autoconfigure extension and take care of provider and exporter creation for us - // based on system properties. - meterProvider = - AutoConfiguredOpenTelemetrySdk.builder() - .addPropertiesSupplier(() -> { - Map properties = new HashMap<>(); - // no need for autoconfigure sdk-extension to enable default traces exporter - properties.put("otel.traces.exporter", "none"); - // expose config.properties to autoconfigure - config.properties.forEach((k, value) -> { - String key = k.toString(); - if (key.startsWith("otel.") && !key.startsWith("otel.jmx")) { - properties.put(key, value.toString()); - } - }); - return properties; - }) - .build() - .getOpenTelemetrySdk() - .getSdkMeterProvider(); - break; - default: // inmemory fallback - meterProvider = SdkMeterProvider.builder().build(); - } - - meter = - meterProvider - .meterBuilder(instrumentationName) - .setInstrumentationVersion(instrumentationVersion) - .build(); - } - - // Visible for testing - GroovyMetricEnvironment(SdkMeterProvider meterProvider, String instrumentationName) { - this.meterProvider = meterProvider; - meter = meterProvider.meterBuilder(instrumentationName).build(); - } - - /** - * Configures with default meter identifiers. - * - * @param config - used to establish exporter type (logging by default) and connection info - */ - public GroovyMetricEnvironment(JmxConfig config) { - this( - config, - "io.opentelemetry.contrib.jmxmetrics", - GroovyMetricEnvironment.class.getPackage().getImplementationVersion()); - } - - /** Will collect all metrics from OpenTelemetrySdk and export via configured exporter. */ - public void flush() { - meterProvider.forceFlush().join(10, TimeUnit.SECONDS); - } - - protected static Attributes mapToAttributes(@Nullable Map labelMap) { - if (labelMap == null) { - return Attributes.empty(); - } - AttributesBuilder attrs = Attributes.builder(); - for (Map.Entry kv : labelMap.entrySet()) { - attrs.put(kv.getKey(), kv.getValue()); - } - return attrs.build(); - } - - /** - * Build or retrieve previously registered {@link DoubleCounter}. - * - * @param name - metric name - * @param description metric description - * @param unit - metric unit - * @return new or memoized {@link DoubleCounter} - */ - public DoubleCounter getDoubleCounter( - final String name, final String description, final String unit) { - return meter.counterBuilder(name).setDescription(description).setUnit(unit).ofDoubles().build(); - } - - /** - * Build or retrieve previously registered {@link LongCounter}. - * - * @param name - metric name - * @param description metric description - * @param unit - metric unit - * @return new or memoized {@link LongCounter} - */ - public LongCounter getLongCounter( - final String name, final String description, final String unit) { - return meter.counterBuilder(name).setDescription(description).setUnit(unit).build(); - } - - /** - * Build or retrieve previously registered {@link DoubleUpDownCounter}. - * - * @param name - metric name - * @param description metric description - * @param unit - metric unit - * @return new or memoized {@link DoubleUpDownCounter} - */ - public DoubleUpDownCounter getDoubleUpDownCounter( - final String name, final String description, final String unit) { - return meter - .upDownCounterBuilder(name) - .setDescription(description) - .setUnit(unit) - .ofDoubles() - .build(); - } - - /** - * Build or retrieve previously registered {@link LongUpDownCounter}. - * - * @param name - metric name - * @param description metric description - * @param unit - metric unit - * @return new or memoized {@link LongUpDownCounter} - */ - public LongUpDownCounter getLongUpDownCounter( - final String name, final String description, final String unit) { - return meter.upDownCounterBuilder(name).setDescription(description).setUnit(unit).build(); - } - - /** - * Build or retrieve previously registered {@link DoubleHistogram}. - * - * @param name - metric name - * @param description metric description - * @param unit - metric unit - * @return new or memoized {@link DoubleHistogram} - */ - public DoubleHistogram getDoubleHistogram( - final String name, final String description, final String unit) { - return meter.histogramBuilder(name).setDescription(description).setUnit(unit).build(); - } - - /** - * Build or retrieve previously registered {@link LongHistogram}. - * - * @param name - metric name - * @param description metric description - * @param unit - metric unit - * @return new or memoized {@link LongHistogram} - */ - public LongHistogram getLongHistogram( - final String name, final String description, final String unit) { - return meter.histogramBuilder(name).setDescription(description).setUnit(unit).ofLongs().build(); - } - - /** - * Register a double observable gauge. - * - * @param name - metric name - * @param description metric description - * @param unit - metric unit - * @param updater - the value updater - * @return the ObservableDoubleMeasurement for the gauge - */ - public ObservableDoubleMeasurement registerDoubleValueCallback( - final String name, - final String description, - final String unit, - final Consumer updater) { - int descriptorHash = - InstrumentDescriptor.create( - name, - description, - unit, - InstrumentType.OBSERVABLE_GAUGE, - InstrumentValueType.DOUBLE) - .hashCode(); - - return registerCallback( - doubleUpdaterRegistry, - () -> meter.gaugeBuilder(name).setDescription(description).setUnit(unit).buildObserver(), - descriptorHash, - updater); - } - - /** - * Register a long observable gauge. - * - * @param name - metric name - * @param description metric description - * @param unit - metric unit - * @param updater - the value updater - * @return the ObservableLongMeasurement for the gauge - */ - public ObservableLongMeasurement registerLongValueCallback( - final String name, - final String description, - final String unit, - final Consumer updater) { - int descriptorHash = - InstrumentDescriptor.create( - name, description, unit, InstrumentType.OBSERVABLE_GAUGE, InstrumentValueType.LONG) - .hashCode(); - - return registerCallback( - longUpdaterRegistry, - () -> - meter - .gaugeBuilder(name) - .ofLongs() - .setDescription(description) - .setUnit(unit) - .buildObserver(), - descriptorHash, - updater); - } - - /** - * Register an observable double counter. - * - * @param name - metric name - * @param description metric description - * @param unit - metric unit - * @param updater - the value updater - * @return the ObservableDoubleMeasurement for the counter - */ - public ObservableDoubleMeasurement registerDoubleCounterCallback( - final String name, - final String description, - final String unit, - final Consumer updater) { - int descriptorHash = - InstrumentDescriptor.create( - name, - description, - unit, - InstrumentType.OBSERVABLE_COUNTER, - InstrumentValueType.DOUBLE) - .hashCode(); - - return registerCallback( - doubleUpdaterRegistry, - () -> - meter - .counterBuilder(name) - .setDescription(description) - .setUnit(unit) - .ofDoubles() - .buildObserver(), - descriptorHash, - updater); - } - - /** - * Register an observable long counter. - * - * @param name - metric name - * @param description metric description - * @param unit - metric unit - * @param updater - the value updater - * @return the ObservableLongMeasurement for the counter - */ - public ObservableLongMeasurement registerLongCounterCallback( - final String name, - final String description, - final String unit, - final Consumer updater) { - int descriptorHash = - InstrumentDescriptor.create( - name, - description, - unit, - InstrumentType.OBSERVABLE_COUNTER, - InstrumentValueType.LONG) - .hashCode(); - - return registerCallback( - longUpdaterRegistry, - () -> meter.counterBuilder(name).setDescription(description).setUnit(unit).buildObserver(), - descriptorHash, - updater); - } - - /** - * Register an observable double updown counter. - * - * @param name - metric name - * @param description metric description - * @param unit - metric unit - * @param updater - the value updater - * @return the ObservableDoubleMeasurement for the counter - */ - public ObservableDoubleMeasurement registerDoubleUpDownCounterCallback( - final String name, - final String description, - final String unit, - final Consumer updater) { - int descriptorHash = - InstrumentDescriptor.create( - name, - description, - unit, - InstrumentType.OBSERVABLE_UP_DOWN_COUNTER, - InstrumentValueType.DOUBLE) - .hashCode(); - - return registerCallback( - doubleUpdaterRegistry, - () -> - meter - .upDownCounterBuilder(name) - .setDescription(description) - .setUnit(unit) - .ofDoubles() - .buildObserver(), - descriptorHash, - updater); - } - - /** - * Register an observable long updown counter. - * - * @param name - metric name - * @param description metric description - * @param unit - metric unit - * @param updater - the value updater - * @return the ObservableLongMeasurement for the counter - */ - public ObservableLongMeasurement registerLongUpDownCounterCallback( - final String name, - final String description, - final String unit, - final Consumer updater) { - int descriptorHash = - InstrumentDescriptor.create( - name, - description, - unit, - InstrumentType.OBSERVABLE_UP_DOWN_COUNTER, - InstrumentValueType.LONG) - .hashCode(); - - return registerCallback( - longUpdaterRegistry, - () -> - meter - .upDownCounterBuilder(name) - .setDescription(description) - .setUnit(unit) - .buildObserver(), - descriptorHash, - updater); - } - - private T registerCallback( - final Map>> registry, - final Supplier observerBuilder, - final int descriptorHash, - final Consumer updater) { - - // Only build the instrument if it isn't already in the registry - ObservableMeasurement obs = instrumentOnceRegistry.get(descriptorHash); - if (obs == null) { - T observer = observerBuilder.get(); - instrumentOnceRegistry.put(descriptorHash, observer); - // If an updater was not provided, the measurement is expected to be added - // to a group batchcallback using the registerBatchCallback function - if (updater != null) { - Consumer cb = proxiedObserver(descriptorHash, registry, updater); - meter.batchCallback(() -> cb.accept(observer), observer); - } - return observer; - } else if (updater != null) { - // If the instrument has already been built with the appropriate proxied observer, - // update the registry so that the callback has the appropriate updater function - registry.get(descriptorHash).set(updater); - } - - return (T) obs; - } - - /** - * Register a collection of observables in a single batch callback - * - * @param identifier - object used to identify the callback to have only one callback - * @param callback - closure that records measurements for the observables - * @param measurement - first observable, the SDK expects this is always collected - * @param additional - remaining observable, the SDK expects this is sometimes collected - */ - public void registerBatchCallback( - Object identifier, - Closure callback, - ObservableMeasurement measurement, - ObservableMeasurement... additional) { - int hash = identifier.hashCode(); - // Store the callback in the registry so the proxied callback always runs the latest - // metric collection closure - batchUpdaterRegistry.putIfAbsent(hash, new AtomicReference<>()); - batchUpdaterRegistry.get(hash).set(callback); - - // collect the set of instruments into a set so we can compare to what's previously been - // registered - Set instrumentSet = - Arrays.stream(additional).collect(Collectors.toCollection(HashSet::new)); - instrumentSet.add(measurement); - - Tuple2> existingCallback = - batchCallbackRegistry.get(hash); - // If this is our first attempt to register this callback or the list of relevant instruments - // has changed, we need register the callback. - if (existingCallback == null || !existingCallback.getV2().equals(instrumentSet)) { - // If the callback has already been created, and we're here to update the set of instruments - // make sure we close the previous callback - if (existingCallback != null) { - existingCallback.getV1().close(); - } - batchCallbackRegistry.put( - hash, - new Tuple2<>( - meter.batchCallback( - () -> batchUpdaterRegistry.get(hash).get().call(), measurement, additional), - instrumentSet)); - } - } - - private Consumer proxiedObserver( - final int descriptorHash, - final Map>> registry, - final Consumer updater) { - registry.putIfAbsent(descriptorHash, new AtomicReference<>()); - registry.get(descriptorHash).set(updater); - return result -> registry.get(descriptorHash).get().accept(result); - } -} diff --git a/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/GroovyRunner.java b/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/GroovyRunner.java deleted file mode 100644 index 4aaabca4d3..0000000000 --- a/jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/GroovyRunner.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.contrib.jmxmetrics; - -import static java.nio.charset.StandardCharsets.UTF_8; - -import groovy.lang.Binding; -import groovy.lang.GroovyShell; -import groovy.lang.Script; -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URI; -import java.net.URL; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.codehaus.groovy.control.CompilationFailedException; - -public class GroovyRunner { - private static final Logger logger = Logger.getLogger(GroovyRunner.class.getName()); - - private final List