-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dfc78b4
commit f2f6258
Showing
6 changed files
with
195 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
sample/benchmark/src/main/java/com/datadog/benchmark/sample/BenchmarkApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.benchmark.sample | ||
|
||
import android.app.Application | ||
|
||
internal class BenchmarkApplication : Application() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
// enableDatadogSessionReplay() | ||
} | ||
|
||
/* private fun enableDatadogSessionReplay() { | ||
Datadog.initialize( | ||
this, | ||
createDatadogConfiguration(), | ||
preferences.getTrackingConsent() | ||
) | ||
val rumConfig = createRumConfiguration() | ||
Rum.enable(rumConfig) | ||
val sessionReplayConfig = SessionReplayConfiguration.Builder(SAMPLE_IN_ALL_SESSIONS) | ||
.apply { | ||
if (BuildConfig.DD_OVERRIDE_SESSION_REPLAY_URL.isNotBlank()) { | ||
useCustomEndpoint(BuildConfig.DD_OVERRIDE_SESSION_REPLAY_URL) | ||
} | ||
} | ||
.setPrivacy(SessionReplayPrivacy.MASK_USER_INPUT) | ||
.addExtensionSupport(MaterialExtensionSupport()) | ||
.build() | ||
SessionReplay.enable(sessionReplayConfig) | ||
} | ||
private fun createRumConfiguration(): RumConfiguration { | ||
return RumConfiguration.Builder(BuildConfig.DD_RUM_APPLICATION_ID) | ||
.apply { | ||
if (BuildConfig.DD_OVERRIDE_RUM_URL.isNotBlank()) { | ||
useCustomEndpoint(BuildConfig.DD_OVERRIDE_RUM_URL) | ||
} | ||
} | ||
.useViewTrackingStrategy( | ||
NavigationViewTrackingStrategy( | ||
R.id.nav_host_fragment, | ||
true, | ||
BenchmarkNavigationPredicate() | ||
) | ||
) | ||
.setTelemetrySampleRate(100f) | ||
.trackUserInteractions() | ||
.trackLongTasks(250L) | ||
.trackNonFatalAnrs(true) | ||
.setViewEventMapper(object : ViewEventMapper { | ||
override fun map(event: ViewEvent): ViewEvent { | ||
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true) | ||
return event | ||
} | ||
}) | ||
.setActionEventMapper(object : EventMapper<ActionEvent> { | ||
override fun map(event: ActionEvent): ActionEvent { | ||
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true) | ||
return event | ||
} | ||
}) | ||
.setResourceEventMapper(object : EventMapper<ResourceEvent> { | ||
override fun map(event: ResourceEvent): ResourceEvent { | ||
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true) | ||
return event | ||
} | ||
}) | ||
.setErrorEventMapper(object : EventMapper<ErrorEvent> { | ||
override fun map(event: ErrorEvent): ErrorEvent { | ||
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true) | ||
return event | ||
} | ||
}) | ||
.setLongTaskEventMapper(object : EventMapper<LongTaskEvent> { | ||
override fun map(event: LongTaskEvent): LongTaskEvent { | ||
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true) | ||
return event | ||
} | ||
}) | ||
.build() | ||
} | ||
@SuppressLint("LogNotTimber") | ||
private fun createDatadogConfiguration(): Configuration { | ||
val configBuilder = Configuration.Builder( | ||
clientToken = BuildConfig.DD_CLIENT_TOKEN, | ||
env = BuildConfig.BUILD_TYPE, | ||
variant = BuildConfig.FLAVOR | ||
) | ||
.setFirstPartyHosts(tracedHosts) | ||
.setBatchSize(BatchSize.SMALL) | ||
.setUploadFrequency(UploadFrequency.FREQUENT) | ||
try { | ||
configBuilder.useSite(DatadogSite.valueOf(BuildConfig.DD_SITE_NAME)) | ||
} catch (e: IllegalArgumentException) { | ||
Timber.e("Error setting site to ${BuildConfig.DD_SITE_NAME}") | ||
} | ||
configBuilder.setBackpressureStrategy( | ||
BackPressureStrategy( | ||
32, | ||
{ Log.w("BackPressure", "THRESHOLD REACHED!") }, | ||
{ Log.e("BackPressure", "ITEM DROPPED $it!") }, | ||
BackPressureMitigation.IGNORE_NEWEST | ||
) | ||
) | ||
return configBuilder.build() | ||
}*/ | ||
} |
20 changes: 20 additions & 0 deletions
20
sample/benchmark/src/main/java/com/datadog/benchmark/sample/BenchmarkNavigationPredicate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.benchmark.sample | ||
|
||
import androidx.navigation.NavDestination | ||
import com.datadog.android.rum.tracking.ComponentPredicate | ||
|
||
internal class BenchmarkNavigationPredicate : ComponentPredicate<NavDestination> { | ||
override fun accept(component: NavDestination): Boolean { | ||
return true | ||
} | ||
|
||
override fun getViewName(component: NavDestination): String { | ||
return component.label.toString() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters