-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Installing AndroidInstrumentations * Validating installing instrumentations * Clean up * Improving test name * Removing common module * Renaming android-agent to core * Making instrumentations into services * Created android-agent module * Adding OtelRumConfig extensions * Updating agent description * Reverting core namespace change * Moving RumConstants to common package * Adding auto service annotations as implementation to avoid R8 complains
- Loading branch information
1 parent
5f6a0d0
commit 461bf86
Showing
140 changed files
with
329 additions
and
226 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
80 changes: 80 additions & 0 deletions
80
android-agent/src/main/kotlin/io/opentelemetry/android/agent/OtelRumConfigExtensions.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,80 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.android.agent | ||
|
||
import io.opentelemetry.android.config.OtelRumConfig | ||
import io.opentelemetry.android.instrumentation.AndroidInstrumentationRegistry | ||
import io.opentelemetry.android.instrumentation.activity.ActivityLifecycleInstrumentation | ||
import io.opentelemetry.android.instrumentation.anr.AnrInstrumentation | ||
import io.opentelemetry.android.instrumentation.common.ScreenNameExtractor | ||
import io.opentelemetry.android.instrumentation.crash.CrashDetails | ||
import io.opentelemetry.android.instrumentation.crash.CrashReporterInstrumentation | ||
import io.opentelemetry.android.instrumentation.fragment.FragmentLifecycleInstrumentation | ||
import io.opentelemetry.android.instrumentation.network.NetworkChangeInstrumentation | ||
import io.opentelemetry.android.instrumentation.slowrendering.SlowRenderingInstrumentation | ||
import io.opentelemetry.android.internal.services.network.data.CurrentNetwork | ||
import io.opentelemetry.api.trace.Tracer | ||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor | ||
import java.time.Duration | ||
|
||
/** | ||
* Convenience functions to allow configuring the default instrumentations through the [OtelRumConfig] object, for example: | ||
* | ||
* ``` | ||
* OtelRumConfig() | ||
* .setSessionTimeout(Duration.ofSeconds(10)) // Real OtelRumConfig function | ||
* .setSlowRenderingDetectionPollInterval(Duration.ofSeconds(5)) // Extension function | ||
* .disableScreenAttributes() // Real OtelRumConfig function | ||
* ``` | ||
*/ | ||
|
||
fun OtelRumConfig.setActivityTracerCustomizer(customizer: (Tracer) -> Tracer): OtelRumConfig { | ||
AndroidInstrumentationRegistry.get().get(ActivityLifecycleInstrumentation::class.java) | ||
?.setTracerCustomizer(customizer) | ||
return this | ||
} | ||
|
||
fun OtelRumConfig.setActivityNameExtractor(screenNameExtractor: ScreenNameExtractor): OtelRumConfig { | ||
AndroidInstrumentationRegistry.get().get(ActivityLifecycleInstrumentation::class.java) | ||
?.setScreenNameExtractor(screenNameExtractor) | ||
return this | ||
} | ||
|
||
fun OtelRumConfig.setFragmentTracerCustomizer(customizer: (Tracer) -> Tracer): OtelRumConfig { | ||
AndroidInstrumentationRegistry.get().get(FragmentLifecycleInstrumentation::class.java) | ||
?.setTracerCustomizer(customizer) | ||
return this | ||
} | ||
|
||
fun OtelRumConfig.setFragmentNameExtractor(screenNameExtractor: ScreenNameExtractor): OtelRumConfig { | ||
AndroidInstrumentationRegistry.get().get(FragmentLifecycleInstrumentation::class.java) | ||
?.setScreenNameExtractor(screenNameExtractor) | ||
return this | ||
} | ||
|
||
fun OtelRumConfig.addAnrAttributesExtractor(extractor: AttributesExtractor<Array<StackTraceElement>, Void>): OtelRumConfig { | ||
AndroidInstrumentationRegistry.get().get(AnrInstrumentation::class.java) | ||
?.addAttributesExtractor(extractor) | ||
return this | ||
} | ||
|
||
fun OtelRumConfig.addCrashAttributesExtractor(extractor: AttributesExtractor<CrashDetails, Void>): OtelRumConfig { | ||
AndroidInstrumentationRegistry.get().get(CrashReporterInstrumentation::class.java) | ||
?.addAttributesExtractor(extractor) | ||
return this | ||
} | ||
|
||
fun OtelRumConfig.addNetworkChangeAttributesExtractor(extractor: AttributesExtractor<CurrentNetwork, Void>): OtelRumConfig { | ||
AndroidInstrumentationRegistry.get().get(NetworkChangeInstrumentation::class.java) | ||
?.addAttributesExtractor(extractor) | ||
return this | ||
} | ||
|
||
fun OtelRumConfig.setSlowRenderingDetectionPollInterval(interval: Duration): OtelRumConfig { | ||
AndroidInstrumentationRegistry.get().get(SlowRenderingInstrumentation::class.java) | ||
?.setSlowRenderingDetectionPollInterval(interval) | ||
return this | ||
} |
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 was deleted.
Oops, something went wrong.
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,84 @@ | ||
plugins { | ||
id("otel.android-library-conventions") | ||
id("otel.publish-conventions") | ||
} | ||
|
||
android { | ||
namespace = "io.opentelemetry.android" | ||
|
||
buildToolsVersion = "34.0.0" | ||
|
||
defaultConfig { | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
buildConfigField("String", "OTEL_ANDROID_VERSION", "\"$version\"") | ||
} | ||
|
||
buildTypes { | ||
all { | ||
resValue("string", "rum.version", "${project.version}") | ||
} | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro", | ||
) | ||
} | ||
} | ||
|
||
androidComponents { | ||
onVariants { | ||
if (it.buildType == "release") { // The one we choose to release | ||
project.tasks.register("createReleaseBuild", Copy::class) { | ||
from(it.artifacts.get(com.android.build.api.artifact.SingleArtifact.AAR)) | ||
into(project.layout.buildDirectory.dir("outputs/aar")) | ||
rename(".+", "opentelemetry-android.aar") | ||
} | ||
} | ||
} | ||
} | ||
|
||
project.afterEvaluate { | ||
tasks.named("assembleRelease") { | ||
finalizedBy("createReleaseBuild") | ||
} | ||
} | ||
|
||
testOptions { | ||
unitTests.isReturnDefaultValues = true | ||
unitTests.isIncludeAndroidResources = true | ||
} | ||
|
||
buildFeatures { | ||
buildConfig = true | ||
} | ||
|
||
sourceSets { | ||
getByName("test") { | ||
kotlin.srcDirs("src/integrationTest/kotlin") | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(libs.androidx.core) | ||
implementation(libs.androidx.navigation.fragment) | ||
implementation(libs.androidx.lifecycle.process) | ||
|
||
api(platform(libs.opentelemetry.platform)) | ||
api(libs.opentelemetry.api) | ||
implementation(libs.opentelemetry.sdk) | ||
implementation(libs.opentelemetry.exporter.logging) | ||
implementation(libs.opentelemetry.instrumentation.api) | ||
implementation(libs.opentelemetry.semconv.incubating) | ||
implementation(libs.opentelemetry.diskBuffering) | ||
testImplementation(libs.opentelemetry.api.incubator) | ||
testImplementation(libs.androidx.test.core) | ||
testImplementation(libs.awaitility) | ||
testImplementation(libs.robolectric) | ||
testImplementation(libs.androidx.junit.ktx) | ||
} | ||
|
||
extra["pomName"] = "OpenTelemetry Android Instrumentation" | ||
description = "A library for instrumenting Android applications with OpenTelemetry" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.