Skip to content

Do not count attribute overwrites as dropped attributes in AttributesMap - #8833

Merged
jack-berg merged 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/attributes-map-overwrite-not-counted-as-dropped
Sep 24, 2026
Merged

jack-berg merged 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/attributes-map-overwrite-not-counted-as-dropped

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Fixes #8832

Description

  • AttributesMap.put() incremented totalAddedValues even when overwriting an existing key. getTotalAttributeCount() exposes that counter and the OTLP marshalers emit total - size as dropped_attributes_count, so setting the same key twice produced dropped_attributes_count=1 below the limit.
  • Move the increment into the new-name branch so only inserts and capacity drops are counted.
  • Matches the spec (only limit-exceeded attributes may be discarded), the proto comment (0 means nothing dropped), and opentelemetry-go/opentelemetry-python, which do not count overwrites as drops. Log records and recordException events share the class and are corrected too.
  • SdkSpanBuilderTest.setAllAttributes_mergesAttributes expectation 8 -> 6: three builder attributes plus five merged (two overlapping names) are six unique names below the limit; the old 8 counted the two overwrites as drops (Add Span#setAttributes method to add Attributes to a Span #2799 did not discuss the number).

Testing done

  • Added AttributesMapTest#put_overwriteDoesNotIncrementTotalAddedValues and a getTotalAddedValues() assertion in putSameKeyDifferentType_doesNotConsumeExtraCapacity; both fail without the fix.
  • Added SdkSpanTest#overwritingAttribute_doesNotCountAsDropped.
  • ./gradlew :sdk:common:check :sdk:trace:check pass; :sdk:logs:test and :exporters:otlp:common:test pass. No apidiff change (internal package).

@thswlsqls
thswlsqls marked this pull request as ready for review September 18, 2026 01:09
@thswlsqls
thswlsqls requested a review from a team as a code owner September 18, 2026 01:09
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-09-24 20:22 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.38%. Comparing base (509182e) to head (5a5b9c7).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8833      +/-   ##
============================================
+ Coverage     91.34%   91.38%   +0.03%     
- Complexity    10652    10657       +5     
============================================
  Files          1010     1010              
  Lines         28696    28697       +1     
  Branches       3682     3683       +1     
============================================
+ Hits          26212    26224      +12     
+ Misses         1683     1671      -12     
- Partials        801      802       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jack-berg
jack-berg merged commit 7f3111b into open-telemetry:main Sep 24, 2026
55 of 57 checks passed
@otelbot

otelbot Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @thswlsqls! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributesMap counts attribute overwrites as dropped attributes

2 participants