-
Notifications
You must be signed in to change notification settings - Fork 9
chore: migrate from flint v1 (super-linter) to flint v2 binary #1251
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
0f25ad4
chore: migrate from flint v1 (super-linter) to flint v2 binary
zeitlinger d39fbc7
chore: update renovate-tracked-deps for flint v2 tools
zeitlinger 8653637
chore: use full multi-line license header text
zeitlinger 63b8ce0
fix: refresh flint v2 migration
zeitlinger ba9c472
fix: keep fix alias and align license header text
zeitlinger bb734ab
chore: switch flint migration to v0.20.3
zeitlinger fc7b442
ci: normalize flint init output
zeitlinger 9727c12
ci: keep markdownlint exceptions local
zeitlinger a48cf1e
Merge origin/main into feat/flint-v2-migration
zeitlinger 4974ccc
chore: simplify lint tasks
zeitlinger e43dea7
docs: clarify markdown line length policy
zeitlinger 2431a8f
chore: clarify tool grouping
zeitlinger 54df30f
chore: separate tools from linters
zeitlinger 547e2c7
chore: group flint with linters
zeitlinger d906733
chore: drop redundant tools heading
zeitlinger 361ff3d
chore: tighten mise tool spacing
zeitlinger e284979
chore: drop pre-commit setup task
zeitlinger cda1842
chore: preserve markdownlint config
zeitlinger 8b4d549
chore: replace spotless with flint linting
zeitlinger 1db27cb
chore: refresh renovate tracked deps
zeitlinger cf4b158
chore: restore markdownlint config
zeitlinger d5201b8
chore: scope line length by file type
zeitlinger 0d8f17a
chore: enforce markdown line length
zeitlinger 07ce173
chore: apply prettier fixes
zeitlinger e67342b
chore: tighten line length enforcement
zeitlinger 0f792e6
chore: apply prettier fixes
zeitlinger 2b54954
chore: restore upstream reference
zeitlinger 5f93725
chore: apply java formatting
zeitlinger 90265a8
docs: align markdown lint guidance
zeitlinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,52 @@ | ||
| root = true | ||
|
|
||
| [*] | ||
| max_line_length = 100 | ||
| indent_size = 2 | ||
|
|
||
| [*.md] | ||
| max_line_length = 120 | ||
|
|
||
| [CHANGELOG.md] | ||
| max_line_length = off | ||
|
|
||
| [*.yml] | ||
| max_line_length = 200 | ||
|
|
||
| [*.yaml] | ||
| max_line_length = 200 | ||
|
|
||
| [*.json] | ||
| max_line_length = 120 | ||
|
|
||
| [*.json5] | ||
| max_line_length = 120 | ||
|
|
||
| [Dockerfile*] | ||
| max_line_length = 200 | ||
|
|
||
| [{*.gradle,build.gradle,settings.gradle}] | ||
| max_line_length = 150 | ||
|
|
||
| [*.xml] | ||
| max_line_length = 200 | ||
|
|
||
| [build.gradle] | ||
| indent_size = 2 | ||
|
|
||
| [*.java] | ||
| max_line_length = 120 | ||
| indent_size = 2 | ||
|
|
||
| # ktlint overrides | ||
| [{*.kt,*.kts}] | ||
| max_line_length = 160 | ||
| continuation_indent_size = 2 | ||
| ktlint_standard_no-wildcard-imports = disabled | ||
| ktlint_standard_package-name = disabled | ||
| ktlint_standard_max-line-length = disabled | ||
| ktlint_standard_trailing-comma-on-call-site = disabled | ||
| ktlint_standard_trailing-comma-on-declaration-site = disabled | ||
| ktlint_standard_wrapping = disabled | ||
| ktlint_standard_property-naming = disabled | ||
| ktlint_standard_function-literal = disabled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| [settings] | ||
| exclude = [ | ||
| "CHANGELOG.md", | ||
| "gradlew", | ||
| "gradlew.bat", | ||
| ] | ||
|
|
||
| [checks.license-header] | ||
| text = """ | ||
| /* | ||
| * Copyright Grafana Labs | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| """ | ||
|
zeitlinger marked this conversation as resolved.
|
||
| patterns = ["**/*.java", "**/*.kt"] | ||
|
zeitlinger marked this conversation as resolved.
|
||
|
|
||
| [checks.renovate-deps] | ||
| exclude_managers = ["github-actions", "github-runners"] | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,71 +1,105 @@ | ||
| # AGENTS.md | ||
|
|
||
| This file provides guidance to AI coding agents when working with code in this repository. | ||
| This file provides guidance to AI coding agents when working | ||
| with code in this repository. | ||
|
|
||
| ## What This Is | ||
|
|
||
| A javaagent distribution of the [OpenTelemetry Java instrumentation agent](https://github.com/open-telemetry/opentelemetry-java-instrumentation), optimized for Grafana Cloud Application Observability. It wraps the upstream agent and adds Grafana-specific extensions (tested instrumentation filtering, metric filtering, resource attribute truncation, default config). | ||
| A javaagent distribution of the | ||
| [OpenTelemetry Java instrumentation | ||
| agent](https://github.com/open-telemetry/opentelemetry-java-instrumentation), | ||
| optimized for Grafana Cloud Application Observability. It | ||
| wraps the upstream agent and adds Grafana-specific | ||
| extensions (tested instrumentation filtering, metric | ||
| filtering, resource attribute truncation, default config). | ||
|
|
||
| ## Build Commands | ||
|
|
||
| ```sh | ||
| ./gradlew build # full build (compiles, tests, assembles agent JAR) | ||
| ./gradlew spotlessApply # auto-format Java (Google Java Format) and misc files | ||
| mise run lint:fix # auto-fix Java/Markdown/YAML/shell lint issues via flint | ||
| ./gradlew :custom:test # run unit tests only | ||
| ./gradlew :custom:test --tests '*MetricFilterTest' # run a single test class | ||
| SMOKE_TEST_JAVA_VERSION=8 ./gradlew :smoke-tests:test # run smoke tests (requires env var) | ||
| ``` | ||
|
|
||
| The final artifact is `agent/build/libs/grafana-opentelemetry-java.jar`. | ||
|
|
||
| Smoke tests only run when `SMOKE_TEST_JAVA_VERSION` env var is set (or running in IntelliJ). They use TestContainers and test the entire javaagent with a real application. | ||
| Smoke tests only run when `SMOKE_TEST_JAVA_VERSION` env var | ||
| is set (or running in IntelliJ). They use TestContainers | ||
| and test the entire javaagent with a real application. | ||
|
|
||
| ## Modules | ||
|
|
||
| - **`:custom`** — Grafana extensions: instrumentation filtering, metric filtering, resource truncation, version logging. Entry point is `GrafanaAutoConfigCustomizerProvider` (implements OpenTelemetry's `AutoConfigurationCustomizerProvider` SPI). Has checkstyle enforcement. | ||
| - **`:agent`** — Packages the upstream OTEL javaagent + custom extensions into a single shadow JAR via a 3-step process (relocate → isolate → merge) to avoid classpath conflicts. | ||
| - **`:smoke-tests`** — Integration tests using TestContainers that run a Spring Boot app with the full javaagent attached. | ||
| - **`:custom`** — Grafana extensions: instrumentation | ||
| filtering, metric filtering, resource truncation, version | ||
| logging. Entry point is | ||
| `GrafanaAutoConfigCustomizerProvider` (implements | ||
| OpenTelemetry's `AutoConfigurationCustomizerProvider` | ||
| SPI). Has checkstyle enforcement. | ||
| - **`:agent`** — Packages the upstream OTEL javaagent + | ||
| custom extensions into a single shadow JAR via a 3-step | ||
| process (relocate → isolate → merge) to avoid classpath | ||
| conflicts. | ||
| - **`:smoke-tests`** — Integration tests using | ||
| TestContainers that run a Spring Boot app with the full | ||
| javaagent attached. | ||
|
|
||
| ## Architecture | ||
|
|
||
| The distro extends upstream OTEL via the `AutoConfigurationCustomizerProvider` SPI. Key customization points in `:custom`: | ||
| The distro extends upstream OTEL via the | ||
| `AutoConfigurationCustomizerProvider` SPI. Key | ||
| customization points in `:custom`: | ||
|
|
||
| - `TestedInstrumentationsCustomizer` — optionally limits active instrumentations to a curated list in `Instrumentations.java` (controlled by `grafana.otel.use-tested-instrumentations` property) | ||
| - `TestedInstrumentationsCustomizer` — optionally limits | ||
| active instrumentations to a curated list in | ||
| `Instrumentations.java` (controlled by | ||
| `grafana.otel.use-tested-instrumentations` property) | ||
| - `MetricsCustomizer` / `MetricFilter` — filters metrics | ||
| - `ResourceCustomizer` — truncates resource attribute values (default 2048 chars) | ||
| - `DistributionVersion.java` — **auto-generated** by `custom/build.gradle` `manageVersionClass` task; do not edit manually | ||
| - `DistributionVersion.java` — **auto-generated** by | ||
| `custom/build.gradle` `manageVersionClass` task; do not | ||
| edit manually | ||
|
|
||
| Package relocation (`gradle/shadow.gradle`) moves OpenTelemetry classes to `io.opentelemetry.javaagent.shaded.*` to prevent conflicts with instrumented application code. Resource providers are excluded from relocation. | ||
| Package relocation (`gradle/shadow.gradle`) moves | ||
| OpenTelemetry classes to | ||
| `io.opentelemetry.javaagent.shaded.*` to prevent conflicts | ||
| with instrumented application code. Resource providers are | ||
| excluded from relocation. | ||
|
|
||
| ## Linting | ||
|
|
||
| After modifying non-Java files (Markdown, YAML, Dockerfiles, shell scripts, etc.), always run linting via mise: | ||
|
|
||
| ```sh | ||
| mise run lint:super-linter # run super-linter only | ||
| mise run fix # auto-fix lint issues | ||
| mise run lint # run lint checks | ||
| mise run lint:fix # auto-fix lint issues | ||
|
zeitlinger marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| Lint tasks are sourced from [grafana/flint](https://github.com/grafana/flint). | ||
|
|
||
| ## Code Conventions | ||
|
|
||
| - Java 8 compilation target (`-Werror`), Java 17 for tests | ||
| - Google Java Format via Spotless, checkstyle (Google style) on `:custom` | ||
| - License header: Apache 2.0 / Grafana Labs (enforced by Spotless) | ||
| - Google Java Format, ktlint, and checkstyle (Google style) on `:custom` | ||
| - License header: Apache 2.0 / Grafana Labs (enforced by flint) | ||
| - Package root: `com.grafana.extensions.*` | ||
|
zeitlinger marked this conversation as resolved.
|
||
| - JUnit 5 + AssertJ for assertions, LogUnit for log capture | ||
|
|
||
| ## CI | ||
|
|
||
| - PR builds test against Java 8, 11, 17, 21 | ||
| - Linting: super-linter, lychee (link checker), markdownlint, codespell | ||
| - Linting: flint v2 (google-java-format, ktlint, markdownlint, | ||
| editorconfig-checker, lychee, codespell, shellcheck, shfmt, | ||
| actionlint, prettier) | ||
| - `CHECK_GENERATED_FILES=true` validates that auto-generated code is up to date | ||
| - OWASP dependency check fails build on CVE CVSS >= 7.0 | ||
| - Releases are scheduled weekly (Friday 09:00 UTC) or triggered manually | ||
|
|
||
| ## Dependency Management | ||
|
|
||
| - Upstream OTEL version tracked in `build.gradle` → `otelInstrumentationVersion` | ||
| - Renovate manages dependency updates; extends `github>grafana/flint` preset for mise task and tool version updates (see `.github/renovate.json5`) | ||
| - Renovate manages dependency updates; extends | ||
| `github>grafana/flint` preset for mise task and tool | ||
| version updates (see `.github/renovate.json5`) | ||
| - `mise.toml` manages tool versions (Java, lychee) and lint tasks | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| // Keep JSON formatting aligned with the repo's two-space style. | ||
| "formatter": { | ||
| "indentStyle": "space", | ||
| "indentWidth": 2 | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.