Skip to content

Commit 0f5f9a4

Browse files
committed
duration
1 parent 3c14fe6 commit 0f5f9a4

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ 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, not simply `static final` | Always ||
18+
| Style | Uppercase field names should reflect semantic constants or immutable value constants such as `Duration` timeouts/intervals, not simply `static final` | Always ||
1919
| Naming | Getter naming (`get` / `is`) | Always ||
2020
| Naming | Module/package naming | New or renamed modules/packages | `module-naming.md` |
2121
| Javaagent | Advice patterns | `@Advice` classes | `javaagent-advice-patterns.md` |

docs/contributing/style-guide.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,13 @@ Method parameters and local variables should never be declared `final`.
9595
### Uppercase field names
9696

9797
Use uppercase (`SCREAMING_SNAKE_CASE`) for constant-like fields whose value is treated as a stable
98-
identifier or immutable descriptor.
98+
identifier, immutable descriptor, or immutable value constant.
9999

100100
Examples that may remain uppercase include:
101101

102102
- literal strings, numbers, and booleans that behave like module constants
103+
- immutable value objects that are treated as fixed constants after initialization, such as
104+
`Duration` timeouts, intervals, or deadlines
103105
- semantic keys and handles such as `AttributeKey`, `ContextKey`, `VirtualField`,
104106
`MethodHandle`, and `Pattern`
105107
- canonical singleton or sentinel fields named `INSTANCE`, `EMPTY`, or `NOOP`
@@ -110,6 +112,12 @@ Use lower camel case for runtime-created collaborator objects even when they are
110112
for example loggers, instrumenters, helpers, sanitizers, mappers, caches, and similar service
111113
objects.
112114

115+
When deciding between uppercase and lower camel case, distinguish immutable value constants from
116+
collaborators. A `private static final Duration FLUSH_TIMEOUT = ...;` field may remain uppercase
117+
when it is used as a fixed timeout constant, even if its value is computed from configuration at
118+
startup. In contrast, runtime-created service objects such as instrumenters, tracers, loggers, or
119+
helpers should use lower camel case.
120+
113121
### `@Nullable` annotation usage
114122

115123
**Note: This section is aspirational and may not reflect the current codebase.**

0 commit comments

Comments
 (0)