Skip to content

Commit

Permalink
Copy in spotless-conventions from instrumentation repo (#3554)
Browse files Browse the repository at this point in the history
* Copy in spotless-conventions from instrumentation repo.

* Reformat

* A few more dotfiles
  • Loading branch information
Anuraag Agrawal authored Aug 27, 2021
1 parent 12a8936 commit 6ef3091
Show file tree
Hide file tree
Showing 44 changed files with 471 additions and 429 deletions.
198 changes: 99 additions & 99 deletions CHANGELOG.md

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ you must run a local docker daemon.
check formatting:

`./gradlew build`

4. If you are a Windows user, use the alternate command mentioned below to run tests and
check formatting:

`gradlew.bat`

## Checks

Before submitting a PR, you should make sure the style checks and unit tests pass. You can run these
Expand All @@ -60,15 +60,15 @@ particular PR, but merging to the base branch is authorized to restricted member

## Style guideline

We follow the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html).
We follow the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html).
Our build will fail if source code is not formatted according to that style. To fix any
style failures the above [checks](#checks) show, automatically apply the formatting with:

```bash
$ ./gradlew spotlessApply
```

To verify code style manually run the following command,
To verify code style manually run the following command,
which uses [google-java-format](https://github.com/google/google-java-format) library:

`./gradlew spotlessCheck`
Expand Down Expand Up @@ -99,12 +99,12 @@ of all `toString()` methods should be considered to be unstable unless explicitl
If you notice any practice being applied in the project consistently that isn't listed here, please consider a pull request to add it.

### Pre-commit hook
To completely delegate code style formatting to the machine,
To completely delegate code style formatting to the machine,
you can add [git pre-commit hook](https://git-scm.com/docs/githooks).
We provide an example script in `buildscripts/pre-commit` file.
Just copy or symlink it into `.git/hooks` folder.

### Editorconfig
### Editorconfig
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.
Expand Down Expand Up @@ -135,8 +135,8 @@ It does not support all required rules, so you still have to run `spotlessApply`
possible, for any new value classes. Remember to add package-private
constructors to all AutoValue classes to prevent classes in other packages
from extending them.


### Unit Tests

* Unit tests target Java 8, so language features such as lambda and streams can be used in tests.
Expand Down
2 changes: 1 addition & 1 deletion QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Our quickstart guide has been migrated to the [OpenTelemetry documentation websi

The source for the documentation website can be found in our [website_docs](website_docs) folder in
this repository. If you have updates to the documentation, please open a pull request that updates the documents
in that location. Thanks!
in that location. Thanks!
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
If you are looking for an all-in-one, easy-to-install auto-instrumentation javaagent, please visit our sibling project,
[opentelemetry-java-instrumentation](https://github.com/open-telemetry/opentelemetry-java-instrumentation).

If you are looking for examples on how to use the OpenTelemetry APIs to write your own manual instrumentation, or
how to set up the OpenTelemetry Java SDK, please visit our [quickstart guide](QUICKSTART.md). We also have
If you are looking for examples on how to use the OpenTelemetry APIs to write your own manual instrumentation, or
how to set up the OpenTelemetry Java SDK, please visit our [quickstart guide](QUICKSTART.md). We also have
fully-functioning example projects in our [examples sub-module](examples), which can be a good way to get
your feet wet in a local environment.

If you are looking to get involved with the project, please read our [contributing guide](CONTRIBUTING.md). We welcome
contributions!
contributions!

If you are looking for a general overview of the OpenTelemetry project, please visit the [official website](https://opentelemetry.io).

Expand All @@ -23,9 +23,9 @@ If you are looking for a general overview of the OpenTelemetry project, please v
We hold regular meetings. See details at [community page](https://github.com/open-telemetry/community#java-sdk).

We use [GitHub Discussions](https://github.com/open-telemetry/opentelemetry-java/discussions)
for support or general questions. Feel free to drop us a line.
for support or general questions. Feel free to drop us a line.

We are also present in the `#otel-java` channel in the [CNCF slack](https://slack.cncf.io/).
We are also present in the `#otel-java` channel in the [CNCF slack](https://slack.cncf.io/).
Please join us for more informal discussions.

## Overview
Expand Down Expand Up @@ -59,7 +59,7 @@ Both API and SDK extensions consist of various additional components which are e
to keep them from growing too large.

We still aim to provide the same level of quality and guarantee for them as for the core components.
Please don't hesitate to use them if you find them useful.
Please don't hesitate to use them if you find them useful.

## Project setup and contribute

Expand Down Expand Up @@ -146,7 +146,7 @@ We strongly recommend using our published BOM to keep all dependency versions in

```groovy
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
Expand All @@ -161,7 +161,7 @@ of the APIs.

## Releases

See the [VERSIONING.md](VERSIONING.md) document for our policies for releases and compatibility
See the [VERSIONING.md](VERSIONING.md) document for our policies for releases and compatibility
guarantees.

Check out information about the [latest release](https://github.com/open-telemetry/opentelemetry-java/releases).
Expand Down
8 changes: 4 additions & 4 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Open the release build workflow in your browser [here](https://github.com/open-t
You will see a button that says "Run workflow". Press the button, enter the version number you want
to release in the input field that pops up, and then press "Run workflow".

This triggers the release process, which builds the artifacts. It will not automatically update the
This triggers the release process, which builds the artifacts. It will not automatically update the
documentation, because the Github Actions cannot push changes to the main branch.

## Announcement

Once the GitHub workflow completes, go to Github [release
page](https://github.com/open-telemetry/opentelemetry-java/releases), press
`Draft a new release` to write release notes about the new release. If there is already a draft
Expand Down Expand Up @@ -48,13 +48,13 @@ Next, update the
Create a PR to mark the new release in README.md and CHANGELOG.md on the main branch.

Finally, update the files `website_docs` directory to point at the newly released version. Once that has
been merged to the main branch, use the "Update OpenTelemetry Website" github action to create a PR
been merged to the main branch, use the "Update OpenTelemetry Website" github action to create a PR
in the website repository with the changes.

## Patch Release

All patch releases should include only bug-fixes, and must avoid
adding/modifying the public APIs.
adding/modifying the public APIs.

Open the patch release build workflow in your browser [here](https://github.com/open-telemetry/opentelemetry-java/actions/workflows/patch-release-build.yml).

Expand Down
10 changes: 5 additions & 5 deletions VERSIONING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ that all artifacts have a version of the format `MAJOR.MINOR.PATCH` or `MAJOR.MI
For any artifact with a stable release, that is its version does not end in `-alpha`, no backwards-incompatible
changes will be made unless incrementing the `MAJOR` version number. In practice, this means that
backwards-incompatible changes will be avoided as long as possible. Most releases are made by
incrementing the `MINOR` version. Patch releases with urgent cherry-picked bugfixes will be made by
incrementing the `MINOR` version. Patch releases with urgent cherry-picked bugfixes will be made by
incrementing the `PATCH` version.

A backwards-incompatible change affects the public API of a module. The public API is any public
class or method that is not in a package which includes the word `internal`. Examples of incompatible
changes are:

- API changes that could require code using the artifact to be changed, e.g., removing a method,
- API changes that could require code using the artifact to be changed, e.g., removing a method,
reordering parameters, adding a method to an interface or abstract class without adding a default
implementation.

- ABI changes that could require code using the artifact to be recompiled, but not changed, e.g.,
changing the return type of a method from `void` to non-`void`, changing a `class` to an `interface`.
The [JLS](https://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html) has more information on
Expand All @@ -41,7 +41,7 @@ new artifact which requires adding the new artifact to dependency declarations.

As a user, if you always depend on the latest version of the BOM for a given `MAJOR` version, and
you do not use classes in the `internal` package (which you MUST NOT do), you can be assured that
your app will always function and have access to the latest features of OpenTelemetry without needing
your app will always function and have access to the latest features of OpenTelemetry without needing
any changes to code.

## API vs SDK
Expand All @@ -65,7 +65,7 @@ for at least three more years. This includes
When incrementing the `MAJOR` version of the SDK, previously released `MAJOR` versions will be supported
for at least one year.

## Stable vs alpha
## Stable vs alpha

Not all of our artifacts are published as stable artifacts - any non-stable artifact has the suffix
`-alpha` on its version. NONE of the guarantees described above apply to alpha artifacts. They may
Expand Down
2 changes: 1 addition & 1 deletion api/all/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* The code in this module is the implementation of stable OpenTelemetry signals.
* Semantic Conventions for OpenTelemetry are in the `opentelemetry-semconv` module.
* The default implementation of the interfaces in this module is in the OpenTelemetry SDK module.
* The default implementation of the interfaces in this module is in the OpenTelemetry SDK module.
* The interfaces in this directory can be implemented to create alternative
implementations of the OpenTelemetry library.

Expand Down
4 changes: 2 additions & 2 deletions api/metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
[![Javadocs][javadoc-image]][javadoc-url]

* The code in this module is the implementation of the [experimental OpenTelemetry metrics signal][metrics-spec].
* The default implementation of the interfaces in this module is in the OpenTelemetry metrics SDK module.
* The default implementation of the interfaces in this module is in the OpenTelemetry metrics SDK module.
* The interfaces in this directory can be implemented to create alternative
implementations of the OpenTelemetry library.

[javadoc-image]: https://www.javadoc.io/badge/io.opentelemetry/opentelemetry-api-metrics.svg
[javadoc-url]: https://www.javadoc.io/doc/io.opentelemetry/opentelemetry-api-metrics
[metrics-spec]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md
[metrics-spec]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md
13 changes: 2 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import nebula.plugin.release.git.opinion.Strategies
import java.time.Duration

plugins {
id("com.diffplug.spotless")
id("com.github.ben-manes.versions")
id("io.github.gradle-nexus.publish-plugin")
id("nebula.release")

id("otel.spotless-conventions")
}

if (!JavaVersion.current().isJava11Compatible()) {
Expand Down Expand Up @@ -58,16 +59,6 @@ nexusPublishing {
}
}

allprojects {
apply(plugin = "com.diffplug.spotless")

spotless {
kotlinGradle {
ktlint("0.42.1").userData(mapOf("indent_size" to "2", "continuation_indent_size" to "2"))
}
}
}

subprojects {
group = "io.opentelemetry"
}
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repositories {
}

dependencies {
implementation("com.diffplug.spotless:spotless-plugin-gradle:5.13.0")
implementation("com.diffplug.spotless:spotless-plugin-gradle:5.14.3")
// Needed for japicmp but not automatically brought in for some reason.
implementation("com.google.guava:guava:30.1-jre")
implementation("com.squareup:javapoet:1.13.0")
Expand Down
11 changes: 1 addition & 10 deletions buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ plugins {
eclipse
idea

id("com.diffplug.spotless")

id("otel.errorprone-conventions")
id("otel.jacoco-conventions")
id("otel.spotless-conventions")
}

val otelJava = extensions.create<OtelJavaExtension>("otelJava")
Expand Down Expand Up @@ -166,14 +165,6 @@ configurations.configureEach {
}
}

spotless {
java {
googleJavaFormat("1.9")
licenseHeaderFile(rootProject.file("buildscripts/spotless.license.java"), "(package|import|class|// Includes work from:)")
targetExclude("build/**")
}
}

val dependencyManagement by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = false
Expand Down
47 changes: 47 additions & 0 deletions buildSrc/src/main/kotlin/otel.spotless-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
plugins {
id("com.diffplug.spotless")
}

spotless {
java {
googleJavaFormat()
licenseHeaderFile(rootProject.file("buildscripts/spotless.license.java"), "(package|import|public|// Includes work from:)")
target("src/**/*.java")
}
plugins.withId("groovy") {
groovy {
licenseHeaderFile(rootProject.file("buildscripts/spotless.license.java"), "(package|import|class)")
}
}
plugins.withId("scala") {
scala {
scalafmt()
licenseHeaderFile(rootProject.file("buildscripts/spotless.license.java"), "(package|import|public)")
target("src/**/*.scala")
}
}
plugins.withId("org.jetbrains.kotlin.jvm") {
kotlin {
ktlint().userData(mapOf("indent_size" to "2", "continuation_indent_size" to "2", "disabled_rules" to "no-wildcard-imports"))
licenseHeaderFile(rootProject.file("buildscripts/spotless.license.java"), "(package|import|class|// Includes work from:)")
}
}
kotlinGradle {
ktlint().userData(mapOf("indent_size" to "2", "continuation_indent_size" to "2", "disabled_rules" to "no-wildcard-imports"))
}
format("misc") {
// not using "**/..." to help keep spotless fast
target(
".gitattributes",
".gitconfig",
".editorconfig",
"*.md",
"src/**/*.md",
"docs/**/*.md",
"*.sh",
"src/**/*.properties")
indentWithSpaces()
trimTrailingWhitespace()
endWithNewline()
}
}
10 changes: 5 additions & 5 deletions docs/jmh.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@

[jmh] (Java Benchmark Harness) is a tool for running benchmarks and reporting results.

opentelemetry-java has a lot of micro benchmarks. They live inside
opentelemetry-java has a lot of micro benchmarks. They live inside
`jmh` directories in the appropriate module.

The benchmarks are run with a gradle plugin.

To run an entire suite for a module, you can run the jmh gradle task.
As an example, here's how you can run the benchmarks for all of
To run an entire suite for a module, you can run the jmh gradle task.
As an example, here's how you can run the benchmarks for all of
the sdk trace module.

```
`./gradlew :sdk:trace:jmh`
```

If you just want to run a single benchmark and not the entire suite:
If you just want to run a single benchmark and not the entire suite:

`./gradlew -PjmhIncludeSingleClass=BatchSpanProcessorBenchmark :sdk:trace:jmh`
`./gradlew -PjmhIncludeSingleClass=BatchSpanProcessorBenchmark :sdk:trace:jmh`
Loading

0 comments on commit 6ef3091

Please sign in to comment.