From 9ee448a757f2fa15608fd7397a41feb5f59c0ff2 Mon Sep 17 00:00:00 2001 From: Douglas Q Hawkins Date: Thu, 16 Jul 2026 15:06:37 -0400 Subject: [PATCH] Deprecate TagMap.create(int) -- size is ignored create(int) ignores its size (returns new OptimizedTagMap()); TagMap's storage can't honor a size hint without compromising its other optimizations. Mark it @Deprecated pointing at create(), and migrate the two TagMap-internal callers (fromMap, Ledger.build) off it. The external callers (CoreTracer, DDSpanContext, TagContext) are left -- their deprecation warnings flag the sites a future dedicated sizing mechanism will convert (DDSpanContext especially). Co-Authored-By: Claude Opus 4.8 --- .../src/main/java/datadog/trace/api/TagMap.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal-api/src/main/java/datadog/trace/api/TagMap.java b/internal-api/src/main/java/datadog/trace/api/TagMap.java index 1610cb3a5f2..1c66bef8075 100644 --- a/internal-api/src/main/java/datadog/trace/api/TagMap.java +++ b/internal-api/src/main/java/datadog/trace/api/TagMap.java @@ -50,7 +50,7 @@ public interface TagMap extends Map, Iterablemap */ static TagMap fromMap(Map map) { - TagMap tagMap = TagMap.create(map.size()); + TagMap tagMap = TagMap.create(); tagMap.putAll(map); return tagMap; } @@ -68,6 +68,12 @@ static TagMap create() { return new OptimizedTagMap(); } + /** + * @deprecated {@code size} is ignored -- TagMap's storage can't honor a size hint without + * compromising its other optimizations, so this behaves identically to {@link #create()}; + * prefer that. A dedicated sizing mechanism may be introduced separately. + */ + @Deprecated static TagMap create(int size) { return new OptimizedTagMap(); } @@ -1114,7 +1120,7 @@ public Iterator iterator() { } public TagMap build() { - TagMap map = TagMap.create(this.estimateSize()); + TagMap map = TagMap.create(); fill(map); return map; }