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

Catching adapter exceptions and writing them #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,12 @@ class AmplitudeTestGroupAssignmentTrackerIT extends SpecificationWithJUnit with
amplitudeTestGroupAssignmentTracker.newAssignment(assignment)
amplitudeDriver.assertThatBiServerWasCalled("httpapi")
}

"don't throw an exception if failing to write to bi adapter" in new Context{
val failingAmplitudeAdapter = AmplitudeAdapterBuilder.create(
s"http://localhost:$port/notexisting", "198e3469868de498f5d67581d6de4518", null)
val failingAmplitudeTestGroupAssignmentTracker = new BiTestGroupAssignmentTracker(failingAmplitudeAdapter)
failingAmplitudeTestGroupAssignmentTracker.newAssignment(assignment) must not(throwA[Throwable])
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import com.wixpress.petri.experiments.domain.Assignment
class BiTestGroupAssignmentTracker(adapter: BiAdapter) extends TestGroupAssignmentTracker {
override def newAssignment(assignment: Assignment): Unit = {
val event = BiPetriEvent.fromAssignment(assignment)
adapter.sendEvent(event)
try {
adapter.sendEvent(event)
} catch {
case e: Throwable =>
println(s"Failed to write BI Event to: ${adapter.getClass.getName} for experiment ${assignment.getExperimentId}")
e.printStackTrace()
}
}
}

Expand Down