Skip to content

Commit 4ad4ee7

Browse files
authored
Merge branch 'main' into prefactor-db-info
2 parents 4fac3c7 + b3ed67b commit 4ad4ee7

938 files changed

Lines changed: 3825 additions & 2395 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.

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

Lines changed: 132 additions & 72 deletions
Large diffs are not rendered by default.

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,13 @@ For each file in scope:
9494
5. Do not flag a non-capturing lambda or method reference as an unnecessary allocation,
9595
because on modern JDKs these are typically cached at the call site rather than
9696
allocated on every invocation.
97-
6. Flag a missing `// added in X.Y` comment on a single-class lower-bound
98-
`hasClassesNamed(...)` check in `classLoaderMatcher()` only after validating that the
99-
stated version is factually correct from repository or upstream evidence; the comment
100-
documents why the matcher exists and which version boundary it enforces.
97+
6. Flag a missing version-boundary comment on a single-class `hasClassesNamed(...)`
98+
check in `classLoaderMatcher()` only after validating the stated boundary from
99+
repository or upstream evidence. Use `// added in X.Y` for a pure lower bound.
100+
If the same positive class also provides the upper bound because it disappears in a
101+
newer sibling version, preserve or request `removed in Y.Z` too. For negated checks
102+
such as `not(hasClassesNamed(...))`, use `// added in Y.Z` because the class's first
103+
appearance is what starts the excluded version range.
101104
7. Prevent duplicates:
102105
- If equivalent `REVIEW:` already exists above the same line, do not add another.
103106

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ When a "Knowledge File" is listed, load it from `knowledge/` before reviewing th
1515
| --- | --- | --- | --- |
1616
| General | Logic, correctness, reliability, safety, copy/paste mistakes, incorrect comments | Always ||
1717
| Style | Style guide | Always ||
18+
| Style | Uppercase field names should reflect semantic constants or immutable value constants such as `Duration` timeouts/intervals, not simply `static final` | Always ||
1819
| Naming | Getter naming (`get` / `is`) | Always ||
20+
| Naming | Boolean/collection option naming (`set*Enabled`, `setCapture*`, `setEmitExperimental*`) | `Experimental` or `TelemetryBuilder` setter changes | `library-patterns.md` |
1921
| Naming | Module/package naming | New or renamed modules/packages | `module-naming.md` |
2022
| Javaagent | Advice patterns | `@Advice` classes | `javaagent-advice-patterns.md` |
2123
| Javaagent | Module structure patterns | `InstrumentationModule`, `TypeInstrumentation`, `Singletons` | `javaagent-module-patterns.md` |
@@ -30,6 +32,7 @@ When a "Knowledge File" is listed, load it from `knowledge/` before reviewing th
3032
| Build | Gradle conventions, muzzle, test tasks, plugins | `build.gradle.kts`, `settings.gradle.kts` | `gradle-conventions.md` |
3133
| Build | `testcontainersBuildService` declaration | Testcontainers dependency without `usesService` | `gradle-conventions.md` |
3234
| Style | Prefer instance creation over singletons for stateless interface impls (except on hot paths or Kotlin `object` declarations) | `TextMapGetter`, `TextMapSetter`, `*AttributesGetter`, `AttributesExtractor`, `SpanNameExtractor`, `HttpServerResponseMutator`, enum/static singletons ||
35+
| Style | Prefer `value == null` / `value != null` over `null == value` / `null != value` | Null comparisons ||
3336
| Style | No unnecessary explicit type witnesses on generic method calls (`Collections.<String>emptyList()`) | Java generic method calls with explicit type parameters ||
3437
| Style | Remove redundant null guards on attribute puts | `AttributesBuilder.put`, `onStart`, `onEnd`, attribute extraction methods ||
3538
| General | No redundant `ByteBuffer.duplicate()` on `Value.getValue()` | `Value.getValue()` with `BYTES` type, `ByteBuffer` handling ||

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ be **static nested classes** inside the instrumentation class, not standalone to
1212

