Skip to content

Commit

Permalink
Moving DefaultExportScheduler instance to DefaultExportScheduleHandle…
Browse files Browse the repository at this point in the history
…r's constructor
  • Loading branch information
LikeTheSalad committed Jan 11, 2024
1 parent c407bab commit 2abf0af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import io.opentelemetry.android.internal.services.ServiceManager
import io.opentelemetry.android.internal.services.periodicwork.PeriodicWorkService
import java.util.concurrent.atomic.AtomicBoolean

class DefaultExportScheduleHandler : ExportScheduleHandler {
class DefaultExportScheduleHandler(private val exportScheduler: DefaultExportScheduler) :
ExportScheduleHandler {
private val enabled = AtomicBoolean(false)

override fun enable() {
if (!enabled.getAndSet(true)) {
ServiceManager.get().getService(PeriodicWorkService::class.java)
.enqueue(DefaultExportScheduler())
.enqueue(exportScheduler)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DefaultExportScheduleHandlerTest {

@BeforeEach
fun setUp() {
handler = DefaultExportScheduleHandler()
handler = DefaultExportScheduleHandler(DefaultExportScheduler())
}

@Test
Expand Down

0 comments on commit 2abf0af

Please sign in to comment.