-
Notifications
You must be signed in to change notification settings - Fork 64
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
RUMM-407 Use app package name as default service name value #241
RUMM-407 Use app package name as default service name value #241
Conversation
val serviceName: String, | ||
val envName: String | ||
val envName: String, | ||
val serviceName: String? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid changing parameters order, this is a nightmare whenever we have a rebase/merger afterwards.
Also you don't need a default value here, the default will come from the config builder
DEFAULT_ENV_NAME | ||
) | ||
private var tracesConfig: FeatureConfig = FeatureConfig( | ||
clientToken, | ||
applicationId, | ||
DatadogEndpoint.TRACES_US, | ||
DEFAULT_SERVICE_NAME, | ||
DEFAULT_ENV_NAME | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can set the default value here, that way you don't have to switch the order.
@@ -58,7 +58,7 @@ internal object TracesFeature { | |||
|
|||
clientToken = config.clientToken | |||
endpointUrl = config.endpointUrl | |||
serviceName = config.serviceName | |||
serviceName = config.serviceName ?: appContext.packageName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of copy/pasting this logic everywhere, you could define it once and for all in a CoreFeature.serviceName
property, that'll be then used by other features ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was actually thinking the same...but CoreFeature doesn't hold a reference to the FeatureConfig or RumConfig. I would have to actually provide the FeatureConfig as a parameter to that method and because RumFeature has a different config (RumConfig) I will need 2 methods. I am not really sure which approach will be better: having the code duplicated in each feature or having a 2 methods in the CoreFeature :(. Maybe I can think to something else.
091529e
to
d6dbf29
Compare
@@ -56,25 +57,27 @@ internal object CoreFeature { | |||
|
|||
internal var packageName: String = "" | |||
internal var packageVersion: String = "" | |||
private var customServiceName: String? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You didn't save any logic copy. You could do :
internal var serviceName: String = ""
fun initialize(…) {
// …
serviceName = config.serviceName ?: packageName
}
fun stop() {
// …
serviceName = ""
}
Then in all the other XFeature
, remove the XFeature.serviceName
properties and reference this one here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh...yes that would be better, don't know why I didn't think about this. Tks.
fakeEnvName | ||
) | ||
) | ||
} | ||
|
||
@Test | ||
fun `builder with custom service name`( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this test was removed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups.....I lost this during a rebase, I thought I put it back. Good spot.
@@ -250,4 +249,64 @@ internal class CrashReportsFeatureTest { | |||
assertThat(endpointUrl).isSameAs(endpointUrl2) | |||
assertThat(serviceName).isSameAs(serviceName2) | |||
} | |||
|
|||
@Test | |||
fun `will use the custom service name if provided`(forge: Forge) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you follow my suggestion above, you only need to test the service name resolution in the CoreFeatureTest file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But still I want to keep these tests as this will guarantee that the serviceName will be set in these features and their default value will be the one from the CoreFeature
d6dbf29
to
e531236
Compare
fun resolveServiceName(): String { | ||
return serviceName ?: packageName | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can delete this one, it's not used anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup..again forgot, damn it.
2f209f7
to
e3eb2dd
Compare
e3eb2dd
to
3aa9f31
Compare
What does this PR do?
A brief description of the change being made with this pull request.
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)