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

Added new Logger implementation #1113

Merged
merged 9 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,14 @@ android {
testInstrumentationRunnerArguments.put("clearPackageData", "true")
}

signingConfigs {
create("release") {
storeFile = project.file("keystore.jks")
storePassword = "${project.findProperty("splunk_test_app_store_password")}"
keyAlias = "${project.findProperty("splunk_test_app_key_alias")}"
keyPassword = "${project.findProperty("splunk_test_app_key_password")}"
}
}

buildTypes {
getByName("debug") {
resValue("bool", "leak_canary_add_launcher_icon", "false")
signingConfig = signingConfigs.getByName("release")
val ip = InetAddress.getLocalHost().hostAddress
buildConfigField("String", "IP_ADDRESS", "\"$ip\"")
}
getByName("release") {
isMinifyEnabled = true
signingConfig = signingConfigs.getByName("release")
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
Expand All @@ -57,11 +46,6 @@ android {

buildFeatures {
viewBinding = true
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = Dependencies.Android.Compose.compilerVersion
}

packagingOptions {
Expand Down Expand Up @@ -92,30 +76,14 @@ dependencies {
implementation(Dependencies.Android.constraintLayout)
implementation(Dependencies.Android.activityKtx)
implementation(Dependencies.Android.fragmentKtx)

/**
* Play services basement must be explicitly included since a newer version is being enforced than what is transitively used by play services maps.
*/
implementation(Dependencies.Android.playServicesMap)
implementation(Dependencies.Android.playServicesBasement)

implementation(Dependencies.Android.cardView)
implementation(Dependencies.Android.material)

implementation(Dependencies.Android.Compose.activity)
implementation(Dependencies.Android.Compose.ui)
implementation(Dependencies.Android.Compose.material)
implementation(Dependencies.Android.Compose.animation)
implementation(Dependencies.Android.Compose.materialIconsExtended)
implementation(Dependencies.Android.Compose.toolingPreview)

/**
* Okio must be explicitly included since a newer version is being enforced than what is transitively used by OkHttp.
*/
implementation(Dependencies.okhttp)
implementation(Dependencies.okio)

debugImplementation(Dependencies.Android.Compose.uiTooling)
debugImplementation(Dependencies.AndroidDebug.leakCanary)

/**
Expand Down Expand Up @@ -152,15 +120,10 @@ dependencies {

androidTestUtil(Dependencies.AndroidTest.testOrchestrator)

implementation(Dependencies.Android.cameraLifecycle)
implementation(Dependencies.Android.cameraExtensions)
implementation(Dependencies.Android.cameraView)

/**
* Explicit version of guava jre must be forced because ext truth uses one with vulnerabilities.
*/
implementation(Dependencies.guavaAndroid)
implementation(Dependencies.Android.exoPlayer)
}

tasks.register<Exec>("startOtelCollectorForTests") {
Expand Down
Binary file removed app/keystore.jks
Binary file not shown.
3 changes: 1 addition & 2 deletions app/src/androidTest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Then start running the test you want.
The Setup only includes Otel collector and Zipkin for now.

# End-to-End Flow
The End-to-End flow is just a flow to generate data for end-to-end tests. There will be a separate
Playwright based project [here](https://bitbucket.corp.appdynamics.com/projects/MRUM_AC/repos/mrum-e2e-tests/browse) to verify the DashUI view relating to the test data.
The End-to-End flow is just a flow to generate data for end-to-end tests.

More on that later.
25 changes: 1 addition & 24 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@ buildscript {
repositories {
mavenCentral()
google()

maven {
url = uri("$projectDir/gradle-plugin/obfuscation-director/repository")
}

maven {
url = uri("$projectDir/gradle-plugin/documentation-extractor/repository")
}
}

dependencies {
classpath(Dependencies.gradle)
classpath(Dependencies.gradleApi)
classpath(Dependencies.buildInfoExtractorGradle)
classpath(Dependencies.kotlin)
}
Expand All @@ -29,21 +20,7 @@ allprojects {
google()

maven {
setUrl(Configurations.Artifactory.repositoryURL)

/**
* Create a file gradle.properties in the GRADLE_USER_HOME directory.
* By default this is in the USER_HOME/.gradle directory.
* Insert following lines into gradle.properties:
* sl_artifactory_token = <token>
*/
credentials(HttpHeaderCredentials::class) {
name = "Authorization"
value = "Bearer ${project.findProperty("sl_artifactory_token")}"
}
authentication {
create<HttpHeaderAuthentication>("header")
}
setUrl("https://sdk.smartlook.com/android/release")
}
}
}
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/Configurations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ object Configurations {

object Artifactory {
const val bareRepositoryURL = "https://artifactory.bare.appdynamics.com/artifactory/maven-releases/"
const val repositoryURL = "https://artifactory.ci.smartlook.cloud/artifactory/libs-release-local"
}

const val sdkVersionCode = 1
Expand Down
41 changes: 5 additions & 36 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,61 +64,30 @@ object Dependencies {

object Android {

/**
* Play services maps 18.2.0 is the latest version.
* This version includes services basement transitively with vulnerabilities, we explicitly set the services basement version to a safer one.
*/
private const val playServicesMapVersion = "18.2.0"
private const val playServiceBasementVersion = "18.1.0"

private const val annotationVersion = "1.6.0"
private const val appcompatVersion = "1.6.1"
private const val multidexVersion = "2.0.1"
private const val recyclerVersion = "1.2.1"
private const val cardVersion = "1.0.0"
private const val materialVersion = "1.9.0"

const val annotation = "androidx.annotation:annotation:$annotationVersion"
const val appcompat = "androidx.appcompat:appcompat:$appcompatVersion"
const val playServicesMap = "com.google.android.gms:play-services-maps:$playServicesMapVersion"
const val playServicesBasement = "com.google.android.gms:play-services-basement:$playServiceBasementVersion"
const val multidex = "androidx.multidex:multidex:$multidexVersion"
const val recycler = "androidx.recyclerview:recyclerview:$recyclerVersion"
const val cardView = "androidx.cardview:cardview:$cardVersion"
const val material = "com.google.android.material:material:$materialVersion"

// Test application

private const val constraintLayoutVersion = "2.1.4"
private const val activityKtxVersion = "1.2.2"
private const val fragmentKtxVersion = "1.3.3"
private const val fragmentVersion = "1.3.3"
private const val cameraVersion = "1.2.0"
private const val exoPlayerVersion = "2.19.1"

const val constraintLayout = "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
const val activityKtx = "androidx.activity:activity-ktx:$activityKtxVersion"
const val fragmentKtx = "androidx.fragment:fragment-ktx:$fragmentKtxVersion"
const val fragment = "androidx.fragment:fragment:$fragmentVersion"
const val cameraLifecycle = "androidx.camera:camera-lifecycle:$cameraVersion"
const val cameraExtensions = "androidx.camera:camera-extensions:$cameraVersion"
const val cameraView = "androidx.camera:camera-view:$cameraVersion"
const val exoPlayer = "com.google.android.exoplayer:exoplayer:$exoPlayerVersion"

object Compose { // FIXME Update when fix obfuscation-director compatibility with Kotlin 1.8.0+
private const val version = "1.2.1"
private const val materialVersion = "1.2.1"
private const val activityVersion = "1.3.1"

const val compilerVersion = "1.3.2"

const val activity = "androidx.activity:activity-compose:$activityVersion"
const val ui = "androidx.compose.ui:ui:$version"
const val uiTooling = "androidx.compose.ui:ui-tooling:$version"
const val toolingPreview = "androidx.compose.ui:ui-tooling-preview:$version"
const val material = "androidx.compose.material:material:$materialVersion"
const val materialIconsExtended = "androidx.compose.material:material-icons-extended:$materialVersion"
const val animation = "androidx.compose.animation:animation:$version"

object SessionReplay {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Should we name it to a generic word like "common" instead of "SessionReplay"?

Copy link
Author

Choose a reason for hiding this comment

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

No, because it is part of session replay "package" and all modules must have the same version.

private const val version = "1.0.10"

const val logger = "com.cisco.android:sr-common-logger:$version"
}
}

Expand Down
1 change: 0 additions & 1 deletion common/id/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ android {
}

dependencies {
implementation(project(":common:logger"))
}
3 changes: 2 additions & 1 deletion common/job/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ android {
}

dependencies {
implementation(project(":common:logger"))
implementation(project(":common:utils"))
implementation(project(":common:storage"))

implementation(Dependencies.Android.SessionReplay.logger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import android.annotation.SuppressLint
import android.app.job.JobScheduler
import android.content.Context
import android.os.Build
import com.smartlook.sdk.log.LogAspect
import com.smartlook.sdk.common.logger.Logger
import com.cisco.android.common.logger.Logger

/**
* Takes care of scheduling the rests to send them only if they meet certain conditions.
Expand All @@ -16,19 +15,19 @@ class JobManager(private val context: Context) : IJobManager {
private val jobScheduler: JobScheduler by lazy { context.getSystemService(Context.JOB_SCHEDULER_SERVICE) as JobScheduler }

override fun scheduleJob(jobType: JobType) {
Logger.privateD(LogAspect.JOB, TAG, { "scheduleJob()" })
Logger.d(TAG, "scheduleJob()")
val jobInfo = jobType.createJobInfo(context = context)
try {
if (jobType.canSchedule(jobScheduler.allPendingJobs.size)) {
val result = jobScheduler.schedule(jobInfo)
if (result == JobScheduler.RESULT_FAILURE) {
Logger.privateD(LogAspect.JOB, TAG, { "scheduleJob(): job was not scheduled, failure" })
Logger.d(TAG, "scheduleJob(): job was not scheduled, failure")
}
} else {
Logger.privateD(LogAspect.JOB, TAG, { "scheduleJob(): job was not scheduled, limit was reached" })
Logger.d(TAG, "scheduleJob(): job was not scheduled, limit was reached")
}
} catch (exception: Exception) {
Logger.privateD(LogAspect.JOB, TAG, { "scheduleJob(): job was not scheduled, limit was reached" })
Logger.d(TAG, "scheduleJob(): job was not scheduled, limit was reached")
}
}

Expand Down Expand Up @@ -58,7 +57,7 @@ class JobManager(private val context: Context) : IJobManager {
private var instance: IJobManager? = null

fun attach(context: Context): IJobManager {
Logger.privateV(LogAspect.JOB, TAG, { "attach(): JobManager attached." })
Logger.v(TAG, "attach(): JobManager attached.")
return instance ?: JobManager(context).also { instance = it }
}
}
Expand Down
3 changes: 2 additions & 1 deletion common/otel/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ dependencies {
implementation(project(":common:job"))
implementation(project(":common:http"))
implementation(project(":common:storage"))
implementation(project(":common:logger"))
implementation(project(":common:utils"))

api(Dependencies.Otel.sdk)
Expand All @@ -41,4 +40,6 @@ dependencies {
exclude(group = "com.squareup.okhttp3", module = "okhttp")
}
api(Dependencies.Otel.semConv)

implementation(Dependencies.Android.SessionReplay.logger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@

package com.cisco.mrum.common.otel.api.internal

import com.cisco.android.common.logger.Logger
import com.cisco.mrum.common.otel.api.logRecord.UploadOtelLogRecordData
import com.cisco.mrum.common.otel.api.span.UploadOtelSpanData
import com.smartlook.sdk.common.job.IJobManager
import com.smartlook.sdk.common.job.JobIdStorage
import com.smartlook.sdk.common.logger.Logger
import com.smartlook.sdk.common.storage.IStorage
import com.smartlook.sdk.common.utils.extensions.safeSubmit
import com.smartlook.sdk.log.LogAspect
import com.cisco.mrum.common.otel.api.logRecord.UploadOtelLogRecordData
import com.cisco.mrum.common.otel.api.span.UploadOtelSpanData
import java.util.concurrent.Executors
import java.util.concurrent.atomic.AtomicBoolean

Expand All @@ -38,12 +37,12 @@ internal class OfflineOtelDataProcessor(

fun start() {
executor.safeSubmit {
Logger.d(LogAspect.SDK_METHODS, TAG) { "start(): called" }
Logger.d(TAG, "start(): called")

if (!loadedLocalData.getAndSet(true)) {
startProcessingLocalData()
} else {
Logger.d(LogAspect.SDK_METHODS, TAG) { "start(): already called! Not doing anything." }
Logger.d(TAG, "start(): already called! Not doing anything.")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ import android.app.job.JobService
import android.content.ComponentName
import android.content.Context
import android.os.PersistableBundle
import com.cisco.android.common.logger.Logger
import com.cisco.mrum.common.otel.internal.storage.OtelStorage
import com.smartlook.android.common.http.HttpClient
import com.smartlook.android.common.http.model.Header
import com.smartlook.android.common.http.model.Response
import com.smartlook.sdk.common.job.JobIdStorage
import com.smartlook.sdk.common.logger.Logger
import com.smartlook.sdk.common.storage.Storage
import com.smartlook.sdk.log.LogAspect
import java.net.UnknownHostException

@SuppressLint("NewApi")
Expand All @@ -42,24 +41,24 @@ internal class UploadOtelLogRecordDataJob : JobService() {
private val otelStorage by lazy { OtelStorage.obtainInstance(storage.preferences) }

override fun onStopJob(params: JobParameters?): Boolean {
Logger.privateD(LogAspect.JOB, TAG, { "onStopJob()" })
Logger.d(TAG, "onStopJob()")
return true
}

override fun onStartJob(params: JobParameters?): Boolean {
Logger.privateD(LogAspect.JOB, TAG, { "onStartJob()" })
Logger.d(TAG, "onStartJob()")
startUpload(params)
return true
}

private fun startUpload(params: JobParameters?) {
params?.extras?.getString(DATA_SERIALIZE_KEY)?.let { id ->
Logger.privateD(LogAspect.JOB, TAG, { "startUpload() id: $id" })
Logger.d(TAG, "startUpload() id: $id")

val url = otelStorage.readBaseUrl()?.let { "$it/eum/v1/logs" }

if (url == null) {
Logger.privateD(LogAspect.JOB, TAG, { "startUpload() url is not valid" })
Logger.d(TAG, "startUpload() url is not valid")
jobFinished(params, false)
return
}
Expand All @@ -71,7 +70,7 @@ internal class UploadOtelLogRecordDataJob : JobService() {
body = storage.getOtelLogDataFile(id),
callback = object : HttpClient.Callback {
override fun onSuccess(response: Response) {
Logger.privateD(LogAspect.JOB, TAG, { "startUpload() onSuccess: response=$response, code=${response.code}, body=${response.body.toString(Charsets.UTF_8)}" })
Logger.d(TAG, "startUpload() onSuccess: response=$response, code=${response.code}, body=${response.body.toString(Charsets.UTF_8)}")
deleteData(id)
if (response.isSuccessful) {
jobFinished(params, false)
Expand All @@ -82,7 +81,7 @@ internal class UploadOtelLogRecordDataJob : JobService() {
}

override fun onFailed(e: Exception) {
Logger.privateD(LogAspect.JOB, TAG, { "startUpload() onFailed: e=$e" })
Logger.d(TAG, "startUpload() onFailed: e=$e")
when (e) {
is UnknownHostException -> jobFinished(params, true)
else -> {
Expand Down
Loading
Loading