Skip to content

Commit 2d7395c

Browse files
authored
Introduce markdown lint check (#7175)
Fixes #7129
1 parent 2db0b03 commit 2d7395c

File tree

67 files changed

+319
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+319
-214
lines changed

.github/workflows/build-daily.yml

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ jobs:
3030
markdown-link-check:
3131
uses: ./.github/workflows/reusable-markdown-link-check.yml
3232

33+
markdown-lint-check:
34+
uses: ./.github/workflows/reusable-markdown-lint-check.yml
35+
3336
misspell-check:
3437
uses: ./.github/workflows/reusable-misspell-check.yml
3538

.github/workflows/build-pull-request.yml

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ jobs:
4343
if: "!startsWith(github.ref_name, 'release/')"
4444
uses: ./.github/workflows/reusable-markdown-link-check.yml
4545

46+
# this is a required check to avoid illegal markdown format
47+
markdown-lint-check:
48+
# release branches are excluded to avoid unnecessary maintenance
49+
if: ${{ !startsWith(github.ref_name, 'release/') }}
50+
uses: ./.github/workflows/reusable-markdown-lint-check.yml
51+
4652
# this is not a required check to avoid blocking pull requests if new misspellings are added
4753
# to the misspell dictionary
4854
misspell-check:

.github/workflows/build.yml

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ jobs:
4545
if: "!startsWith(github.ref_name, 'release/')"
4646
uses: ./.github/workflows/reusable-markdown-link-check.yml
4747

48+
markdown-lint-check:
49+
# release branches are excluded
50+
if: ${{ !startsWith(github.ref_name, 'release/') }}
51+
uses: ./.github/workflows/reusable-markdown-lint-check.yml
52+
4853
misspell-check:
4954
# release branches are excluded to avoid unnecessary maintenance if new misspellings are added
5055
# to the misspell dictionary
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Reusable - Markdown lint check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
markdown-lint-check:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: Install mardkdownlint
13+
run: npm install -g markdownlint-cli
14+
15+
- name: Run markdownlint
16+
run: |
17+
markdownlint -c .markdownlint.yml -p .gitignore **/*.md -i licenses/licenses.md

.markdownlint.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
2+
# and https://github.com/DavidAnson/markdownlint/blob/main/README.md
3+
4+
# Default state for all rules
5+
default: true
6+
7+
ul-style: false
8+
line-length: false
9+
no-duplicate-header:
10+
siblings_only: true
11+
ol-prefix:
12+
style: ordered
13+
no-inline-html: false
14+
fenced-code-language: false

CONTRIBUTING.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
## Contributing
1+
# Contributing
22

33
Pull requests for bug fixes are always welcome!
44

55
Before submitting new features or changes to current functionality, it is recommended to first
66
[open an issue](https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/new)
77
and discuss your ideas or propose the changes you wish to make.
88

9-
### Building
9+
## Building
1010

1111
In order to build and test this whole repository you need JDK 11+.
1212

1313
Some instrumentations and tests may put constraints on which java versions they support.
1414
See [Running the tests](./docs/contributing/running-tests.md) for more details.
1515

16-
#### Snapshot builds
16+
### Snapshot builds
1717

1818
For developers testing code changes before a release is complete, there are
1919
snapshot builds of the `main` branch. They are available from
2020
the Sonatype OSS snapshots repository at `https://oss.sonatype.org/content/repositories/snapshots/`
2121
([browse](https://oss.sonatype.org/content/repositories/snapshots/io/opentelemetry/))
2222

23-
#### Building from source
23+
### Building from source
2424

2525
Build using Java 11+:
2626

@@ -36,39 +36,39 @@ and then you can find the java agent artifact at
3636

3737
`javaagent/build/libs/opentelemetry-javaagent-<version>.jar`.
3838

39-
### IntelliJ setup and troubleshooting
39+
## IntelliJ setup and troubleshooting
4040

4141
See [IntelliJ setup and troubleshooting](docs/contributing/intellij-setup-and-troubleshooting.md)
4242

43-
### Style guide
43+
## Style guide
4444

4545
See [Style guide](docs/contributing/style-guideline.md)
4646

47-
### Running the tests
47+
## Running the tests
4848

4949
See [Running the tests](docs/contributing/running-tests.md)
5050

51-
### Writing instrumentation
51+
## Writing instrumentation
5252

5353
See [Writing instrumentation](docs/contributing/writing-instrumentation.md)
5454

55-
### Understanding the javaagent structure
55+
## Understanding the javaagent structure
5656

5757
See [Understanding the javaagent structure](docs/contributing/javaagent-structure.md)
5858

59-
### Understanding the javaagent instrumentation testing components
59+
## Understanding the javaagent instrumentation testing components
6060

6161
See [Understanding the javaagent instrumentation testing components](docs/contributing/javaagent-test-infra.md)
6262

63-
### Debugging
63+
## Debugging
6464

6565
See [Debugging](docs/contributing/debugging.md)
6666

67-
### Understanding Muzzle
67+
## Understanding Muzzle
6868

6969
See [Understanding Muzzle](docs/contributing/muzzle.md)
7070

71-
### Troubleshooting PR build failures
71+
## Troubleshooting PR build failures
7272

7373
The build logs are very long and there is a lot of parallelization, so the logs can be hard to
7474
decipher, but if you scroll to the bottom you should see something like:

VERSIONING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
## Compatibility requirements
44

55
Artifacts in this repository follow the same compatibility requirements described in
6-
https://github.com/open-telemetry/opentelemetry-java/blob/main/VERSIONING.md#compatibility-requirements
6+
<https://github.com/open-telemetry/opentelemetry-java/blob/main/VERSIONING.md#compatibility-requirements>
77
.
88

99
EXCEPT for the following incompatible changes which are allowed in stable artifacts in this
1010
repository:
1111

1212
* Changes to the telemetry produced by instrumentation
1313
(there will be some guarantees about telemetry stability in the future, see discussions
14-
in https://github.com/open-telemetry/opentelemetry-specification/issues/1301)
14+
in <https://github.com/open-telemetry/opentelemetry-specification/issues/1301>)
1515
* Changes to configuration properties that contain the word `experimental`
1616
* Changes to configuration properties under the namespace `otel.javaagent.testing`
1717

@@ -23,7 +23,7 @@ This means that:
2323

2424
## Stable vs alpha
2525

26-
See https://github.com/open-telemetry/opentelemetry-java/blob/main/VERSIONING.md#stable-vs-alpha
26+
See <https://github.com/open-telemetry/opentelemetry-java/blob/main/VERSIONING.md#stable-vs-alpha>
2727

2828
IN PARTICULAR:
2929

benchmark-overhead/README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* [Process](#process)
55
* [What do we measure?](#what-do-we-measure)
66
* [Config](#config)
7-
+ [Agents](#agents)
7+
* [Agents](#agents)
88
* [Automation](#automation)
99
* [Setup and Usage](#setup-and-usage)
1010
* [Visualization](#visualization)
@@ -23,9 +23,10 @@ There is one dynamic test here called [OverheadTests](https://github.com/open-te
2323
The `@TestFactory` method creates a test pass for each of the [defined configurations](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/benchmark-overhead/src/test/java/io/opentelemetry/config/Configs.java).
2424
Before the tests run, a single collector instance is started. Each test pass has one or more agents configured and those are tested in series.
2525
For each agent defined in a configuration, the test runner (using [testcontainers](https://www.testcontainers.org/)) will:
26+
2627
1. create a fresh postgres instance and populate it with initial data.
2728
2. create a fresh instance of [spring-petclinic-rest](https://github.com/spring-petclinic/spring-petclinic-rest) instrumented with the specified agent
28-
3. measure the time until the petclinic app is marked "healthy" and then write it to a file
29+
3. measure the time until the petclinic app is marked "healthy" and then write it to a file.
2930
4. if configured, perform a warmup phase. During the warmup phase, a bit of traffic is generated in order to get the application into a steady state (primarily helping facilitate jit compilations). Currently, we use a 30 second warmup time.
3031
5. start a JFR recording by running `jcmd` inside the petclinic container
3132
6. run the [k6 test script](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/benchmark-overhead/k6/basic.js) with the configured number of iterations through the file and the configured number of concurrent virtual users (VUs).
@@ -65,6 +66,7 @@ relative overhead.
6566
## Config
6667

6768
Each config contains the following:
69+
6870
* name
6971
* description
7072
* list of agents (see below)
@@ -74,6 +76,7 @@ Each config contains the following:
7476
* warmupSeconds - how long to wait before starting conducting measurements
7577

7678
Currently, we test:
79+
7780
* no agent versus latest released agent
7881
* no agent versus latest snapshot
7982
* latest release vs. latest snapshot

docs/contributing/debugging.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
## Debugging
1+
# Debugging
22

33
Debugging java agent can be a challenging task since some instrumentation
44
code is directly inlined into target classes.
55

6-
### Advice methods
6+
## Advice methods
77

88
Breakpoints do not work in advice methods, because their code is directly inlined
99
by ByteBuddy into the target class. It is good to keep these methods as small as possible.
@@ -21,13 +21,13 @@ System.out.println()
2121
Thread.dumpStack()
2222
```
2323

24-
### Agent initialization code
24+
## Agent initialization code
2525

2626
If you want to debug agent initialization code (e.g. `OpenTelemetryAgent`, `AgentInitializer`,
2727
`AgentInstaller`, `OpenTelemetryInstaller`, etc.) then it's important to specify the `-agentlib:` JVM arg
2828
before the `-javaagent:` JVM arg and use `suspend=y` (see full example below).
2929

30-
### Enabling debugging
30+
## Enabling debugging
3131

3232
The following example shows remote debugger configuration. The breakpoints
3333
should work in any code except ByteBuddy advice methods.

docs/contributing/intellij-setup-and-troubleshooting.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Configuration:
1717
![enable google format](https://user-images.githubusercontent.com/5099946/131759832-36437aa0-a5f7-42c0-9425-8c5b45c16765.png)
1818

1919
Note: If google-java-format generates errors in Intellij,
20-
see https://github.com/google/google-java-format/issues/787#issuecomment-1200762464.
20+
see <https://github.com/google/google-java-format/issues/787#issuecomment-1200762464>.
2121

2222
## Troubleshooting
2323

docs/contributing/muzzle.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Muzzle will prevent loading an instrumentation if it detects any mismatch or con
1212
## How it works
1313

1414
Muzzle has two phases:
15+
1516
* at compile time it collects references to the third-party symbols and used helper classes;
1617
* at runtime it compares those references to the actual API symbols on the classpath.
1718

@@ -73,12 +74,15 @@ it's not an optional feature.
7374
The gradle plugin defines two tasks:
7475

7576
* `muzzle` task runs the runtime muzzle verification against different library versions:
77+
7678
```sh
7779
./gradlew :instrumentation:google-http-client-1.19:javaagent:muzzle
7880
```
81+
7982
If a new, incompatible version of the instrumented library is published it fails the build.
8083

8184
* `printMuzzleReferences` task prints all API references in a given module:
85+
8286
```sh
8387
./gradlew :instrumentation:google-http-client-1.19:javaagent:printMuzzleReferences
8488
```

docs/contributing/repository-settings.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Repository settings
22

33
Repository settings in addition to what's documented already at
4-
https://github.com/open-telemetry/community/blob/main/docs/how-to-configure-new-repository.md.
4+
<https://github.com/open-telemetry/community/blob/main/docs/how-to-configure-new-repository.md>.
55

66
## General > Pull Requests
77

docs/contributing/using-instrumenter-api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ In some rare cases it may be useful to completely disable the constructed `Instr
413413
example, based on a configuration property. The `InstrumenterBuilder` exposes a `setEnabled()`
414414
method for that: passing `false` will turn the newly created `Instrumenter` into a no-op instance.
415415

416-
### Finally, set the span kind with the `SpanKindExtractor` and get a new `Instrumenter`!
416+
### Finally, set the span kind with the `SpanKindExtractor` and get a new `Instrumenter`
417417

418418
The `Instrumenter` creation process ends with calling one of the following `InstrumenterBuilder`
419419
methods:

docs/contributing/writing-instrumentation-module.md

+4
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,18 @@ compile time for it to work.
344344
### Why we don't use ByteBuddy @Advice.Origin Method
345345

346346
Instead of
347+
347348
```
348349
@Advice.Origin Method method
349350
```
351+
350352
we prefer to use
353+
351354
```
352355
@Advice.Origin("#t") Class<?> declaringClass,
353356
@Advice.Origin("#m") String methodName
354357
```
358+
355359
because the former inserts a call to `Class.getMethod(...)` in transformed method. In contrast,
356360
getting the declaring class and method name is just loading constants from constant pool, which is
357361
a much simpler operation.

docs/contributing/writing-instrumentation.md

+1
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ That way you can use these shared, globally available utilities to communicate b
359359
instrumentation modules.
360360

361361
Some examples of this include:
362+
362363
* Application server instrumentations communicating with Servlet API instrumentations.
363364
* Different high-level Kafka consumer instrumentations suppressing the low-level `kafka-clients`
364365
instrumentation.

docs/java-7-rationale.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
## Rationale for not supporting Java 7
1+
# Rationale for not supporting Java 7
22

3-
### Android support is no longer tied to Java 7
3+
## Android support is no longer tied to Java 7
44

55
Even for supporting old Android API levels:
66

77
> If you're building your app using Android Gradle plugin 4.0.0 or higher, the plugin extends
88
> support for using a number of Java 8 language APIs <b>without requiring a minimum API level for
99
> your app</b>.
1010
11-
(https://developer.android.com/studio/write/java8-support#library-desugaring)
11+
(<https://developer.android.com/studio/write/java8-support#library-desugaring>)
1212

1313
There are some Java 8 APIs that Android does not desugar, but we can use
1414
[animal sniffer plugin](https://github.com/xvik/gradle-animalsniffer-plugin) to ensure we don't use
@@ -20,11 +20,11 @@ We will use this approach for the `instrumentation-api` module and for any libra
2020
instrumentation that would be useful to Android developers
2121
(e.g. library instrumentation for OkHttp).
2222

23-
### Modern test tooling requires Java 8+
23+
## Modern test tooling requires Java 8+
2424

2525
Both JUnit 5 and Testcontainers require Java 8+.
2626

27-
### Auto-instrumentation (Javaagent)
27+
## Auto-instrumentation (Javaagent)
2828

2929
We could run tests against Java 8+ and ensure Java 7 compliance by using similar animal sniffer
3030
technique as above.
@@ -43,21 +43,21 @@ debugging across two separate JVMs. And new contributor experience has a very hi
4343
project (compared to say commercial tools who can invest more in onboarding their employees onto a
4444
more complex codebase).
4545

46-
### Library (manual) instrumentation
46+
## Library (manual) instrumentation
4747

4848
We believe that Java 7 users are primarily in maintenance mode and not interested in cracking open
4949
their code anymore and adding library (manual) instrumentation, so we don't believe there is much
5050
interest in library instrumentation targeting Java 7.
5151

52-
### Java 7 usage
52+
## Java 7 usage
5353

5454
Certainly one factor to consider is what percentage of production applications are running Java 7.
5555

5656
Luckily, New Relic
5757
[published their numbers recently](https://blog.newrelic.com/technology/state-of-java),
5858
so we know that ~2.5% of production applications are still running Java 7 as of March 2020.
5959

60-
### Alternatives for Java 7 users
60+
## Alternatives for Java 7 users
6161

6262
We understand the situations that lead applications to get stuck on Java 7 (we've been there
6363
ourselves), and we agree that those applications need monitoring too.

docs/logger-mdc-instrumentation.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Those three pieces of information can be included in log statements produced by
2222
by specifying them in the pattern/format.
2323

2424
Tip: for Spring Boot configuration which uses logback, you can add MDC to log lines by overriding only the `logging.pattern.level`:
25+
2526
```properties
2627
logging.pattern.level = trace_id=%mdc{trace_id} span_id=%mdc{span_id} trace_flags=%mdc{trace_flags} %5p
2728
```

0 commit comments

Comments
 (0)