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

feat: Set Google api issues level as DEBUG #2016

Merged
merged 1 commit into from
Jun 9, 2021
Merged
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
3 changes: 2 additions & 1 deletion test_runner/src/main/kotlin/ftl/http/ExecuteWithRetry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ftl.run.exception.FailureToken
import ftl.run.exception.PermissionDenied
import ftl.run.exception.ProjectNotFound
import ftl.util.report
import io.sentry.SentryLevel
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import java.io.IOException
Expand All @@ -24,7 +25,7 @@ private inline fun <T> withRetry(crossinline block: () -> T): T = runBlocking {
} catch (err: IOException) {
// We want to send every occurrence of Google API error for statistic purposes
// https://github.com/Flank/flank/issues/701
FlankGoogleApiError(err).report()
FlankGoogleApiError(err).report(SentryLevel.DEBUG)

lastError = err
if (err is HttpResponseException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ftl.reports.printTotalDuration
import ftl.run.cancelMatrices
import ftl.util.closeCrashReporter
import ftl.util.report
import io.sentry.SentryLevel
import kotlinx.coroutines.runBlocking
import kotlin.system.exitProcess

Expand Down Expand Up @@ -54,7 +55,7 @@ internal fun withGlobalExceptionHandling(block: () -> Int, exitProcessFunction:
}

is InfrastructureError -> {
Copy link
Contributor

@pawelpasterz pawelpasterz Jun 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to change log level for FTLError as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, does FTLError occurs only on Google Api issues?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to error description, it's thrown when an internal error occurs.
So I guess you are right...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could leave it for now and see later how it is working

t.report()
t.report(SentryLevel.DEBUG)
printError("An infrastructure error occurred.")
printError("Details: ${t.messageOrUnavailable}")
exitProcessFunction(INFRASTRUCTURE_ERROR)
Expand Down
12 changes: 8 additions & 4 deletions test_runner/src/main/kotlin/ftl/util/CrashReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ftl.util

import flank.common.config.isTest
import io.sentry.Sentry
import io.sentry.SentryLevel
import java.io.File
import java.util.UUID

Expand All @@ -26,10 +27,10 @@ fun disableCrashReporting() {
configureCrashReporter
}

fun Throwable.report() {
fun Throwable.report(logLevel: SentryLevel = SentryLevel.ERROR) {
if (isTest().not()) {
configureCrashReporter
notify(this)
notify(this, logLevel)
}
}

Expand Down Expand Up @@ -66,8 +67,11 @@ fun setCrashReportTag(
vararg tags: Pair<String, String>
) = tags.forEach { (property, value) -> Sentry.setTag(property, value) }

private fun notify(error: Throwable) {
Sentry.captureException(error)
private fun notify(error: Throwable, logLevel: SentryLevel) {
Sentry.withScope {
it.level = logLevel
Sentry.captureException(error)
}
}

fun closeCrashReporter() {
Expand Down