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

Extract emb.type to separate source file #518

Merged
merged 1 commit into from
Mar 7, 2024
Merged

Conversation

fractalwrench
Copy link
Contributor

@fractalwrench fractalwrench commented Mar 7, 2024

Goal

Extracts the possible values for emb.type into a separate source file. I have organised these as enums implementing a common interface to get a bit of type safety rather than throwing strings around everywhere.

#519 also takes this further with a POC for the rest of the strings.

Copy link

codecov bot commented Mar 7, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 79.33%. Comparing base (34f961a) to head (1644d1b).

❗ Current head 1644d1b differs from pull request most recent head b4d2c94. Consider uploading reports for the commit b4d2c94 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #518      +/-   ##
==========================================
+ Coverage   79.29%   79.33%   +0.03%     
==========================================
  Files         390      391       +1     
  Lines       10752    10761       +9     
  Branches     1599     1599              
==========================================
+ Hits         8526     8537      +11     
+ Misses       1580     1578       -2     
  Partials      646      646              
Files Coverage Δ
...ndroid/embracesdk/capture/aei/AeiDataSourceImpl.kt 79.31% <100.00%> (ø)
...cesdk/capture/crumbs/CustomBreadcrumbDataSource.kt 93.75% <100.00%> (ø)
...sdk/capture/crumbs/FragmentBreadcrumbDataSource.kt 66.66% <100.00%> (ø)
...roid/embracesdk/internal/logs/EmbraceLogService.kt 91.89% <100.00%> (ø)
...ndroid/embracesdk/arch/destination/LogEventData.kt 60.00% <0.00%> (ø)
...droid/embracesdk/arch/destination/SpanEventData.kt 60.00% <0.00%> (ø)
...droid/embracesdk/arch/destination/StartSpanData.kt 40.00% <0.00%> (ø)
.../embrace/android/embracesdk/arch/schema/EmbType.kt 88.88% <88.88%> (ø)

... and 1 file with indirect coverage changes

@@ -0,0 +1,38 @@
package io.embrace.android.embracesdk.arch.schema

internal object EmbType {
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't be better to use a Sealed Class in case we need to evaluate the type at some point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good point. I was focused on not being able to extend enum classes in Kotlin but forgot sealed classes are an option here. I'll update the PR

/**
* Keys that track how fast a time interval is. Only applies to spans.
*/
internal enum class Performance : TelemetryType
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't have types and description here... I assume it's going to be added later.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are no subtypes now so this is probably fine until we do

Copy link
Contributor

@lucaslabari lucaslabari left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -0,0 +1,38 @@
package io.embrace.android.embracesdk.arch.schema

internal object EmbType {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We want the name to be lower-case in the payload - I can't find a way to override name, so I used typeName before. Is there a way to do that so the default enum name would just work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I follow. This class doesn't serialize/deserialize JSON, it just holds data that is passed to other classes that do.

Copy link
Collaborator

@bidetofevil bidetofevil left a comment

Choose a reason for hiding this comment

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

Looks good. I can refactor EmbraceAttributes.Type to refer to this when it's in

@fractalwrench fractalwrench merged commit a21263c into master Mar 7, 2024
2 checks passed
@fractalwrench fractalwrench deleted the extract-type-names branch March 7, 2024 16:16
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

3 participants