Skip to content

Conversation

@fractalwrench
Copy link
Member

Goal

Converts AttributeModifyingSpanExporter to Kotlin and refactors the test to avoid unnecessary mocks.

As part of this change I did alter the signature so that a single function is responsible for modifying attribute values by checking the passed in key matches.

@fractalwrench fractalwrench requested a review from a team as a code owner October 23, 2025 11:16
@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.13%. Comparing base (8c456b0) to head (c57b7eb).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
...y/android/export/AttributeModifyingSpanExporter.kt 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1334      +/-   ##
==========================================
+ Coverage   64.06%   64.13%   +0.07%     
==========================================
  Files         154      153       -1     
  Lines        3108     3056      -52     
  Branches      316      313       -3     
==========================================
- Hits         1991     1960      -31     
+ Misses       1028     1007      -21     
  Partials       89       89              

☔ View full report in Codecov by Sentry.
📢 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.

*/
class AttributeModifyingSpanExporter(
private val delegate: SpanExporter,
private val spanAttributeReplacements: (key: AttributeKey<*>, value: Any?) -> Any?,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we create an interface instead? i find it friendlier than a function def.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this to use a typealias for readability

@fractalwrench fractalwrench force-pushed the convert-attr-modifying branch from eef9b2e to c57b7eb Compare October 24, 2025 13:34
Comment on lines +143 to +144
} else {
return value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Prefer omitting the redundant else (and yeah, if it was kotlin it would be even cleaner to return from the if I suppose).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how this else is redundant as the lambda requires a return statement if function is null. Have I missed some syntax that would simplify this in Java?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think he's talking about writing it like this:

if (function != null) {
   return function.apply(value);
}
return value;

Maybe it sounded like omitting the "whole else", which might be confusing.

Copy link
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment, but LGTM. Thanks!

Copy link
Contributor

@LikeTheSalad LikeTheSalad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers!

Comment on lines +143 to +144
} else {
return value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think he's talking about writing it like this:

if (function != null) {
   return function.apply(value);
}
return value;

Maybe it sounded like omitting the "whole else", which might be confusing.

@breedx-splk breedx-splk merged commit ae7738c into open-telemetry:main Oct 29, 2025
8 checks passed
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.

4 participants