Skip to content

Commit

Permalink
✨ Add channel info to statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
devkanro committed Aug 28, 2023
1 parent 3ad28dc commit 2911463
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 38 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {

allprojects {
group = "io.kanro"
version = "1.4.6"
version = "1.4.7"

repositories {
mavenLocal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ sealed interface CallEvent : ChangedInteraction {
val resolvedAuthority: String,
val method: String,
val methodType: MethodType,
val header: Metadata
val header: Metadata,
val frontend: String,
val backend: String
) : CallEvent {
private val timestamp = Timestamp.now()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import io.kanro.mediator.desktop.viewmodel.MainViewModel
import io.kanro.mediator.internal.MediatorProtoReflection
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import java.util.Deque
import java.util.*
import java.util.concurrent.ConcurrentLinkedDeque

class CallTimeline(val id: String = (counter++).toString()) : BaseObservableObject() {
Expand Down Expand Up @@ -46,7 +46,9 @@ class CallTimeline(val id: String = (counter++).toString()) : BaseObservableObje
resolvedAuthority: String,
method: String,
methodType: MethodType,
header: Metadata
header: Metadata,
frontend: String,
backend: String
): CallEvent.Start {
return emit(
CallEvent.Start(
Expand All @@ -55,7 +57,9 @@ class CallTimeline(val id: String = (counter++).toString()) : BaseObservableObje
resolvedAuthority,
method,
methodType,
header
header,
frontend,
backend
)
)
}
Expand Down
46 changes: 15 additions & 31 deletions desktop/src/main/kotlin/io/kanro/mediator/desktop/ui/CallView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,12 @@ import androidx.compose.foundation.gestures.draggable
import androidx.compose.foundation.gestures.rememberDraggableState
import androidx.compose.foundation.hoverable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.rememberScrollbarAdapter
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
Expand All @@ -49,15 +34,8 @@ import com.bybutter.sisyphus.string.toUpperSpaceCase
import io.grpc.Metadata
import io.kanro.compose.jetbrains.JBTheme
import io.kanro.compose.jetbrains.SelectionScope
import io.kanro.compose.jetbrains.control.*
import io.kanro.compose.jetbrains.control.ContextMenuArea
import io.kanro.compose.jetbrains.control.Icon
import io.kanro.compose.jetbrains.control.JBTreeItem
import io.kanro.compose.jetbrains.control.JBTreeList
import io.kanro.compose.jetbrains.control.JPanelBorder
import io.kanro.compose.jetbrains.control.ListItemHoverIndication
import io.kanro.compose.jetbrains.control.ProgressBar
import io.kanro.compose.jetbrains.control.Tab
import io.kanro.compose.jetbrains.control.Text
import io.kanro.mediator.desktop.model.CallEvent
import io.kanro.mediator.desktop.model.CallTimeline
import io.kanro.mediator.desktop.model.asState
Expand Down Expand Up @@ -154,20 +132,26 @@ fun StatisticsView(call: CallTimeline) {
MetadataItem("Start time", start.timestamp().string(), selectedKey == 4) {
selectedKey = 4
}
MetadataItem("Frontend Channel", start.frontend, selectedKey == 5) {
selectedKey = 5
}
MetadataItem("Backend Channel", start.backend, selectedKey == 6) {
selectedKey = 6
}
}
val close = call.close()
if (close != null) {
MetadataItem("End time", close.timestamp().string(), selectedKey == 5) {
selectedKey = 5
MetadataItem("End time", close.timestamp().string(), selectedKey == 7) {
selectedKey = 7
}
}
val transparent = call.first<CallEvent.Transparent>()
if (transparent != null) {
MetadataItem("Authority", transparent.authority, selectedKey == 6) {
selectedKey = 6
MetadataItem("Authority", transparent.authority, selectedKey == 8) {
selectedKey = 8
}
MetadataItem("Start time", transparent.timestamp().string(), selectedKey == 7) {
selectedKey = 7
MetadataItem("Start time", transparent.timestamp().string(), selectedKey == 9) {
selectedKey = 9
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion desktop/src/main/kotlin/io/kanro/mediator/internal/Debug.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ suspend fun randomCall(): CallTimeline {

return CallTimeline().apply {
this.start(
Random.nextBoolean(), host, host, randomMethod, MethodType.UNKNOWN, randomMetadata()
Random.nextBoolean(), host, host, randomMethod, MethodType.UNKNOWN, randomMetadata(),
"L:debug = R:debug",
"L:debug = R:debug",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ class MediatorGrpcProxySupport(private val config: MediatorConfiguration, privat
rewriteHost,
headers.path().substring(1),
MethodType.UNKNOWN,
headers.toGrpcMetadata()
headers.toGrpcMetadata(),
"R:${fs.remoteAddress()} - L:${fs.localAddress()}",
"L:${bs.localAddress()} - R:${bs.remoteAddress()}"
)
MainViewModel.calls += timeline
val filter = MainViewModel.filter.value
Expand Down

0 comments on commit 2911463

Please sign in to comment.