Skip to content

Commit b102ebc

Browse files
committed
Merge remote-tracking branch 'upstream/main' into class-loader-matcher
# Conflicts: # instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-jersey-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v2_0/JerseyInstrumentationModule.java
2 parents 08ee8f9 + fdacd21 commit b102ebc

379 files changed

Lines changed: 2004 additions & 1175 deletions

File tree

Some content is hidden

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

.fossa.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,6 @@ targets:
346346
- type: gradle
347347
path: ./
348348
target: ':instrumentation:armeria:armeria-grpc-1.14:javaagent'
349-
- type: gradle
350-
path: ./
351-
target: ':instrumentation:async-http-client:async-http-client-1-common:javaagent'
352349
- type: gradle
353350
path: ./
354351
target: ':instrumentation:async-http-client:async-http-client-1.8:javaagent'
@@ -358,6 +355,9 @@ targets:
358355
- type: gradle
359356
path: ./
360357
target: ':instrumentation:async-http-client:async-http-client-2.0:javaagent'
358+
- type: gradle
359+
path: ./
360+
target: ':instrumentation:async-http-client:async-http-client-common-1.8:javaagent'
361361
- type: gradle
362362
path: ./
363363
target: ':instrumentation:aws-lambda:aws-lambda-core-1.0:javaagent'
@@ -427,9 +427,6 @@ targets:
427427
- type: gradle
428428
path: ./
429429
target: ':instrumentation:clickhouse:clickhouse-client-v2-0.8:javaagent'
430-
- type: gradle
431-
path: ./
432-
target: ':instrumentation:couchbase:couchbase-2-common:javaagent'
433430
- type: gradle
434431
path: ./
435432
target: ':instrumentation:couchbase:couchbase-2.0:javaagent'
@@ -448,6 +445,9 @@ targets:
448445
- type: gradle
449446
path: ./
450447
target: ':instrumentation:couchbase:couchbase-3.4:javaagent'
448+
- type: gradle
449+
path: ./
450+
target: ':instrumentation:couchbase:couchbase-common-2.0:javaagent'
451451
- type: gradle
452452
path: ./
453453
target: ':instrumentation:dropwizard:dropwizard-metrics-4.0:javaagent'
@@ -630,10 +630,10 @@ targets:
630630
target: ':instrumentation:jms:jms-common:javaagent'
631631
- type: gradle
632632
path: ./
633-
target: ':instrumentation:jsf:jsf-jakarta-common:javaagent'
633+
target: ':instrumentation:jsf:jsf-common-javax:javaagent'
634634
- type: gradle
635635
path: ./
636-
target: ':instrumentation:jsf:jsf-javax-common:javaagent'
636+
target: ':instrumentation:jsf:jsf-jakarta-common:javaagent'
637637
- type: gradle
638638
path: ./
639639
target: ':instrumentation:jsf:jsf-mojarra-1.2:javaagent'
@@ -1092,7 +1092,7 @@ targets:
10921092
target: ':instrumentation:jaxrs:jaxrs-2.0:jaxrs-2.0-resteasy-3.1:javaagent'
10931093
- type: gradle
10941094
path: ./
1095-
target: ':instrumentation:jaxrs:jaxrs-2.0:jaxrs-2.0-resteasy-common:javaagent'
1095+
target: ':instrumentation:jaxrs:jaxrs-2.0:jaxrs-2.0-resteasy-common-3.0:javaagent'
10961096
- type: gradle
10971097
path: ./
10981098
target: ':instrumentation:jaxrs:jaxrs-3.0:jaxrs-3.0-annotations:javaagent'

.github/agents/code-review-and-fix.agent.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ Auto-fix boundaries:
139139