1313
```java
1414
// ✅ Correct: nested inside instrumentation class
15-
public class MyInstrumentation implements TypeInstrumentation {
15+
class MyInstrumentation implements TypeInstrumentation {
1616
// ...
1717

1818
@SuppressWarnings("unused")

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

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,20 @@ class suffices for a simple version boundary — use multiple classes only when:
8282
present (e.g., Jersey checks both the JAX-RS spec API and the Jersey implementation class;
8383
AWS SDK Lambda checks both the Lambda module and JSON protocol core).
8484

85-
Place a comment **above each class name string** stating its version role:
85+
Place a comment **above each class name string** stating its version role and matcher shape:
8686

87-
- **Floor class** (proves "at least version X"): use `// added in X.Y`.
88-
- **Ceiling class** (proves "not yet version Y"): use `// removed in Y.Z`.
87+
- **Positive floor class** in `hasClassesNamed(...)` (proves "at least version X"):
88+
use `// added in X.Y`.
89+
- **Positive ceiling class** in `hasClassesNamed(...)` (proves "not yet version Y"):
90+
use `// removed in Y.Z`.
91+
- **Negated exclusion class** in `not(hasClassesNamed(...))` or
92+
`.and(not(hasClassesNamed(...)))`: use `// added in Y.Z`, because the class's presence
93+
starts excluding `Y.Z+`.
94+
95+
A single **positive** landmark class can sometimes provide **both** bounds: its presence
96+
proves the module is at least version `X.Y`, and the same class disappears in `Y.Z`, so
97+
its presence also excludes `Y.Z+`. In that case, a combined comment such as
98+
`// added in X.Y, removed in Y.Z` is appropriate.
8999

90100
**How to identify ceiling classes**: check whether a **newer sibling module** exists for
91101
the same library (e.g., `mongo-4.0` next to `mongo-3.7`). If the newer module's
@@ -147,9 +157,9 @@ OpenTelemetry instrumentation:
147157
```java
148158
@Override
149159
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
150-
// InternalRequest was introduced in 7.0.0
160+
// added in 7.0.0
151161
return hasClassesNamed("org.elasticsearch.client.RestClient$InternalRequest")
152-
// Instrumentation class was introduced in 8.10 (native OTel support)
162+
// added in 8.10 (native OTel support)
153163
.and(not(hasClassesNamed(
154164
"co.elastic.clients.transport.instrumentation.Instrumentation")));
155165
}
@@ -160,9 +170,9 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
160170
```java
161171
@Override
162172
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
163-
// LibraryTelemetryOptions was introduced in azure-core 1.53
173+
// added in azure-core 1.53
164174
return hasClassesNamed("com.azure.core.util.LibraryTelemetryOptions")
165-
// OpenTelemetryTracer was introduced in azure-core-tracing-opentelemetry 1.0.0-beta.47
175+
// added in azure-core-tracing-opentelemetry 1.0.0-beta.47
166176
.and(not(hasClassesNamed("com.azure.core.tracing.opentelemetry.OpenTelemetryTracer")));
167177
}
168178
```
@@ -180,20 +190,27 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
180190
- **Version comments on landmark classes.** For multi-class checks, `.and(not(...))`
181191
chains, or cases where the landmark version differs from the module's base version,
182192
each `hasClassesNamed()` call must have a `//` comment stating the class's **role**:
183-
- Floor class → `// added in X.Y` (class introduced in version X.Y).
184-
- Ceiling class → `// removed in Y.Z` (class removed in version Y.Z, ensuring the
185-
module does not activate on Y.Z+).
186-
Do not use `// added in` for a ceiling class — that states when the class first appeared,
187-
which is irrelevant and misleading; the purpose is the upper bound.
193+
- Positive floor class → `// added in X.Y` (class introduced in version X.Y).
194+
- Positive ceiling class → `// removed in Y.Z` (class removed in version Y.Z, ensuring
195+
the module does not activate on Y.Z+).
196+
- Negated exclusion class in `not(hasClassesNamed(...))``// added in Y.Z` (class
197+
introduced in version Y.Z, so its presence excludes Y.Z+).
198+
- Single positive class that serves as both floor and ceiling → include both boundaries,
199+
e.g. `// added in X.Y, removed in Y.Z`.
200+
Do not use `// added in` for a **positive** ceiling class — that states when the class
201+
first appeared, which is irrelevant and misleading; the purpose is the upper bound.
202+
Conversely, do use `// added in` for a **negated** exclusion class, because the class's
203+
first appearance is exactly what begins the excluded version range.
188204
To identify ceiling classes, check if a newer sibling module's `classLoaderMatcher()`
189205
checks a different variant or replacement class.
190-
- **Single-class lower-bound comments are required.** When a single-class
191-
`hasClassesNamed(...)` check exists solely to establish the module's lower bound, add an
192-
inline `// added in X.Y` comment. The comment explains why the matcher exists and which
193-
version boundary it enforces. First validate that `X.Y` is factually correct from
194-
repository or upstream evidence; do not infer it from the module name alone. Flag a
195-
missing comment in this case, and do not flag an existing one for removal unless the
196-
comment is demonstrably wrong.
206+
- **Single-class landmark comments are required.** When a single-class
207+
`hasClassesNamed(...)` check establishes the module's lower bound, add an inline
208+
`// added in X.Y` comment. If that same class also establishes the upper bound because
209+
it is removed or replaced in a newer sibling version, include that fact too, e.g.
210+
`// added in X.Y, removed in Y.Z`. First validate each stated boundary from repository
211+
or upstream evidence; do not infer versions from the module name alone. Flag a missing
212+
boundary comment in this case, and do not flag an existing dual-role comment for removal
213+
unless it is demonstrably wrong.
197214
- Prefer **one landmark class** per version boundary — choose the most stable/specific class.
198215
- Pair with **muzzle config** (`assertInverse.set(true)`) for full coverage.
199216
- Use `hasClassesNamed(...)` (from `AgentElementMatchers`) — not raw ByteBuddy matchers.
@@ -208,7 +225,7 @@ Each `TypeInstrumentation` class instruments a single target class.
208225
### Required structure
209226

