Skip to content

Commit

Permalink
chore: datadog poc [OTE-719][1/n] (#581)
Browse files Browse the repository at this point in the history
Co-authored-by: mobile-build-bot-git <[email protected]>
  • Loading branch information
yogurtandjam and mobile-build-bot authored Aug 22, 2024
1 parent 1123912 commit 0a93ee0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.8.99"
version = "1.8.100"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,5 +355,7 @@ interface PresentationProtocol {
interface LoggingProtocol {
fun d(tag: String, message: String)

fun e(tag: String, message: String)
fun e(tag: String, message: String, context: Map<String, Any>?, error: Error?)

fun ddInfo(tag: String, message: String, context: Map<String, Any>?)
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import exchange.dydx.abacus.utils.toNobleAddress
import exchange.dydx.abacus.utils.toOsmosisAddress
import io.ktor.util.encodeBase64
import kollections.iListOf
import kollections.toIMap
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
Expand Down Expand Up @@ -357,8 +358,10 @@ internal class OnboardingSupervisor(
val header = iMapOf(
"Content-Type" to "application/json",
)
Logger.ddInfo(body.toIMap(), { "retrieveSkipDepositRouteNonCCTP payload sending" })
helper.post(url, header, body.toJsonPrettyPrint()) { _, response, code, headers ->
if (response != null) {
Logger.ddInfo(helper.parser.decodeJsonObject(response), { "retrieveSkipDepositRouteCCTP payload received" })
val currentFromAmount = stateMachine.state?.input?.transfer?.size?.size
val oldFromAmount = oldState?.input?.transfer?.size?.size
if (currentFromAmount == oldFromAmount) {
Expand Down Expand Up @@ -415,8 +418,10 @@ internal class OnboardingSupervisor(
val header = iMapOf(
"Content-Type" to "application/json",
)
Logger.ddInfo(body.toIMap(), { "retrieveSkipDepositRouteCCTP payload sending" })
helper.post(url, header, body.toJsonPrettyPrint()) { _, response, code, headers ->
if (response != null) {
Logger.ddInfo(helper.parser.decodeJsonObject(response), { "retrieveSkipDepositRouteCCTP payload received" })
val currentFromAmount = stateMachine.state?.input?.transfer?.size?.size
val oldFromAmount = oldState?.input?.transfer?.size?.size
if (currentFromAmount == oldFromAmount) {
Expand Down Expand Up @@ -1139,8 +1144,10 @@ internal class OnboardingSupervisor(
"Content-Type" to "application/json",
)
val oldState = stateMachine.state
Logger.ddInfo(body.toIMap(), { "retrieveSkipWithdrawalRouteNonCCTP payload sending" })
helper.post(url, header, body.toJsonPrettyPrint()) { _, response, code, headers ->
if (response != null) {
Logger.ddInfo(helper.parser.decodeJsonObject(response), { "retrieveSkipWithdrawalRouteNonCCTP payload received" })
update(stateMachine.squidRoute(response, subaccountNumber ?: 0, null), oldState)
} else {
Logger.e { "retrieveSkipWithdrawalRouteNonCCTP error, code: $code" }
Expand Down Expand Up @@ -1194,8 +1201,10 @@ internal class OnboardingSupervisor(
val header = iMapOf(
"Content-Type" to "application/json",
)
Logger.ddInfo(body.toIMap(), { "retrieveSkipWithdrawalRouteCCTP payload sending" })
helper.post(url, header, body.toJsonPrettyPrint()) { _, response, code, _ ->
if (response != null) {
Logger.ddInfo(helper.parser.decodeJsonObject(response), { "retrieveSkipWithdrawalRouteCCTP payload received" })
val currentFromAmount = stateMachine.state?.input?.transfer?.size?.size
val oldFromAmount = oldState?.input?.transfer?.size?.size
if (currentFromAmount == oldFromAmount) {
Expand Down Expand Up @@ -1693,9 +1702,11 @@ internal class OnboardingSupervisor(
val header = iMapOf(
"Content-Type" to "application/json",
)
Logger.ddInfo(body.toIMap(), { "cctpToNobleSkip payload sending" })
helper.post(url, header, body.toJsonPrettyPrint()) { _, response, code, _ ->
val json = helper.parser.decodeJsonObject(response)
if (json != null) {
Logger.ddInfo(json, { "cctpToNobleSkip payload received" })
val skipRoutePayloadProcessor = SkipRoutePayloadProcessor(parser = helper.parser)
val processedPayload = skipRoutePayloadProcessor.received(existing = mapOf(), payload = json)
val ibcPayload = helper.parser.asString(
Expand Down
12 changes: 10 additions & 2 deletions src/commonMain/kotlin/exchange.dydx.abacus/utils/Logger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@ object Logger {
}
}

fun e(message: () -> String) {
fun e(context: Map<String, Any>? = null, error: Error? = null, message: () -> String) {
clientLogger?.let {
it.e(TAG, message())
it.e(TAG, message(), context, error)
} ?: platformErrorLog(message())
}

fun ddInfo(context: Map<String, Any>? = null, message: () -> String) {
if (isDebugEnabled) {
clientLogger?.let {
it.ddInfo(TAG, message(), context)
}
}
}
}

expect fun platformDebugLog(message: String)
Expand Down
2 changes: 1 addition & 1 deletion v4_abacus.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'v4_abacus'
spec.version = '1.8.99'
spec.version = '1.8.100'
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down

0 comments on commit 0a93ee0

Please sign in to comment.