Welcome to OpenTelemetry Java repository!
Before you start - see OpenTelemetry general contributing requirements and recommendations.
If you want to add new features or change behavior, please make sure your changes follow the OpenTelemetry Specification. Otherwise file an issue or submit a PR to the specification repo first.
Make sure to review the projects license and sign the CNCF CLA. A signed CLA will be enforced by an automatic check once you submit a PR, but you can also sign it after opening your PR.
Java 11 or higher is required to build the projects in this repository. The built artifacts can be used on Java 8 or higher.
Continuous integration builds the project, runs the tests, and runs multiple types of static analysis.
Note: Currently, to run the full suite of tests, you'll need to be running a docker daemon. The tests that require docker are disabled if docker is not present. If you wish to run them, you must run a local docker daemon.
Clone the repository
git clone https://github.com/open-telemetry/opentelemetry-java.git
Run the following commands to build, run tests and most static analysis, and check formatting:
./gradlew build
If you are a Windows user, use the alternate command mentioned below to run tests and check formatting:
gradlew.bat
Before submitting a PR, you should make sure the style checks and unit tests pass. You can run these with the check task.
$ ./gradlew check
Note: this gradle task will potentially generate changes to files in the docs/apidiffs/current_vs_latest directory. Please make sure to include any changes to these files in your pull request.
After you submit a PR, it will be reviewed by the project maintainers and approvers. Not all maintainers need to review a particular PR, but merging to the base branch is authorized to restricted members (administrators).
We follow the Google Java Style Guide. Our build will fail if source code is not formatted according to that style. To fix any style failures the above checks show, automatically apply the formatting with:
$ ./gradlew spotlessApply
To verify code style manually run the following command, which uses google-java-format library:
./gradlew spotlessCheck
null must be annotated with @Nullable.final for public classes everywhere it is possible, this ensures that these classes cannot be extended when the API does not intend to offer that functionality.toString() overrides on classes is encouraged, but we only use toString() to provide debugging assistance. The implementations of all toString() methods should be considered to be unstable unless explicitly documented otherwise.If you notice any practice being applied in the project consistently that isn't listed here, please consider a pull request to add it.
To completely delegate code style formatting to the machine, you can add git pre-commit hook. We provide an example script in buildscripts/pre-commit file. Just copy or symlink it into .git/hooks folder.
As additional convenience for IntelliJ Idea users, we provide .editorconfig file. Idea will automatically use it to adjust its code formatting settings. It does not support all required rules, so you still have to run spotlessApply from time to time.
@since tag specifying the minor version when it was released (or the next minor version).@author tags in our javadoc.The OTLP proto dependency version is defined here. To bump the version,
shasum -a 256 ~/path/to/downloaded.zip to compute its checksumprotoVersion and protoChecksum in the build file with the new version and checksum