Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor how Embrace attributes are defined #526

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

bidetofevil
Copy link
Collaborator

@bidetofevil bidetofevil commented Mar 8, 2024

Goal

Create an abstraction for an Embrace Attribute and define a sealed class for each attribute and an implementation of that class for each valid value.

I converted two attributes just to get some feedback as to whether this is a good idea/implementation. If it looks good, I can convert EmbType/TelemetryType to this format as well.

The goal is to be able to use these class when validating values in tests, and also when we write out the property to OTel objects, instead of having to hardcode rules like putting emb. in front of attribute names, etc.

If this looks good, I'll add convenience methods to internal objects and tests to simply the code that words with Embrace attributes, so you can do something like span.setEmbraceAttribute(ErrorCode.Failure)

Testing

Existing tests cover the usage, but unit tests should be added to test the abstract classes if this is deemed a good way to go.

@@ -375,12 +375,10 @@ public final class io/embrace/android/embracesdk/spans/EmbraceSpanEventJsonAdapt
public fun toString ()Ljava/lang/String;
}

public final class io/embrace/android/embracesdk/spans/ErrorCode : java/lang/Enum, io/embrace/android/embracesdk/internal/spans/EmbraceAttributes$Attribute {
public final class io/embrace/android/embracesdk/spans/ErrorCode : java/lang/Enum {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is marked as @BetaApi so I think this change is OK, especially given that customers shouldn't be using those methods anyway.

@bidetofevil bidetofevil force-pushed the hho/remove-embraceattributes-type branch from d699687 to a70cb16 Compare March 8, 2024 06:50
@bidetofevil bidetofevil force-pushed the hho/refactor-embrace-attribute branch from bb0352f to c77be02 Compare March 8, 2024 06:50
Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

codecov bot commented Mar 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.59%. Comparing base (5e18d90) to head (92e8c37).
Report is 15 commits behind head on master.

❗ Current head 92e8c37 differs from pull request most recent head 61848e4. Consider uploading reports for the commit 61848e4 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #526      +/-   ##
==========================================
+ Coverage   79.45%   79.59%   +0.14%     
==========================================
  Files         403      406       +3     
  Lines       10861    10867       +6     
  Branches     1602     1601       -1     
==========================================
+ Hits         8630     8650      +20     
+ Misses       1585     1575      -10     
+ Partials      646      642       -4     
Files Coverage Δ
...roid/embracesdk/arch/schema/AppTerminationCause.kt 100.00% <100.00%> (ø)
...android/embracesdk/arch/schema/EmbraceAttribute.kt 100.00% <100.00%> (ø)
...droid/embracesdk/arch/schema/ErrorCodeAttribute.kt 100.00% <100.00%> (ø)
...id/embracesdk/internal/spans/CurrentSessionSpan.kt 100.00% <100.00%> (ø)
...mbracesdk/internal/spans/CurrentSessionSpanImpl.kt 90.69% <100.00%> (ø)
...oid/embracesdk/internal/spans/EmbraceExtensions.kt 93.10% <100.00%> (+0.79%) ⬆️
...id/embracesdk/internal/spans/EmbraceSpanService.kt 94.28% <ø> (ø)
...e/android/embracesdk/internal/spans/SpanService.kt 96.29% <100.00%> (ø)
...droid/embracesdk/internal/spans/SpanServiceImpl.kt 100.00% <ø> (ø)
...esdk/internal/spans/UninitializedSdkSpanService.kt 76.66% <100.00%> (ø)
... and 2 more

... and 7 files with indirect coverage changes

Copy link
Collaborator Author

bidetofevil commented Mar 11, 2024

Merge activity

  • Mar 11, 11:26 AM EDT: @bidetofevil started a stack merge that includes this pull request via Graphite.
  • Mar 11, 11:29 AM EDT: Graphite rebased this pull request as part of a merge.
  • Mar 11, 11:30 AM EDT: @bidetofevil merged this pull request with Graphite.

@bidetofevil bidetofevil force-pushed the hho/remove-embraceattributes-type branch from 76865c0 to e3c84d8 Compare March 11, 2024 15:27
Base automatically changed from hho/remove-embraceattributes-type to master March 11, 2024 15:28
@bidetofevil bidetofevil force-pushed the hho/refactor-embrace-attribute branch from 92e8c37 to 61848e4 Compare March 11, 2024 15:29
@bidetofevil bidetofevil merged commit 11625ab into master Mar 11, 2024
2 of 3 checks passed
@bidetofevil bidetofevil deleted the hho/refactor-embrace-attribute branch March 11, 2024 15:30
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.

None yet

2 participants