Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add configuration files for JMX support. #817

Merged
merged 4 commits into from
Oct 10, 2024
Merged

Conversation

jefchien
Copy link
Member

@jefchien jefchien commented Jun 17, 2024

Description of changes:

1. rules/*.yaml

The JMX Metric Insight and the JMX Metric Gatherer have different pre-defined target systems (activemq, tomcat, etc.) and even different metrics within each shared target system (open-telemetry/opentelemetry-java-instrumentation#9765). This is an effort to unify the metrics being generated by deferring to the Gatherer's definition files.

By placing it in the same path as the JMX Metric Insight resources, the rule files can be overwritten and referred to directly.

> gradlew build
> jar tf otelagent/build/libs/aws-opentelemetry-agent-1.33.0-SNAPSHOT.jar | grep jmx
inst/META-INF/io/opentelemetry/instrumentation/io.opentelemetry.jmx-metrics.properties
inst/io/opentelemetry/javaagent/shaded/instrumentation/javaagent/jmx/
inst/io/opentelemetry/javaagent/shaded/instrumentation/javaagent/jmx/JmxMetricInsightInstaller.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/AttributeInfo.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/BeanAttributeExtractor.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/BeanFinder$1.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/BeanFinder.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/BeanGroup.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/DetectionStatus.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/JmxMetricInsight.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricAttribute.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricAttributeExtractor.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricConfiguration.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricDef.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricExtractor.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricInfo$Type.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricInfo.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricRegistrar$1.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/engine/MetricRegistrar.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/yaml/
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/yaml/JmxConfig.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/yaml/JmxRule.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/yaml/Metric.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/yaml/MetricStructure.classdata
inst/io/opentelemetry/javaagent/shaded/instrumentation/jmx/yaml/RuleParser.classdata
inst/jmx/
inst/jmx/rules/
inst/jmx/rules/activemq.yaml
inst/jmx/rules/hadoop.yaml
inst/jmx/rules/jetty.yaml
inst/jmx/rules/kafka-broker.yaml
inst/jmx/rules/tomcat.yaml
inst/jmx/rules/wildfly.yaml
inst/jmx/
inst/jmx/rules/
inst/jmx/rules/jvm.yaml
inst/jmx/rules/kafka-consumer.yaml
inst/jmx/rules/kafka-producer.yaml
inst/jmx/rules/kafka.yaml
inst/jmx/rules/tomcat.yaml
inst/jmx/view.yaml

This makes it easier for users to specify the target systems via environment variables.

OTEL_JMX_TARGET_SYSTEM: jvm, tomcat

This results in

petclinic [otel.javaagent 2024-06-14 20:27:36:575 +0000] [main] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.yaml.RuleParser - jvm: found 5 metric rules
petclinic [otel.javaagent 2024-06-14 20:27:36:607 +0000] [main] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.yaml.RuleParser - tomcat: found 6 metric rules
petclinic [otel.javaagent 2024-06-14 20:27:37:731 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Gauge for jvm.classes.loaded
petclinic [otel.javaagent 2024-06-14 20:27:37:738 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Counter for jvm.gc.collections.count
petclinic [otel.javaagent 2024-06-14 20:27:37:739 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Counter for jvm.gc.collections.elapsed
petclinic [otel.javaagent 2024-06-14 20:27:37:740 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Gauge for jvm.memory.heap
petclinic [otel.javaagent 2024-06-14 20:27:37:740 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Gauge for jvm.memory.nonheap
petclinic [otel.javaagent 2024-06-14 20:27:37:745 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Gauge for jvm.memory.pool.usage
petclinic [otel.javaagent 2024-06-14 20:27:37:745 +0000] [pool-8-thread-1] INFO io.opentelemetry.javaagent.shaded.instrumentation.jmx.engine.MetricRegistrar - Created Gauge for jvm.threads.count

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jefchien jefchien requested a review from a team as a code owner June 17, 2024 23:03
Copy link

This PR is stale because it has been open 60 days with no activity.

@github-actions github-actions bot added the stale label Aug 18, 2024
@github-actions github-actions bot removed the stale label Sep 1, 2024
@jefchien jefchien requested a review from a team as a code owner September 16, 2024 22:02
bjrara added a commit that referenced this pull request Sep 19, 2024
## Feature request
Add runtime metrics collection into Application Signals.

## Description of changes:
1. Add JMX metrics template.
1. The JMX template is taken from
#817.
The template is updated with bug fixes and added with additional CPU
metrics. The author of the original PR is notified with the changes.
2. Introduce `CloudWatchTemporalitySelector` to set temporality of
Application Signals exporter to `alwaysDelta`.
3. Add `ScopeBasedPeriodicMetricReader` to copy metrics from
`io.opentelemetry.jmx` instrumentation scope to Application Signals
exporter.
4. Set `aws.local.service` into resource attributes. 

## Result example
```
{
  resource=Resource{
    schemaUrl=https: //opentelemetry.io/schemas/1.21.0,
    attributes={
      aws.local.service="ec2-runtime-demo",
      cloud.account.id="633750930120",
      cloud.availability_zone="us-east-1a",
      cloud.platform="aws_ec2",
      cloud.provider="aws",
      cloud.region="us-east-1",
      host.arch="amd64",
      host.id="i-03ff80a878a803e0e",
      host.image.id="ami-0ae8f15ae66fe8cda",
      host.name="ip-172-31-25-215.ec2.internal",
      host.type="t2.medium",
      os.description="Linux 6.1.102-108.177.amzn2023.x86_64",
      os.type="linux",
      process.command_args=[
        /usr/lib/jvm/java-21-amazon-corretto.x86_64/bin/java,
        -Dotel.instrumentation.micrometer.enabled=false,
        -jar,
        spring-petclinic-all-in-one.jar
      ],
      process.executable.path="/usr/lib/jvm/java-21-amazon-corretto.x86_64/bin/java",
      process.pid=445291,
      process.runtime.description="Amazon.com Inc. OpenJDK 64-Bit Server VM 21.0.4+7-LTS",
      process.runtime.name="OpenJDK Runtime Environment",
      process.runtime.version="21.0.4+7-LTS",
      service.name="ec2-runtime-demo",
      service.version="3.1.0-SNAPSHOT",
      telemetry.auto.version="1.33.0-aws-SNAPSHOT",
      telemetry.sdk.language="java",
      telemetry.sdk.name="opentelemetry",
      telemetry.sdk.version="1.34.1"
    }
  },
  instrumentationScopeInfo=InstrumentationScopeInfo{
    name=io.opentelemetry.jmx,
    version=null,
    schemaUrl=null,
    attributes={
      
    }
  },
  name=jvm.gc.collections.elapsed,
  description=Theapproximateaccumulatedcollectionelapsedtimeinmilliseconds,
  unit=ms,
  type=LONG_SUM,
  data=ImmutableSumData{
    points=[
      ImmutableLongPointData{
        startEpochNanos=1724126549515601332,
        epochNanos=1724126609522082935,
        attributes={
          name="G1 Old Generation"
        },
        value=0,
        exemplars=[
          
        ]
      },
      ImmutableLongPointData{
        startEpochNanos=1724126549515601332,
        epochNanos=1724126609522082935,
        attributes={
          name="G1 Concurrent GC"
        },
        value=49,
        exemplars=[
          
        ]
      },
      ImmutableLongPointData{
        startEpochNanos=1724126549515601332,
        epochNanos=1724126609522082935,
        attributes={
          name="G1 Young Generation"
        },
        value=332,
        exemplars=[
          
        ]
      }
    ],
    monotonic=true,
    aggregationTemporality=CUMULATIVE
  }
}
```
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
@jefchien jefchien changed the base branch from main to runtime-feature September 27, 2024 16:09
@jefchien jefchien changed the base branch from runtime-feature to main October 4, 2024 20:34
musa-asad pushed a commit to musa-asad/aws-otel-java-instrumentation that referenced this pull request Oct 8, 2024
## Feature request
Add runtime metrics collection into Application Signals.

## Description of changes:
1. Add JMX metrics template.
1. The JMX template is taken from
aws-observability#817.
The template is updated with bug fixes and added with additional CPU
metrics. The author of the original PR is notified with the changes.
2. Introduce `CloudWatchTemporalitySelector` to set temporality of
Application Signals exporter to `alwaysDelta`.
3. Add `ScopeBasedPeriodicMetricReader` to copy metrics from
`io.opentelemetry.jmx` instrumentation scope to Application Signals
exporter.
4. Set `aws.local.service` into resource attributes.

## Result example
```
{
  resource=Resource{
    schemaUrl=https: //opentelemetry.io/schemas/1.21.0,
    attributes={
      aws.local.service="ec2-runtime-demo",
      cloud.account.id="633750930120",
      cloud.availability_zone="us-east-1a",
      cloud.platform="aws_ec2",
      cloud.provider="aws",
      cloud.region="us-east-1",
      host.arch="amd64",
      host.id="i-03ff80a878a803e0e",
      host.image.id="ami-0ae8f15ae66fe8cda",
      host.name="ip-172-31-25-215.ec2.internal",
      host.type="t2.medium",
      os.description="Linux 6.1.102-108.177.amzn2023.x86_64",
      os.type="linux",
      process.command_args=[
        /usr/lib/jvm/java-21-amazon-corretto.x86_64/bin/java,
        -Dotel.instrumentation.micrometer.enabled=false,
        -jar,
        spring-petclinic-all-in-one.jar
      ],
      process.executable.path="/usr/lib/jvm/java-21-amazon-corretto.x86_64/bin/java",
      process.pid=445291,
      process.runtime.description="Amazon.com Inc. OpenJDK 64-Bit Server VM 21.0.4+7-LTS",
      process.runtime.name="OpenJDK Runtime Environment",
      process.runtime.version="21.0.4+7-LTS",
      service.name="ec2-runtime-demo",
      service.version="3.1.0-SNAPSHOT",
      telemetry.auto.version="1.33.0-aws-SNAPSHOT",
      telemetry.sdk.language="java",
      telemetry.sdk.name="opentelemetry",
      telemetry.sdk.version="1.34.1"
    }
  },
  instrumentationScopeInfo=InstrumentationScopeInfo{
    name=io.opentelemetry.jmx,
    version=null,
    schemaUrl=null,
    attributes={

    }
  },
  name=jvm.gc.collections.elapsed,
  description=Theapproximateaccumulatedcollectionelapsedtimeinmilliseconds,
  unit=ms,
  type=LONG_SUM,
  data=ImmutableSumData{
    points=[
      ImmutableLongPointData{
        startEpochNanos=1724126549515601332,
        epochNanos=1724126609522082935,
        attributes={
          name="G1 Old Generation"
        },
        value=0,
        exemplars=[

        ]
      },
      ImmutableLongPointData{
        startEpochNanos=1724126549515601332,
        epochNanos=1724126609522082935,
        attributes={
          name="G1 Concurrent GC"
        },
        value=49,
        exemplars=[

        ]
      },
      ImmutableLongPointData{
        startEpochNanos=1724126549515601332,
        epochNanos=1724126609522082935,
        attributes={
          name="G1 Young Generation"
        },
        value=332,
        exemplars=[

        ]
      }
    ],
    monotonic=true,
    aggregationTemporality=CUMULATIVE
  }
}
```
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
@bjrara
Copy link
Member

bjrara commented Oct 10, 2024

Is #898 relevant to this one?

@bjrara bjrara merged commit 51098f9 into aws-observability:main Oct 10, 2024
4 checks passed
@jefchien jefchien mentioned this pull request Oct 23, 2024
bjrara pushed a commit that referenced this pull request Nov 1, 2024
*Description of changes:* Adds contract tests to verify the expected
behavior of the following changes:
-
#817
-
#898
-
#901

Starts up sample apps with the instrumented SDK and verifies that
metrics are received for each of the supported JMX target systems.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants