Skip to content

Commit cb788a7

Browse files
committed
Rename SesseionIdTimeoutHandler to SessionBackgroundTimeoutHandler
1 parent 3f33530 commit cb788a7

File tree

7 files changed

+22
-18
lines changed

7 files changed

+22
-18
lines changed

core/src/main/java/io/opentelemetry/android/OpenTelemetryRumBuilder.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import io.opentelemetry.android.internal.services.CacheStorage;
3434
import io.opentelemetry.android.internal.services.Services;
3535
import io.opentelemetry.android.internal.services.periodicwork.PeriodicWork;
36-
import io.opentelemetry.android.internal.session.SessionIdTimeoutHandler;
36+
import io.opentelemetry.android.internal.session.SessionBackgroundTimeoutHandler;
3737
import io.opentelemetry.android.internal.session.SessionManagerImpl;
3838
import io.opentelemetry.android.session.SessionManager;
3939
import io.opentelemetry.android.session.SessionProvider;
@@ -95,7 +95,7 @@ public final class OpenTelemetryRumBuilder {
9595
private final OtelRumConfig config;
9696
private final List<AndroidInstrumentation> instrumentations = new ArrayList<>();
9797
private final List<Consumer<OpenTelemetrySdk>> otelSdkReadyListeners = new ArrayList<>();
98-
private final SessionIdTimeoutHandler timeoutHandler;
98+
private final SessionBackgroundTimeoutHandler timeoutHandler;
9999
private Function<? super SpanExporter, ? extends SpanExporter> spanExporterCustomizer = a -> a;
100100
private Function<? super MetricExporter, ? extends MetricExporter> metricExporterCustomizer =
101101
a -> a;
@@ -116,11 +116,15 @@ private static TextMapPropagator buildDefaultPropagator() {
116116

117117
public static OpenTelemetryRumBuilder create(Application application, OtelRumConfig config) {
118118
return new OpenTelemetryRumBuilder(
119-
application, config, new SessionIdTimeoutHandler(config.getSessionTimeout()));
119+
application,
120+
config,
121+
new SessionBackgroundTimeoutHandler(config.getSessionTimeout()));
120122
}
121123

122124
OpenTelemetryRumBuilder(
123-
Application application, OtelRumConfig config, SessionIdTimeoutHandler timeoutHandler) {
125+
Application application,
126+
OtelRumConfig config,
127+
SessionBackgroundTimeoutHandler timeoutHandler) {
124128
this.application = application;
125129
this.timeoutHandler = timeoutHandler;
126130
this.resource = AndroidResource.createDefault(application);

core/src/main/java/io/opentelemetry/android/SdkPreconfiguredRumBuilder.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import io.opentelemetry.android.instrumentation.AndroidInstrumentation
1010
import io.opentelemetry.android.instrumentation.AndroidInstrumentationLoader
1111
import io.opentelemetry.android.instrumentation.InstallationContext
1212
import io.opentelemetry.android.internal.services.Services
13-
import io.opentelemetry.android.internal.session.SessionIdTimeoutHandler
13+
import io.opentelemetry.android.internal.session.SessionBackgroundTimeoutHandler
1414
import io.opentelemetry.android.internal.session.SessionManagerImpl
1515
import io.opentelemetry.android.session.SessionManager
1616
import io.opentelemetry.sdk.OpenTelemetrySdk
@@ -20,7 +20,7 @@ class SdkPreconfiguredRumBuilder
2020
internal constructor(
2121
private val application: Application,
2222
private val sdk: OpenTelemetrySdk,
23-
private val timeoutHandler: SessionIdTimeoutHandler = SessionIdTimeoutHandler(),
23+
private val timeoutHandler: SessionBackgroundTimeoutHandler = SessionBackgroundTimeoutHandler(),
2424
private val sessionManager: SessionManager = SessionManagerImpl(timeoutHandler = timeoutHandler),
2525
private val discoverInstrumentations: Boolean,
2626
private val services: Services,

core/src/main/java/io/opentelemetry/android/internal/session/SessionIdTimeoutHandler.kt core/src/main/java/io/opentelemetry/android/internal/session/SessionBackgroundTimeoutHandler.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import java.time.Duration
2323
* Consequently, when the app spent >15 minutes without any activity (spans) in the background,
2424
* after moving to the foreground the first span should trigger the sessionId timeout.
2525
*/
26-
internal class SessionIdTimeoutHandler(
26+
internal class SessionBackgroundTimeoutHandler(
2727
private val clock: Clock,
2828
private val sessionTimeout: Duration,
2929
) : ApplicationStateListener {

core/src/main/java/io/opentelemetry/android/internal/session/SessionManagerImpl.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit
1717
internal class SessionManagerImpl(
1818
private val clock: Clock = Clock.getDefault(),
1919
private val sessionStorage: SessionStorage = SessionStorage.InMemory(),
20-
private val timeoutHandler: SessionIdTimeoutHandler,
20+
private val timeoutHandler: SessionBackgroundTimeoutHandler,
2121
private val idGenerator: SessionIdGenerator = SessionIdGenerator.DEFAULT,
2222
private val sessionLifetimeNanos: Long = TimeUnit.HOURS.toNanos(4),
2323
) : SessionManager {
@@ -74,7 +74,7 @@ internal class SessionManagerImpl(
7474
companion object {
7575
@JvmStatic
7676
fun create(
77-
timeoutHandler: SessionIdTimeoutHandler,
77+
timeoutHandler: SessionBackgroundTimeoutHandler,
7878
sessionLifetimeNanos: Long,
7979
): SessionManagerImpl =
8080
SessionManagerImpl(

core/src/test/java/io/opentelemetry/android/OpenTelemetryRumBuilderTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import io.opentelemetry.android.internal.services.applifecycle.AppLifecycle;
4343
import io.opentelemetry.android.internal.services.applifecycle.ApplicationStateListener;
4444
import io.opentelemetry.android.internal.services.visiblescreen.VisibleScreenTracker;
45-
import io.opentelemetry.android.internal.session.SessionIdTimeoutHandler;
45+
import io.opentelemetry.android.internal.session.SessionBackgroundTimeoutHandler;
4646
import io.opentelemetry.android.session.SessionManager;
4747
import io.opentelemetry.api.common.Attributes;
4848
import io.opentelemetry.api.incubator.logs.ExtendedLogRecordBuilder;
@@ -283,7 +283,7 @@ public void canCustomizeMetricExport() {
283283
public void shouldInstallInstrumentation() {
284284
Services services = createAndSetServiceManager();
285285
SessionManager sessionManager = mock();
286-
SessionIdTimeoutHandler timeoutHandler = mock();
286+
SessionBackgroundTimeoutHandler timeoutHandler = mock();
287287
AndroidInstrumentation localInstrumentation = mock();
288288
AndroidInstrumentation classpathInstrumentation = mock();
289289
AndroidInstrumentationLoaderImpl androidInstrumentationServices =
@@ -308,7 +308,7 @@ public void shouldInstallInstrumentation() {
308308
public void shouldInstallInstrumentation_excludingClasspathImplsWhenRequestedInConfig() {
309309
Services services = createAndSetServiceManager();
310310
SessionManager sessionManager = mock();
311-
SessionIdTimeoutHandler timeoutHandler = mock();
311+
SessionBackgroundTimeoutHandler timeoutHandler = mock();
312312
AndroidInstrumentation localInstrumentation = mock();
313313
AndroidInstrumentation classpathInstrumentation = mock();
314314
AndroidInstrumentationLoaderImpl androidInstrumentationServices =

core/src/test/java/io/opentelemetry/android/internal/session/SessionIdTimeoutHandlerTest.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
package io.opentelemetry.android.internal.session
77

8-
import io.opentelemetry.android.internal.session.SessionIdTimeoutHandler.Companion.DEFAULT_SESSION_TIMEOUT
8+
import io.opentelemetry.android.internal.session.SessionBackgroundTimeoutHandler.Companion.DEFAULT_SESSION_TIMEOUT
99
import io.opentelemetry.sdk.testing.time.TestClock
1010
import org.junit.jupiter.api.Assertions.assertFalse
1111
import org.junit.jupiter.api.Assertions.assertTrue
@@ -18,7 +18,7 @@ class SessionIdTimeoutHandlerTest {
1818
fun shouldNeverTimeOutInForeground() {
1919
val clock: TestClock = TestClock.create()
2020
val timeoutHandler =
21-
SessionIdTimeoutHandler(clock, DEFAULT_SESSION_TIMEOUT)
21+
SessionBackgroundTimeoutHandler(clock, DEFAULT_SESSION_TIMEOUT)
2222

2323
assertFalse(timeoutHandler.hasTimedOut())
2424
timeoutHandler.bump()
@@ -32,7 +32,7 @@ class SessionIdTimeoutHandlerTest {
3232
fun shouldApply15MinutesTimeoutToAppsInBackground() {
3333
val clock: TestClock = TestClock.create()
3434
val timeoutHandler =
35-
SessionIdTimeoutHandler(clock, DEFAULT_SESSION_TIMEOUT)
35+
SessionBackgroundTimeoutHandler(clock, DEFAULT_SESSION_TIMEOUT)
3636

3737
timeoutHandler.onApplicationBackgrounded()
3838
timeoutHandler.bump()
@@ -64,7 +64,7 @@ class SessionIdTimeoutHandlerTest {
6464
fun shouldApplyTimeoutToFirstSpanAfterAppBeingMovedToForeground() {
6565
val clock: TestClock = TestClock.create()
6666
val timeoutHandler =
67-
SessionIdTimeoutHandler(clock, DEFAULT_SESSION_TIMEOUT)
67+
SessionBackgroundTimeoutHandler(clock, DEFAULT_SESSION_TIMEOUT)
6868

6969
timeoutHandler.onApplicationBackgrounded()
7070
timeoutHandler.bump()
@@ -84,7 +84,7 @@ class SessionIdTimeoutHandlerTest {
8484
fun shouldApplyCustomTimeoutToFirstSpanAfterAppBeingMovedToForeground() {
8585
val clock: TestClock = TestClock.create()
8686
val timeoutHandler =
87-
SessionIdTimeoutHandler(clock, Duration.ofNanos(5))
87+
SessionBackgroundTimeoutHandler(clock, Duration.ofNanos(5))
8888

8989
timeoutHandler.onApplicationBackgrounded()
9090
timeoutHandler.bump()

core/src/test/java/io/opentelemetry/android/internal/session/SessionManagerImplTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import java.util.regex.Pattern
2525

2626
internal class SessionManagerImplTest {
2727
@MockK
28-
lateinit var timeoutHandler: SessionIdTimeoutHandler
28+
lateinit var timeoutHandler: SessionBackgroundTimeoutHandler
2929

3030
@BeforeEach
3131
fun setUp() {

0 commit comments

Comments
 (0)