210227
```java
211-
public class MyClassInstrumentation implements TypeInstrumentation {
228+
class MyClassInstrumentation implements TypeInstrumentation {
212229

213230
@Override
214231
public ElementMatcher<TypeDescription> typeMatcher() {

.github/agents/knowledge/library-patterns.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,32 @@ public final class MyLibraryTelemetry {
4444
- Builder setter methods return `this` and are annotated `@CanIgnoreReturnValue`.
4545
- The builder's constructor is package-private — only `Telemetry.builder()` creates it.
4646
- `build()` returns the `{Library}Telemetry` instance.
47+
48+
## Boolean and Collection Option Naming
49+
50+
Builder methods on `TelemetryBuilder` and `Experimental` classes must follow these
51+
naming patterns. Flag any new method that deviates.
52+
53+
### Canonical patterns
54+
55+
| Semantic | Pattern | Examples |
56+
| --- | --- | --- |
57+
| Feature on/off toggle | `set*Enabled(boolean)` | `setSqlCommenterEnabled`, `setQuerySanitizationEnabled`, `setDataSourceInstrumenterEnabled` |
58+
| Emit experimental signals | `setEmitExperimental*(boolean)` | `setEmitExperimentalTelemetry`, `setEmitExperimentalMetrics` |
59+
| Capture data (boolean) | `setCapture*(boolean)` | `setCaptureExperimentalSpanAttributes`, `setCaptureEnduserId`, `setCaptureQuery` |
60+
| Capture data (collection) | `setCapture*(Collection)` | `setCaptureRequestHeaders`, `setCaptureResponseHeaders`, `setCaptureRequestParameters` |
61+
62+
### Rules
63+
64+
- **`set*Enabled`** is for features that are turned on or off (sanitization, SQL commenter,
65+
instrumenter toggles). The thing being named is a feature or processing step.
66+
- **`setCapture*`** is for options that control whether a piece of data is collected or
67+
emitted (attributes, headers, query text, message content). Use the verb form for both
68+
boolean and collection variants.
69+
- **`setEmitExperimental*`** is reserved for the `Experimental` class toggle that enables
70+
all experimental telemetry for an instrumentation. Do not use on `TelemetryBuilder`.
71+
72+
### Known exceptions
73+
74+
- `setPreferJfrMetrics(boolean)` — selects JFR over JMX for overlapping metrics; it is a
75+
strategy selector, not a feature toggle or data capture flag.

.github/agents/knowledge/testing-general-patterns.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ Fluent assertion calls like `taskId.contains(jobName)` or `taskId.startsWith(pre
3939
already proper AssertJ assertions — they throw on failure. Do **not** wrap them in
4040
`assertThat(value.contains(x)).isTrue()`, which degrades the failure message.
4141

42+
- For generic outer `satisfies(AttributeKey, lambda)` parameters, use `val`.
43+
Do not use short generic alternatives like `k` or `v` for the outer parameter.
44+
- If a `satisfies(...)` lambda contains a nested inner lambda and a second parameter name is
45+
required, keep the outer parameter as `val` and use `v` for the nested parameter.
46+
4247
## AssertJ Idiomatic Simplifications
4348

4449
Prefer built-in AssertJ collection/list assertions over extracting values manually:

.github/copilot-instructions.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ Keep scoped language or file-type rules in `.github/instructions/*.instructions.
1616
- Style guide and core conventions: `docs/contributing/style-guide.md`
1717
- Review and implementation knowledge by topic: `.github/agents/knowledge/README.md`
1818

19+
## Knowledge Loading
20+
21+
For coding, fix, and refactoring tasks, consult `.github/agents/knowledge/README.md`
22+
before making substantial changes.
23+
24+
Use the knowledge index to load only the article(s) relevant to the current task.
25+
Do not load the entire knowledge folder by default.
26+
1927
## Gradle Execution Rules
2028

2129
Never use `--rerun-tasks`. Use `--rerun` when needed.

.github/instructions/gradle-testing.instructions.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/instructions/java-style-and-safety.instructions.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)