Skip to content

Commit

Permalink
Extract modules from core (#711)
Browse files Browse the repository at this point in the history
* Extarct modules from core

* Move SystemTime to common module

* Remove TestAndroidInstrumentation from core and check if tests still work

* Rename networkattrs to networkattributes

* Remove the extra import that sneaked in
  • Loading branch information
surbhiia authored Dec 5, 2024
1 parent e5138f4 commit 015f8ed
Show file tree
Hide file tree
Showing 84 changed files with 162 additions and 68 deletions.
1 change: 1 addition & 0 deletions android-agent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ android {

dependencies {
api(project(":core"))
implementation(project(":common"))
implementation(libs.opentelemetry.instrumentation.api)

// Default instrumentations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package io.opentelemetry.android.agent

import io.opentelemetry.android.common.internal.features.networkattributes.data.CurrentNetwork
import io.opentelemetry.android.config.OtelRumConfig
import io.opentelemetry.android.instrumentation.AndroidInstrumentationLoader
import io.opentelemetry.android.instrumentation.activity.ActivityLifecycleInstrumentation
Expand All @@ -15,7 +16,6 @@ import io.opentelemetry.android.instrumentation.crash.CrashReporterInstrumentati
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
Expand Down
24 changes: 24 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
plugins {
id("otel.android-library-conventions")
}

description = "OpenTelemetry android common utils"

android {
namespace = "io.opentelemetry.android.common"

defaultConfig {
consumerProguardFiles("consumer-rules.pro")
}
}

dependencies {
api(platform(libs.opentelemetry.platform.alpha))
api(libs.opentelemetry.api)
implementation(libs.opentelemetry.sdk)
implementation(libs.opentelemetry.instrumentation.api)
implementation(libs.opentelemetry.semconv.incubating)
implementation(libs.androidx.core)

testImplementation(libs.robolectric)
}
Empty file added common/consumer-rules.pro
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android;
package io.opentelemetry.android.common;

import static io.opentelemetry.android.common.RumConstants.BATTERY_PERCENT_KEY;
import static io.opentelemetry.android.common.RumConstants.HEAP_FREE_KEY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android.internal.features.networkattrs;
package io.opentelemetry.android.common.internal.features.networkattributes;

import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CARRIER_ICC;
import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CARRIER_MCC;
Expand All @@ -13,7 +13,7 @@
import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CONNECTION_TYPE;

import androidx.annotation.Nullable;
import io.opentelemetry.android.internal.services.network.data.CurrentNetwork;
import io.opentelemetry.android.common.internal.features.networkattributes.data.CurrentNetwork;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android.internal.services.network.data
package io.opentelemetry.android.common.internal.features.networkattributes.data

import android.os.Build
import android.telephony.TelephonyManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android.internal.services.network.data;
package io.opentelemetry.android.common.internal.features.networkattributes.data;

import android.os.Build;
import androidx.annotation.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android.internal.services.network.data;
package io.opentelemetry.android.common.internal.features.networkattributes.data;

import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NetworkConnectionTypeIncubatingValues;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android.internal.tools.time
package io.opentelemetry.android.common.internal.tools.time

/**
* Utility to be able to mock the current system time for testing purposes.
*
* <p>This class is internal and not for public use. Its APIs are unstable and can change at any
* time.
*/
internal interface SystemTime {
interface SystemTime {
companion object {
private var instance: SystemTime = DefaultSystemTime()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android;
package io.opentelemetry.android.common;

import static io.opentelemetry.android.common.RumConstants.BATTERY_PERCENT_KEY;
import static io.opentelemetry.android.common.RumConstants.HEAP_FREE_KEY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android.internal.features.networkattrs;
package io.opentelemetry.android.common.internal.features.networkattributes;

import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CARRIER_ICC;
import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CARRIER_MCC;
Expand All @@ -14,9 +14,9 @@
import static org.assertj.core.api.Assertions.entry;

import android.os.Build;
import io.opentelemetry.android.internal.services.network.data.Carrier;
import io.opentelemetry.android.internal.services.network.data.CurrentNetwork;
import io.opentelemetry.android.internal.services.network.data.NetworkState;
import io.opentelemetry.android.common.internal.features.networkattributes.data.Carrier;
import io.opentelemetry.android.common.internal.features.networkattributes.data.CurrentNetwork;
import io.opentelemetry.android.common.internal.features.networkattributes.data.NetworkState;
import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
7 changes: 5 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ android {
}

dependencies {
implementation(project(":instrumentation:android-instrumentation"))
implementation(project(":services"))
implementation(project(":common"))

implementation(libs.androidx.core)
implementation(libs.androidx.navigation.fragment)
implementation(libs.androidx.lifecycle.process)

api(platform(libs.opentelemetry.platform.alpha))
api(libs.opentelemetry.api)
Expand All @@ -74,6 +76,7 @@ dependencies {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

package io.opentelemetry.android.internal.features.networkattrs;

import io.opentelemetry.android.common.internal.features.networkattributes.CurrentNetworkAttributesExtractor;
import io.opentelemetry.android.common.internal.features.networkattributes.data.CurrentNetwork;
import io.opentelemetry.android.internal.services.network.CurrentNetworkProvider;
import io.opentelemetry.android.internal.services.network.data.CurrentNetwork;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.context.Context;
import io.opentelemetry.sdk.trace.ReadWriteSpan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import io.opentelemetry.android.instrumentation.AndroidInstrumentation;
import io.opentelemetry.android.instrumentation.AndroidInstrumentationLoader;
import io.opentelemetry.android.instrumentation.InstallationContext;
import io.opentelemetry.android.instrumentation.internal.AndroidInstrumentationLoaderImpl;
import io.opentelemetry.android.internal.initialization.InitializationEvents;
import io.opentelemetry.android.internal.instrumentation.AndroidInstrumentationLoaderImpl;
import io.opentelemetry.android.internal.services.CacheStorage;
import io.opentelemetry.android.internal.services.Preferences;
import io.opentelemetry.android.internal.services.ServiceManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import io.opentelemetry.android.common.internal.features.networkattributes.data.CurrentNetwork;
import io.opentelemetry.android.common.internal.features.networkattributes.data.NetworkState;
import io.opentelemetry.android.internal.services.network.CurrentNetworkProvider;
import io.opentelemetry.android.internal.services.network.data.CurrentNetwork;
import io.opentelemetry.android.internal.services.network.data.NetworkState;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.context.Context;
import io.opentelemetry.sdk.trace.ReadWriteSpan;
Expand Down
4 changes: 3 additions & 1 deletion instrumentation/activity/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ dependencies {
api(platform(libs.opentelemetry.platform.alpha))
api(libs.opentelemetry.api)
api(project(":instrumentation:common-api"))
api(project(":core"))
api(project(":instrumentation:android-instrumentation"))
implementation(project(":services"))
implementation(project(":common"))
implementation(libs.opentelemetry.sdk)
implementation(libs.androidx.core)
implementation(libs.androidx.navigation.fragment)
Expand Down
21 changes: 21 additions & 0 deletions instrumentation/android-instrumentation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
id("otel.android-library-conventions")
id("otel.publish-conventions")
}

description = "OpenTelemetry Android Instrumentation Auto Service"

android {
namespace = "io.opentelemetry.android.instrumentation"

defaultConfig {
consumerProguardFiles("consumer-rules.pro")
}
}

dependencies {
implementation(project(":services"))

api(platform(libs.opentelemetry.platform.alpha))
api(libs.opentelemetry.api)
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package io.opentelemetry.android.instrumentation

import io.opentelemetry.android.OpenTelemetryRum

/**
* This interface defines a tool that automatically generates telemetry for a specific use-case,
* without the need for end users to directly interact with the OpenTelemetry SDK to create telemetry manually.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package io.opentelemetry.android.instrumentation

import io.opentelemetry.android.internal.instrumentation.AndroidInstrumentationLoaderImpl
import io.opentelemetry.android.instrumentation.internal.AndroidInstrumentationLoaderImpl

/**
* Loads and provides [AndroidInstrumentation] instances from the runtime classpath.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android.internal.instrumentation
package io.opentelemetry.android.instrumentation.internal

import io.opentelemetry.android.instrumentation.AndroidInstrumentation
import io.opentelemetry.android.instrumentation.AndroidInstrumentationLoader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android.internal.instrumentation
package io.opentelemetry.android.instrumentation.internal

import io.mockk.mockk
import io.opentelemetry.android.instrumentation.TestAndroidInstrumentation
Expand Down
3 changes: 2 additions & 1 deletion instrumentation/anr/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ android {
}

dependencies {
api(project(":instrumentation:android-instrumentation"))
implementation(project(":services"))
api(platform(libs.opentelemetry.platform.alpha))
api(libs.opentelemetry.api)
api(project(":core"))
implementation(libs.androidx.core)
implementation(libs.opentelemetry.semconv)
implementation(libs.opentelemetry.sdk)
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/common-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
}

dependencies {
api(project(":core"))
implementation(project(":common"))
api(platform(libs.opentelemetry.platform.alpha))
api(libs.opentelemetry.api)
implementation(libs.androidx.navigation.fragment)
Expand Down
4 changes: 3 additions & 1 deletion instrumentation/crash/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ android {
}

dependencies {
api(project(":instrumentation:android-instrumentation"))
implementation(project(":common"))
implementation(project(":services"))
api(platform(libs.opentelemetry.platform.alpha))
api(libs.opentelemetry.api)
api(project(":core"))
implementation(libs.androidx.core)
implementation(libs.opentelemetry.semconv.incubating)
implementation(libs.opentelemetry.sdk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import androidx.annotation.NonNull;
import com.google.auto.service.AutoService;
import io.opentelemetry.android.RuntimeDetailsExtractor;
import io.opentelemetry.android.common.RuntimeDetailsExtractor;
import io.opentelemetry.android.instrumentation.AndroidInstrumentation;
import io.opentelemetry.android.instrumentation.InstallationContext;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
Expand Down
4 changes: 3 additions & 1 deletion instrumentation/fragment/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ dependencies {
api(platform(libs.opentelemetry.platform.alpha))
api(libs.opentelemetry.api)
api(project(":instrumentation:common-api"))
api(project(":core"))
api(project(":instrumentation:android-instrumentation"))
implementation(project(":services"))
implementation(project(":common"))
implementation(libs.androidx.core)
api(libs.androidx.navigation.fragment)
implementation(libs.opentelemetry.sdk)
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/httpurlconnection/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ android {
}

dependencies {
api(project(":instrumentation:android-instrumentation"))
api(platform(libs.opentelemetry.platform.alpha))
api(libs.opentelemetry.api)
api(libs.opentelemetry.context)
api(project(":core"))
implementation(libs.opentelemetry.instrumentation.apiSemconv)
implementation(libs.opentelemetry.instrumentation.api)
}
5 changes: 3 additions & 2 deletions instrumentation/network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ android {
}

dependencies {
api(project(":instrumentation:android-instrumentation"))
implementation(project(":services"))
implementation(project(":common"))
api(platform(libs.opentelemetry.platform.alpha))
api(libs.opentelemetry.api)
api(project(":core"))
api(project(":instrumentation:common-api"))
implementation(libs.androidx.core)
implementation(libs.opentelemetry.semconv.incubating)
implementation(libs.opentelemetry.sdk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import static io.opentelemetry.api.common.AttributeKey.stringKey;

import io.opentelemetry.android.common.internal.features.networkattributes.data.CurrentNetwork;
import io.opentelemetry.android.internal.services.applifecycle.ApplicationStateListener;
import io.opentelemetry.android.internal.services.network.CurrentNetworkProvider;
import io.opentelemetry.android.internal.services.network.NetworkChangeListener;
import io.opentelemetry.android.internal.services.network.data.CurrentNetwork;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import static io.opentelemetry.api.common.AttributeKey.stringKey;
import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CONNECTION_TYPE;

import io.opentelemetry.android.internal.features.networkattrs.CurrentNetworkAttributesExtractor;
import io.opentelemetry.android.internal.services.network.data.CurrentNetwork;
import io.opentelemetry.android.internal.services.network.data.NetworkState;
import io.opentelemetry.android.common.internal.features.networkattributes.CurrentNetworkAttributesExtractor;
import io.opentelemetry.android.common.internal.features.networkattributes.data.CurrentNetwork;
import io.opentelemetry.android.common.internal.features.networkattributes.data.NetworkState;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import androidx.annotation.NonNull;
import com.google.auto.service.AutoService;
import io.opentelemetry.android.common.internal.features.networkattributes.data.CurrentNetwork;
import io.opentelemetry.android.instrumentation.AndroidInstrumentation;
import io.opentelemetry.android.instrumentation.InstallationContext;
import io.opentelemetry.android.internal.services.network.data.CurrentNetwork;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import java.util.ArrayList;
import java.util.Collections;
Expand Down
Loading

0 comments on commit 015f8ed

Please sign in to comment.