Repository navigation
Commit a2eb6db
Add @Staticlifetime and @singleton marker annotations
@Staticlifetime marks a field that must live for the whole program
rather than for its enclosing instance's lifetime (e.g. a cache
allocated per-request instead of once). @singleton is its escape
valve, declaring a class has exactly one process-wide instance, so
an instance field on it can satisfy @Staticlifetime without being
static. Wires a matching check into the perf-review checks doc,
mirroring the existing @NoEscape field-storage check.
APMLP-1846, APMLP-1847
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Add Checker contract section to @singleton javadoc
Splits narrative vs. machine-checkable rule, matching the convention
established by @NoEscape and @Staticlifetime.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Annotate WebFlux route cache with @Staticlifetime
Spot-checks the annotation against the real defect it was modeled on:
PR #12561 (commit e6b8756) made this exact DDCache field static
after it lived per-instance, unshared, for ~4 years. Serves as the
first real call site for @Staticlifetime.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Annotate UTF8 tag/value caches with @Staticlifetime
TAG_CACHE/VALUE_CACHE in TraceMapperV0_4 and KEY_CACHE/VALUE_CACHE
in OtlpCommonProto are already static final -- marking them adds
compliant-example coverage alongside RouteOnSuccessOrError's
violation-turned-compliant case.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Revert "Annotate WebFlux route cache with @Staticlifetime"
Holding off on applying @Staticlifetime to real cache fields until
@SuppressPerfContract (dougqh/perf-contract-suppress, PR #12647) lands
-- want the exemption mechanism in place before widening the annotated
surface.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Revert "Annotate UTF8 tag/value caches with @Staticlifetime"
Same reason as the WebFlux route-cache revert: hold off until
@SuppressPerfContract lands.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Close StaticLifetime checker-contract gaps: require final, static+non-final
Per Bits AI review: the contract accepted "static" fields and
singleton-scoped instance fields without requiring final, so a
mutable field of either shape could pass while still being
reassignable to a fresh, cold instance at runtime -- defeating the
amortization guarantee the annotation exists to protect, just via a
write instead of via scope. Add an explicit mutability trigger and
require final in the Accepted description for both shapes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Fix StaticLifetime's ClassValue paragraph to match its own checker contract
Per review: the intro implied a ClassValue-backed holder need not be
static itself, contradicting the Accepted list below it, which
requires "static final ClassValue<T>". Clarify that it's the
per-Class values ClassValue computes that get a free process-wide
lifetime, not the holder field referencing the ClassValue instance --
that still has to be static final.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/master' into dougqh/static-lifetime-singleton
# Conflicts:
# .agents/skills/perf-review/references/checks.md
Move StaticLifetime/Singleton into datadog.perfcontract and meta-annotate with @PerfContract
Relocates both annotations out of the legacy datadog.trace.api.function
package into the new datadog.perfcontract package (introduced by #12647),
alongside PerfContract/SuppressPerfContract, and adds @PerfContract so
tooling can discover them as perf-contract markers the same way it
already discovers Strategy/StrategyConsumer/NoEscape. No other code
references either annotation, so no import-site updates are needed.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Tighten the @singleton Javadoc
Applies a review suggestion: a static holder or DI registration does not by
itself guarantee a single instance, and only final instance fields satisfy
@Staticlifetime.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restructure the @Staticlifetime Javadoc around one field rule
Applies a review suggestion: a single accepted/violation/out-of-scope rule,
an accurate ClassValue note, and block examples. Keeps the note on the name
echoing Rust's 'static lifetime. Examples use <pre> with escaped @ and generics
so javadoc does not read a leading @ as a block tag.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Require final for @Singleton-held fields in the perf-review StaticLifetime check
Matches the @Staticlifetime and @singleton Javadoc: only a final instance
field on a @singleton class is accepted, and ClassValue holders follow the
plain static final rule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent 14f69f0 commit a2eb6db
3 files changed
Lines changed: 97 additions & 2 deletions
File tree
- .agents/skills/perf-review/references
- internal-api/src/main/java/datadog/perfcontract
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
Lines changed: 68 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
0 commit comments