Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ambushwork committed Jul 29, 2024
1 parent dfc78b4 commit e03ddb2
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 3 deletions.
28 changes: 28 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,34 @@ test-pyramid:publish-staging-synthetics:
paths:
- sample/kotlin/build/outputs/apk/staging/release/kotlin-staging-release.apk

test-pyramid:publish-benchmark-synthetics:
tags: [ "arch:amd64" ]
image: $CI_IMAGE_DOCKER
stage: test-pyramid
timeout: 1h
only:
- develop
- yl/add-sample-fragments
script:
- mkdir -p ./config/
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.gradle-properties --with-decryption --query "Parameter.Value" --out text >> ./gradle.properties
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.keystore --with-decryption --query "Parameter.Value" --out text | base64 -d > ./sample-benchmark.keystore
- aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.benchmark_config_json --with-decryption --query "Parameter.Value" --out text > ./config/us1.json
- export BM_STORE_PASSWD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.keystore-password --with-decryption --query "Parameter.Value" --out text)
- export BM_DD_API_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.benchmark_api_key --with-decryption --query "Parameter.Value" --out text)
- export BM_DD_APP_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.benchmark_app_key --with-decryption --query "Parameter.Value" --out text)
- export BM_MOBILE_APP_ID=$(aws ssm get-parameter --region us-east-1 --name ci.dd-sdk-android.benchmark_mobile_app_id --with-decryption --query "Parameter.Value" --out text)
- GRADLE_OPTS="-Xmx4096M" ./gradlew assembleLibrariesRelease --stacktrace --no-daemon
- GRADLE_OPTS="-Xmx4096M" ./gradlew :sample:benchmark:packageRelease --stacktrace --no-daemon
- npm update -g @datadog/datadog-ci
- echo "Using datadog-ci $(npx @datadog/datadog-ci version)"
- npx @datadog/datadog-ci synthetics upload-application --appKey "BM_DD_APP_KEY" --apiKey "BM_DD_API_KEY" --mobileApp "sample/benchmark/build/outputs/apk/release/benchmark-release.apk" --mobileApplicationId "BM_MOBILE_APP_ID" --versionName "$CI_COMMIT_SHORT_SHA" --latest
artifacts:
when: always
expire_in: 1 week
paths:
- sample/kotlin/build/outputs/apk/us1/release/benchmark-release.apk

# PUBLISH ARTIFACTS ON MAVEN

publish:release-core:
Expand Down
25 changes: 24 additions & 1 deletion sample/benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {
kotlin("kapt")
}

@Suppress("StringLiteralDuplication")
android {
namespace = "com.datadog.sample.benchmark"
compileSdk = AndroidConfig.TARGET_SDK
Expand All @@ -31,12 +32,31 @@ android {
java17()
}

val bmPassword = System.getenv("BM_STORE_PASSWD")
signingConfigs {
if (bmPassword != null) {
create("release") {
storeFile = File(project.rootDir, "sample-benchmark.keystore")
storePassword = bmPassword
keyAlias = "dd-sdk-android"
keyPassword = bmPassword
}
}
}

buildTypes {
release {
getByName("debug") {
isMinifyEnabled = false
}

getByName("release") {
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt")
)
isMinifyEnabled = false
if (bmPassword != null) {
signingConfig = signingConfigs.getByName("release")
}
}
}
}
Expand All @@ -52,6 +72,9 @@ dependencies {
implementation(libs.androidXConstraintLayout)
implementation(libs.googleMaterial)
implementation(libs.glideCore)
implementation(project(":dd-sdk-android-core"))
implementation(project(":features:dd-sdk-android-session-replay"))
implementation(project(":features:dd-sdk-android-rum"))
}

kotlinConfig()
Expand Down
2 changes: 2 additions & 0 deletions sample/benchmark/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application
android:name="com.datadog.benchmark.sample.BenchmarkApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
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()
}*/
}
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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ import com.google.android.material.datepicker.MaterialDatePicker
import com.google.android.material.timepicker.MaterialTimePicker
import java.util.Locale

class SessionReplayFragment : Fragment() {
internal class SessionReplayFragment : Fragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_session_replay, container, false).apply {

findViewById<CheckedTextView>(R.id.checked_text_view).apply {
setOnClickListener { this.toggle() }
}
Expand Down

0 comments on commit e03ddb2

Please sign in to comment.