140140
- Safe to fix:
141141
- import cleanup or direct style-guide conformance
142+
**Extra step for shared/common modules**: when the modified file resides in a module
143+
whose directory name contains `-common`, or whose Gradle path ends with `:testing`,
144+
`:library`, or `:bootstrap`, **first search all sibling modules** under the same
145+
instrumentation parent for callers of the type or member before applying the fix.
142146
- normalization of existing `@SuppressWarnings` syntax or placement, but preserve any
143147
accurate explanatory comment attached to the suppression instead of deleting it as
144148
style noise
@@ -152,6 +156,8 @@ Auto-fix boundaries:
152156
already valid AssertJ assertions; do not wrap them in `assertThat(...).isTrue()`
153157
- AssertJ `.as(...)` descriptions and `.withFailMessage(...)` in tests — remove them
154158
and prefer direct assertions whose failure output already exposes the unexpected values
159+
- `@Test` method `throws` clauses — limit them to a single exception type and keep that type as
160+
specific as possible.
155161
- deterministic semconv constant handling aligned with repository rules
156162
- missing test-task wiring patterns with clear canonical form
157163
- missing `testInstrumentation` cross-version references — when a javaagent module belongs
@@ -227,6 +233,10 @@ Auto-fix boundaries:
227233
readers/writers/streams/response bodies).
228234
Do not apply this conversion in non-JUnit helper methods, `@BeforeAll`, or shared
229235
setup code.
236+
- class-scoped resources created in `@BeforeAll` or other shared setup — prefer
237+
`AutoCleanupExtension` with `deferAfterAll(...)` over nested `@AfterAll` cleanup
238+
chains. Do not introduce or keep `AutoCleanupExtension` solely for a single
239+
`deferAfterAll(...)` call — use a plain `@AfterAll` instead.
230240
- `hasAttributesSatisfying(...)` calls in test assertions — replace with
231241
`hasAttributesSatisfyingExactly(...)` because it is more precise (the non-exact
232242
variant silently ignores unexpected attributes)
@@ -295,6 +305,12 @@ Auto-fix boundaries:
295305
add the correctly named/shaped method with the implementation, deprecate the old method
296306
to delegate to the new one, and add a `@deprecated` Javadoc tag naming the replacement.
297307
For stable modules, annotate instead: the fix requires a broader compatibility decision.
308+
**Exception — javaagent modules**: javaagent modules (Gradle path ends with `:javaagent`,
309+
including shared `-common` javaagent modules) are bundled into the agent jar and are not
310+
a public API. Do **not** apply a deprecation cycle; rename or change the API directly
311+
and update all in-repo callers in the same commit. A deprecation cycle is only required
312+
for non-stable modules whose artifacts are published for external consumption (e.g.,
313+
`:library`, `:testing`, `instrumentation-api*`).
298314
- Do not auto-fix (report in the final output instead):
299315
- missing `testExperimental` task — when experimental flags are set unconditionally
300316
on all test tasks instead of being isolated in a dedicated task
@@ -397,22 +413,30 @@ Execute these steps strictly in order — do not reorder:
397413
pre-existing failure — note it in the final output but do not block the commit.
398414
5. Never commit code that fails tests you can reproduce locally.
399415

400-
**Testing-module dependent validation**: when any modified module is a `testing` module
401-
(its Gradle path ends with `:testing`), you must **also** run `:check` (both normal and
402-
`-PtestLatestDeps=true`) for every sibling `library` and `javaagent` module under the
403-
same instrumentation parent. `testing` modules contain shared abstract test base classes
404-
consumed by those siblings — changes to visibility, method signatures, or class structure
405-
in the `testing` module can break compilation or tests in dependent modules.
406-
407-
To find siblings, list the parent directory of the `testing` module and look for
416+
**Shared-module dependent validation**: when any modified module is a shared module
417+
consumed by sibling instrumentation modules, you must **also** run `:check` (both normal
418+
and `-PtestLatestDeps=true`) for every sibling `library` and `javaagent` module under the
419+
same instrumentation parent. A module is shared if its Gradle path ends with `:testing`,
420+
or its directory name contains `-common` (e.g., `couchbase-2-common`, `netty-common`),
421+
or it is named `library`, `bootstrap`, or `testing-common`. Changes to visibility,
422+
method signatures, or class structure in a shared module can break compilation or tests
423+
in dependent sibling modules — including failures that compile cleanly but throw
424+
`IllegalAccessError` at runtime inside ByteBuddy advice.
425+
426+
To find siblings, list the parent directory of the shared module and look for
408427
`library/`, `javaagent/`, and any version-variant directories that contain `library/`
409-
or `javaagent/` submodules. Run `:check` for each.
428+
or `javaagent/` submodules. Also check `settings.gradle.kts` for every module under
429+
the same instrumentation group. Run `:check` for each sibling that transitively
430+
depends on the modified shared module.
410431

