Skip to content

Commit afbad74

Browse files
committed
static import
1 parent 0b74074 commit afbad74

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

.github/agents/knowledge/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Load only files relevant to the current scope to reduce noise and avoid over-con
1515
| `gradle-conventions.md` | `build.gradle.kts` or `settings.gradle.kts` changes, custom test task registration or wiring |
1616
| `javaagent-advice-patterns.md` | ByteBuddy `@Advice` class or advice-method changes |
1717
| `javaagent-module-patterns.md` | `InstrumentationModule`, `TypeInstrumentation`, `VirtualField`, `CallDepth` |
18-
| `javaagent-singletons-patterns.md` | `*Singletons` holder classes, singleton accessors, callers of singleton accessors/fields |
18+
| `javaagent-singletons-patterns.md` | `*Singletons`, `*SpanNaming`, and similar 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 |
2121
| `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 |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ When a "Knowledge File" is listed, load it from `knowledge/` before reviewing th
2121
| Naming | Module/package naming | New or renamed modules/packages | `module-naming.md` |
2222
| Javaagent | Advice patterns | `@Advice` classes | `javaagent-advice-patterns.md` |
2323
| Javaagent | Module structure patterns | `InstrumentationModule`, `TypeInstrumentation` | `javaagent-module-patterns.md` |
24-
| Javaagent | Singletons patterns | `*Singletons` holder classes, singleton accessors, callers of singleton accessors/fields | `javaagent-singletons-patterns.md` |
24+
| Javaagent | Singletons patterns | `*Singletons`, `*SpanNaming`, and similar holder classes; singleton accessors; callers of singleton accessors/fields | `javaagent-singletons-patterns.md` |
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` |

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
## Quick Reference
44

5-
- Use when: reviewing `*Singletons` holder classes and their callers
5+
- Use when: reviewing `*Singletons`, `*SpanNaming`, and similar holder classes and their callers
66
- Review focus: field/accessor naming, eager initialization, singleton accessor call sites
77

88
Javaagent modules keep shared `Instrumenter` instances and related collaborators in a dedicated
9-
`Singletons` holder class such as `MyLibrarySingletons`.
9+
`Singletons` holder class such as `MyLibrarySingletons`. Some modules also use focused helper
10+
holders such as `*ServerSpanNaming` for shared span-name or route-name collaborators; apply the
11+
same accessor and call-site rules when these classes expose stored singleton fields.
1012

1113
## Rules
1214

@@ -18,8 +20,10 @@ Javaagent modules keep shared `Instrumenter` instances and related collaborators
1820
- For exported collaborators, keep the field `private`, use a lower camel case field name, and
1921
give the accessor method the exact same name as the field. Do not prefix these accessors with
2022
`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).
23+
field. It applies regardless of whether the holder class is named `*Singletons`,
24+
`*ServerSpanNaming`, or another focused holder name. Methods that take arguments or compute a
25+
value are not singleton accessors and keep their normal names (including `get*` when
26+
appropriate).
2327
- `instrumenter` -> `instrumenter()`
2428
- `helper` -> `helper()`
2529
- `setter` -> `setter()`
@@ -32,7 +36,9 @@ Javaagent modules keep shared `Instrumenter` instances and related collaborators
3236
- `RESPONSE_STATUS` stays `RESPONSE_STATUS`
3337
- Callers should static import only exported singleton accessors and uppercase constant-like
3438
fields, and use those members unqualified: accessors for lower camel collaborators, fields for
35-
uppercase constant-like members.
39+
uppercase constant-like members. This includes route/span naming accessors such as
40+
`serverSpanName()` when they simply return a stored `HttpServerRouteGetter` or similar
41+
collaborator.
3642
- Keep verb-named helper methods as verbs when they perform work instead of returning a stored
3743
field. These methods are not singleton accessors and should not be static imported under this
3844
rule.

instrumentation/wicket-8.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/wicket/v8_0/RequestHandlerExecutorInstrumentation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package io.opentelemetry.javaagent.instrumentation.wicket.v8_0;
77

88
import static io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteSource.CONTROLLER;
9+
import static io.opentelemetry.javaagent.instrumentation.wicket.v8_0.WicketServerSpanNaming.serverSpanName;
910
import static net.bytebuddy.matcher.ElementMatchers.named;
1011
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
1112

@@ -42,7 +43,7 @@ public static void onEnter(@Advice.Argument(0) IRequestHandler handler) {
4243
HttpServerRoute.update(
4344
Java8BytecodeBridge.currentContext(),
4445
CONTROLLER,
45-
WicketServerSpanNaming.serverSpanName(),
46+
serverSpanName(),
4647
(IPageClassRequestHandler) handler);
4748
}
4849
}

0 commit comments

Comments
 (0)