Commit 7e9c2b8
Make Telemetry Tags Immutable (opensearch-project#20788)
Replace the mutable HashMap-backed Tags with an immutable design using
sorted parallel arrays and a precomputed hashCode. Adds allocation-efficient
factories (Tags.of, Tags.concat, Tags.fromMap, Tags.toMap), an EMPTY
singleton, and content-based equals/hashCode so Tags can be safely used as
map keys, stored in fields, and shared across threads.
Deprecated API (create(), addTag()) preserved for backward compatibility;
addTag() now returns a new instance instead of mutating in place. Fixes
AutoForceMergeMetrics which called addTag() without reassigning the return
value -- a silent no-op now that Tags is immutable.
---------
Signed-off-by: Sam Akrah <sakrah@uber.com>
Co-authored-by: Sam Akrah <sakrah@uber.com>1 parent 3bf2a27 commit 7e9c2b8
File tree
5 files changed
+632
-46
lines changed- libs/telemetry/src
- main/java/org/opensearch/telemetry/metrics/tags
- test/java/org/opensearch/telemetry/metrics/tags
- server/src/main/java/org/opensearch/index/autoforcemerge
- test/telemetry/src/main/java/org/opensearch/test/telemetry
5 files changed
+632
-46
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
0 commit comments