411432
Example: if you modify files in
412433
`:instrumentation:foo:foo-1.0:testing`, also run `:check` for
413434
`:instrumentation:foo:foo-1.0:library`,
414435
`:instrumentation:foo:foo-1.0:javaagent`, and any version-variant siblings such as
415436
`:instrumentation:foo:foo-2.0:library` if it depends on the `foo-1.0:testing` module.
437+
Likewise, if you modify files in `:instrumentation:couchbase:couchbase-2-common:javaagent`,
438+
also run `:check` for `:instrumentation:couchbase:couchbase-2.0:javaagent` and
439+
`:instrumentation:couchbase:couchbase-2.6:javaagent`.
416440

417441
Do not move on to step 2 until every required `:check` run from this step, including
418442
sibling-module validation and any re-runs after fixes or reverts, has fully completed

.github/agents/knowledge/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Load only files relevant to the current scope to reduce noise and avoid over-con
1818
| `javaagent-singletons-patterns.md` | `*Singletons` holder classes, singleton accessors, callers of singleton accessors/fields |
1919
| `library-patterns.md` | Library instrumentation telemetry, builder, getter, or setter pattern changes |
2020
| `module-naming.md` | New or renamed modules or packages; settings includes |
21-
| `testing-general-patterns.md` | Test files in scope — assertion style, resource cleanup patterns, attribute assertion patterns, `satisfies()` lambda usage |
21+
| `testing-general-patterns.md` | Test files in scope — assertion style, test method signatures and throws clauses, resource cleanup patterns, attribute assertion patterns, `satisfies()` lambda usage |
2222
| `testing-experimental-flags.md` | `testExperimental` task or experimental span-attribute assertions |
2323
| `testing-semconv-stability.md` | Semconv opt-in modes, `emitOld*`/`emitStable*`, `maybeStable`, Semconv test tasks |
2424

.github/agents/knowledge/api-deprecation-policy.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ The CHANGELOG uses distinct headings to distinguish:
1818
- `⚠️ Breaking changes to non-stable APIs` — alpha/non-stable modules (routine)
1919
- `⚠️ Breaking Changes` — stable module changes (rare, requires strong justification)
2020

21+
### Javaagent modules are not a public API
22+
23+
Javaagent modules (Gradle path ends with `:javaagent`, including shared `-common` javaagent
24+
modules) are bundled into the agent jar and are **not** published for external consumption.
25+
Do **not** apply a deprecation cycle to symbols in javaagent modules — rename or change the
26+
API directly and update all in-repo callers in the same commit. The deprecate-then-remove
27+
cycle described below applies only to non-stable modules whose artifacts are published
28+
(e.g., `:library`, `:testing`, `instrumentation-api*`).
29+
2130
## The Deprecate-Then-Remove Cycle
2231

2332
### Alpha (non-stable) modules

