Skip to content

Commit

Permalink
Merge branch 'master' into feat/bean-listener
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/org/datadog/jmxfetch/Instance.java
#	src/main/java/org/datadog/jmxfetch/JmxAttribute.java
#	src/test/java/org/datadog/jmxfetch/TestCommon.java
  • Loading branch information
scottopell committed Dec 27, 2023
2 parents dcf963c + 5b7b838 commit 781db37
Show file tree
Hide file tree
Showing 73 changed files with 3,303 additions and 548 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ version: 2
lint_steps: &lint_steps
steps:
- checkout
- run: mvn verify -B -Dhttps.protocols=TLSv1.2 -DskipTests
- run: ./mvnw verify -B -Dhttps.protocols=TLSv1.2 -DskipTests
build_steps: &build_steps
steps:
- checkout
- setup_remote_docker
- run: mvn test -B -Dhttps.protocols=TLSv1.2 -Dcheckstyle.skip=true -Dtests.log_level=info -Djdk.attach.allowAttachSelf=true
- run: ./mvnw test -B -Dhttps.protocols=TLSv1.2 -Dcheckstyle.skip=true -Dtests.log_level=info -Djdk.attach.allowAttachSelf=true
- run:
when: on_fail
command: for log in target/surefire-reports/*.txt; do echo "$log ========================" ; cat $log ; done

jobs:
lint_openjdk8:
docker:
- image: circleci/openjdk:8-jdk
- image: cimg/openjdk:8.0
<<: *lint_steps
test_openjdk8:
docker:
- image: circleci/openjdk:8-jdk
- image: cimg/openjdk:8.0
<<: *build_steps
test_openjdk11:
docker:
Expand Down
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See https://help.github.com/articles/about-codeowners/ for syntax
# Rules are matched bottom-to-top, so one team can own subdirectories
# and another team can own the rest of the directory.

* @Datadog/agent-metrics-logs

# Documentation
*.md @DataDog/documentation
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
java-package: jdk

- name: Build with Maven
run: mvn clean compile assembly:single
run: ./mvnw clean compile assembly:single

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ target/*
.idea
.vscode
*.iml

*.ucls

*.png
Expand Down
9 changes: 5 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ run_unit_tests:
tags:
- "runner:docker"

image: maven:3.9.1-eclipse-temurin-8
image: eclipse-temurin:8u382-b05-jdk

script:
- mvn -Dhttps.protocols=TLSv1.2 -Dcheckstyle.skip=true -Dtests.log_level=info -Djdk.attach.allowAttachSelf=true -B test
- ./mvnw -Dhttps.protocols=TLSv1.2 -Dcheckstyle.skip=true -Dtests.log_level=info -Djdk.attach.allowAttachSelf=true -B test

artifacts:
expire_in: 1 mos
when: always
paths:
- ./target/surefire-reports/*.txt

Expand All @@ -45,7 +46,7 @@ deploy_to_sonatype:
tags:
- "runner:docker"

image: maven:3.9.1-eclipse-temurin-8
image: eclipse-temurin:8u382-b05-jdk

script:
# Ensure we don't print commands being run to the logs during credential
Expand All @@ -72,7 +73,7 @@ deploy_to_sonatype:
- set -x

- echo "Building release..."
- mvn -Djdk.attach.allowAttachSelf=true -DperformRelease=true -Daether.checksums.algorithms=SHA-512,SHA-256,SHA-1,MD5 --settings ./settings.xml clean deploy
- ./mvnw -Djdk.attach.allowAttachSelf=true -DperformRelease=true -Daether.checksums.algorithms=SHA-512,SHA-256,SHA-1,MD5 --settings ./settings.xml clean deploy

artifacts:
expire_in: 12 mos
Expand Down
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
8 changes: 8 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
#
# Java version currently tracking what is present in -jmx agent builds
# Agent is currently installing 'openjdk-11-jre-headless' from debian
# See https://github.com/DataDog/datadog-agent/blob/3b6f07cb7d097837a7b9247c6119ead3309116ab/Dockerfiles/agent/Dockerfile#L136
# and https://packages.debian.org/sid/openjdk-11-jre-headless
java=11.0.21-amzn
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
Changelog
=========
# Next / TBD

# 0.49.0 / 2023-11-10
* [FEATURE] Adds more per-instance telemetry data around bean matching
* [BUGFIX] Removes un-necessary statsd reinit

# 0.48.0 / 2023-09-26

* [FEATURE] Adds a configurable jmxfetch telemetry check to improve jmxfetch observability [#467][]
* [FEATURE] Added an option to enable removal of extra quotation marks during tag extraction from Java management beans' parameters/attributes [#469][]
* [FEATURE] Updated status bean to report JMX Telemetry to Agent status [#477][]

# 0.47.10 / 2023-08-10

* [IMPROVEMENT] Improvements in how JMXFetch handles communicating back to the Agent. This includes allowing the TLS of the HTTP client to be configured, extra logging around the SSL Context, and 'TLS' as min protocol version used in the `dummyTrustManager` (configurable using the flag `jmxfetch.min_tls_version`, e.g., `-Djmxfetch.min_tls_version=TLS`) [#436][]
* [BUGFIX] Fixed issue race condition where an exception is thrown if the Agent hasn't finished initializing before JMXFetch starts to shut down [#449][]
* [OTHER] Update management agent logic and comments for Java 7 vs 8 vs 9 [#457][]

# 0.47.9 / 2023-05-25

* [BUGFIX] Fixes thread leak in situations with persistent connection failures [#432][]
Expand Down Expand Up @@ -736,7 +754,13 @@ Changelog
[#424]: https://github.com/DataDog/jmxfetch/issues/424
[#431]: https://github.com/DataDog/jmxfetch/issues/431
[#432]: https://github.com/DataDog/jmxfetch/issues/432
[#436]: https://github.com/DataDog/jmxfetch/issues/436
[#437]: https://github.com/DataDog/jmxfetch/issues/437
[#467]: https://github.com/DataDog/jmxfetch/issues/467
[#457]: https://github.com/DataDog/jmxfetch/issues/457
[#449]: https://github.com/DataDog/jmxfetch/issues/449
[#469]: https://github.com/DataDog/jmxfetch/issues/469
[#477]: https://github.com/DataDog/jmxfetch/issues/477
[@alz]: https://github.com/alz
[@aoking]: https://github.com/aoking
[@arrawatia]: https://github.com/arrawatia
Expand Down
64 changes: 55 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.com/DataDog/jmxfetch.png?branch=master)](https://travis-ci.com/DataDog/jmxfetch)
[![Build Status](https://circleci.com/gh/DataDog/jmxfetch.svg?style=svg)](https://app.circleci.com/pipelines/github/DataDog/jmxfetch)

# [Change log](https://github.com/DataDog/jmxfetch/blob/master/CHANGELOG.md)

Expand All @@ -22,21 +22,35 @@ pull request.

## Building from source

JMXFetch uses [Maven](http://maven.apache.org) for its build system.
JMXFetch uses [Maven](http://maven.apache.org) for its build system. The repo contains a [Maven Wrapper](https://maven.apache.org/wrapper/), so you don't need to download and install Maven.

In order to generate the jar artifact, simply run the ```mvn clean compile assembly:single``` command in the cloned directory.
In order to generate the JAR artifact, run the `./mvnw clean compile assembly:single` command in the cloned directory.

The distribution will be created under ```target/```.

Once the jar is created, you can update the one in the Datadog Agent repo.
To use this JAR in the Agent, see [these docs](https://github.com/DataDog/datadog-agent/blob/main/docs/dev/checks/jmxfetch.md).

### Note

If you want build all the JAR files for JMXFetch, you need to use an older JDK version like JDK 8.
There is a known issue where the build can't find `javadoc command` on modern JDKs.
The quickest way to build these JAR files is to use Docker:

```
docker run -it --rm \
--name my-maven-project \
-v "$(pwd)":/usr/src/app \
-w /usr/src/app \
eclipse-temurin:8-jdk ./mvnw -DskipTests clean package
```

## Coding standards

JMXFetch uses [Checkstyle](http://checkstyle.sourceforge.net/) with [Google Java Style](http://google.github.io/styleguide/javaguide.html) to enforce coding standards.

To perform a `Checkstyle` analysis and outputs violations, run:
```
mvn checkstyle::check
./mvnw checkstyle::check
```

`Checkstyle` analysis is automatically executed prior to compiling the code, testing.
Expand All @@ -46,11 +60,24 @@ mvn checkstyle::check
JMXFetch uses [Lombok](https://projectlombok.org/) to modify classes and generate additional code at runtime.
You may need to [enable annotation processors](https://projectlombok.org/setup/overview) to compile in your IDE.

## Useful Developer Settings

### JDK version management
[`sdkman`](https://sdkman.io/install) is recommended to manage multiple versions of Java.
If you are an sdkman user, there is a config file present in this project with
the recommended JDK version for development, use `sdk env` to activate it.


### Enabling file line numbers in log messages
If you set the system property `-Djmxfetch.filelinelogging=true`, this will enable all log output to
include the line number which emitted a given log.


## Testing

To run unit test, issue the following command:
```
mvn test
./mvnw test
```

Some tests utilize [TestContainers](https://www.testcontainers.org/) which requires a docker client.
Expand All @@ -60,7 +87,7 @@ If you're on macOS or Windows, docker desktop is architected to run a linux VM w
This makes the networking a bit different and you should use the following command to run the tests.

```
docker run -it --rm -e TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal -v $PWD:$PWD -w $PWD -v /var/run/docker.sock:/var/run/docker.sock maven:3.8-eclipse-temurin-8 mvn test
docker run -it --rm -e TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal -v $PWD:$PWD -w $PWD -v /var/run/docker.sock:/var/run/docker.sock eclipse-temurin:8-jdk ./mvnw test
```

This version runs the maven jmxfetch tests within a container as well, which works as long as the `TEST_CONTAINERS_HOST_OVERRIDE` env var is set.
Expand Down Expand Up @@ -121,7 +148,7 @@ export SONATYPE_PASS="<Password for Nexus admin from previous step>"
```
- Run the deploy with the appropriate `skipStaging` flag:
```sh
mvn -DskipTests -DskipStaging=true -DperformRelease=true --settings settings.xml clean deploy
./mvnw -DskipTests -DskipStaging=true -DperformRelease=true --settings settings.xml clean deploy
```

If you do this correctly, the artifact will be available in the Nexus container at
Expand All @@ -136,5 +163,24 @@ otherwise the subsequent publishes will fail.

```
Get help on usage:
java -jar jmxfetch-0.48.0-SNAPSHOT-jar-with-dependencies.jar --help
java -jar jmxfetch-0.49.1-SNAPSHOT-jar-with-dependencies.jar --help
```

## Updating Maven Wrapper

To upgrade the Maven Wrapper, you need to run:

```
./mvn wrapper:wrapper -Dmaven=<Maven Version X.Y.Z>
```

The easiest way to regenerate the wrapper files (`mvnw`, `mvnw.cmd`, `.mvn/wrapper/maven-wrapper.jar` and `.mvn/wrapper/maven-wrapper.properties`) is to use Docker:

```
docker run -it --rm \
--name my-maven-project \
-v "$(pwd)":/usr/src/app \
-w /usr/src/app maven:3 mvn wrapper:wrapper -Dmaven=<Maven Version X.Y.Z>
```

Leave out the `-Dmaven=<Maven Version X.Y.Z>` to get the latest version of Maven.
Loading

0 comments on commit 781db37

Please sign in to comment.