.github/agents/knowledge/general-rules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ When a "Knowledge File" is listed, load it from `knowledge/` before reviewing th
2525
| Javaagent | Incorrect `classLoaderMatcher()` | `classLoaderMatcher()` override that is redundant (muzzle already handles it) or missing when needed (muzzle cannot distinguish version range) | `javaagent-module-patterns.md` |
2626
| Semconv | Library vs javaagent semconv constant usage | Semconv constants/assertions ||
2727
| Semconv | Dual semconv testing | `SemconvStability`, `maybeStable`, semconv Gradle tasks | `testing-semconv-stability.md` |
28-
| Testing | General test patterns | Test files in scope — assertion style, resource cleanup, attribute assertions | `testing-general-patterns.md` |
28+
| Testing | General test patterns | Test files in scope — assertion style, test method signatures and throws clauses, resource cleanup, attribute assertions | `testing-general-patterns.md` |
2929
| Testing | Experimental flag tests | `testExperimental`, experimental attribute assertions, `experimental` flags in JVM args or system properties | `testing-experimental-flags.md` |
3030
| Library | TelemetryBuilder/getter/setter patterns | Library instrumentation classes | `library-patterns.md` |
3131
| API | Deprecation and breaking-change policy | Public API changes | `api-deprecation-policy.md` |

.github/agents/knowledge/gradle-conventions.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ module it extends) imports or instantiates Testcontainers types (`GenericContain
188188
rely solely on the presence of an `org.testcontainers:*` dependency in `build.gradle.kts`,
189189
because the dependency may only be used by some suites in the module.
190190

191-
## Prefer `withType<Test>().configureEach` (when multiple test tasks exist)
191+
## Prefer `withType<Test>().configureEach` (ONLY when multiple test tasks exist)
192192

193193
When a module has custom test tasks (e.g., `testStableSemconv`), system properties and JVM
194194
args that apply to **all** test tasks should be set once in a `withType<Test>().configureEach`
@@ -197,13 +197,24 @@ block, not repeated on each individual task.
197197
If a property or JVM arg is moved into `withType<Test>().configureEach`, remove any now-redundant
198198
copies from individual tasks unless a task intentionally overrides the shared value.
199199

200-
When there is only one test task, `tasks.test { ... }` is fine — do not convert it to
201-
`withType<Test>().configureEach` and do not flag it.
200+
When the module's `build.gradle.kts` does not explicitly register additional `Test` tasks,
201+
`tasks.test { ... }` is fine — **do not** convert it to `withType<Test>().configureEach` and
202+
do not flag it.
202203

203-
**How to spot violations:** If `build.gradle.kts` has both a `test { ... }` block and a
204-
custom test task (e.g., `val testStableSemconv by registering(Test::class)`), check whether
205-
any `systemProperty(...)` or `jvmArgs(...)` calls appear inside the `test { }` block that
206-
should apply to all tasks. If so, move them to `withType<Test>().configureEach`.
204+
**`latestDepTest` does not count as a second test task for this rule.** It is registered
205+
implicitly by the convention plugin when `testLatestDeps` is set, and it inherits the
206+
configuration of `tasks.test`. A module with only a `tasks.test { ... }` block and no
207+
`by registering(Test::class)` declarations is a single-test-task module — leave it alone
208+
even if `testLatestDeps = true`.
209+
210+
Only consider converting to `withType<Test>().configureEach` when the **same
211+
`build.gradle.kts`** explicitly registers one or more additional `Test` tasks via
212+
`val foo by registering(Test::class)`.
213+
214+
**How to spot violations:** If `build.gradle.kts` has both a `test { ... }` block and an
215+
explicit `by registering(Test::class)` custom test task (e.g., `testStableSemconv`), check
216+
whether any `systemProperty(...)` or `jvmArgs(...)` calls appear inside the `test { }` block
217+
that should apply to all tasks. If so, move them to `withType<Test>().configureEach`.
207218

208219
```kotlin
209220
tasks {
@@ -232,7 +243,8 @@ review**. Only verify correctness when they are already present.
232243

233244
When already present, verify:
234245

235-
- `collectMetadata` is in `withType<Test>().configureEach` (or `tasks.test` if only one test
236-
task) — never on individual tasks.
246+
- `collectMetadata` is in `withType<Test>().configureEach` (or `tasks.test` if the module
247+
does not explicitly register additional `Test` tasks — `latestDepTest` does not count) —
248+
never on individual tasks.
237249
- `metadataConfig` is on each non-default task, not on the default `test` task.
238250
- The `metadataConfig` value matches at least one of the jvmArgs configured in the task

.github/agents/knowledge/javaagent-singletons-patterns.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ Javaagent modules keep shared `Instrumenter` instances and related collaborators
1717
`"io.opentelemetry.<module-name>"`.
1818
- For exported collaborators, keep the field `private`, use a lower camel case field name, and
1919
give the accessor method the exact same name as the field. Do not prefix these accessors with
20-
`get`.
20+
`get`. This rule applies only to zero-arg methods that directly return a stored singleton
21+
field; methods that take arguments or compute a value are not singleton accessors and keep
22+
their normal names (including `get*` when appropriate).
2123
- `instrumenter` -> `instrumenter()`
2224
- `helper` -> `helper()`
2325
- `setter` -> `setter()`
@@ -34,6 +36,9 @@ Javaagent modules keep shared `Instrumenter` instances and related collaborators
3436
- Keep verb-named helper methods as verbs when they perform work instead of returning a stored
3537
field. These methods are not singleton accessors and should not be static imported under this
3638
rule.
39+
- Methods on a `*Singletons` class that take arguments (for example `addressAndPort(client)` or
40+
`getAddressAndPort(client)`) are not singleton accessors. Do not apply the field-style
41+
accessor naming rule to them, and do not flag their `get*` prefix on that basis.
3742

3843
## Preferred Pattern
3944

@@ -103,7 +108,8 @@ class MyInstrumentation implements TypeInstrumentation {
103108
final` field would be clearer and matches the naming guidance, including semantic keys/handles
104109
and immutable value constants.
105110
- Accessor methods named `getInstrumenter()`, `getHelper()`, `getSetter()`, and similar when they
106-
simply return a backing field.
111+
simply return a backing field. Do not flag `get*`-prefixed methods that take arguments or
112+
compute a value rather than returning a stored singleton field.
107113
- Call sites that qualify singleton accessor or uppercase constant-like field usage with the holder
108114
class instead of static importing the accessor or field.
109115
- Static imports of non-accessor helper methods on a `*Singletons` class when the method performs

.github/agents/knowledge/metadata-yaml-format.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ For `otel.instrumentation.*` properties not in SPECIAL_MAPPINGS:
4949
1. Strip `otel.instrumentation.` prefix
5050
2. Replace `-` with `_` (kebab-case → snake_case)
5151
3. Handle `experimental`:
52-
- `experimental.` path segment → remove, add `/development` to next segment
53-
- `experimental-` in name → add `/development` to that segment
52+
- `experimental.` as a separate path segment → **remove** it, add `/development` to next segment
53+
- `experimental-` as a prefix within a segment name → **keep** it (as `experimental_`), add `/development` to that segment
5454
4. Prepend `java.`
5555

5656
Examples:
@@ -59,9 +59,15 @@ Examples:
5959
|------------------------------------------------------------------------------|-------------------------------------------------------------|
6060
| `otel.instrumentation.grpc.emit-message-events` | `java.grpc.emit_message_events` |
6161
| `otel.instrumentation.grpc.experimental-span-attributes` | `java.grpc.experimental_span_attributes/development` |
62+
| `otel.instrumentation.aws-sdk.experimental-span-attributes` | `java.aws_sdk.experimental_span_attributes/development` |
6263
| `otel.instrumentation.logback-appender.experimental.capture-code-attributes` | `java.logback_appender.capture_code_attributes/development` |
6364
| `otel.instrumentation.common.experimental.controller-telemetry.enabled` | `java.common.controller_telemetry/development.enabled` |
6465

66+
**Key distinction**:
67+
68+
- `experimental-span-attributes` (hyphenated compound) → `experimental_span_attributes/development` (prefix **kept**)
69+
- `experimental.capture-code-attributes` (separate segment) → `capture_code_attributes/development` (segment **removed**)
70+
6571
## Examples Guidelines
6672

6773
Add `examples` only for module-specific configs with non-obvious format (lists, patterns, enums).

0 commit comments

Comments
 (0)