Skip to content
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ apollo {

spotless {
kotlin {
targetExclude("**/generated/**")
licenseHeaderFile(file("LICENSE-HEADER.txt"))
}
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
kotlin.code.style=official

cliGroup=com.sourceplusplus
projectVersion=0.3.1
projectVersion=0.4.0

vertxVersion=4.2.4
graalVersion = 21.3.0
jacksonVersion = 2.12.5
apolloVersion=3.0.0
jacksonVersion=2.13.1
apolloVersion=3.1.0
commonsLang3Version = 3.12.0
cliktVersion = 3.2.0
bouncycastleVersion = 1.69
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pluginManagement {
id 'com.avast.gradle.docker-compose' version "0.15.0" apply false
id 'io.gitlab.arturbosch.detekt' version "1.19.0" apply false
id 'com.github.johnrengelman.shadow' version "7.1.2" apply false
id 'com.apollographql.apollo3' version "3.0.0" apply false
id 'com.apollographql.apollo3' version "3.1.0" apply false
id 'org.mikeneck.graalvm-native-image' version "1.4.1" apply false
id 'com.diffplug.spotless' version '6.2.1' apply false
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/spp/cli/PlatformCLI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import org.bouncycastle.openssl.PEMKeyPair
import org.bouncycastle.openssl.PEMParser
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter
import org.bouncycastle.util.encoders.Hex
import spp.protocol.developer.Developer
import spp.protocol.platform.developer.Developer
import spp.protocol.util.KSerializers
import java.io.File
import java.io.StringReader
Expand Down
33 changes: 13 additions & 20 deletions src/main/kotlin/spp/cli/commands/instrument/SubscribeEvents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ import io.vertx.ext.eventbus.bridge.tcp.impl.protocol.FrameParser
import io.vertx.kotlin.coroutines.await
import kotlinx.coroutines.runBlocking
import spp.cli.PlatformCLI
import spp.protocol.SourceMarkerServices
import spp.protocol.ProtocolMarshaller.deserializeLiveInstrumentRemoved
import spp.protocol.SourceServices.Provide.toLiveInstrumentSubscriberAddress
import spp.protocol.extend.TCPServiceFrameParser
import spp.protocol.instrument.LiveInstrumentEvent
import spp.protocol.instrument.LiveInstrumentEventType
import spp.protocol.instrument.breakpoint.event.LiveBreakpointHit
import spp.protocol.instrument.breakpoint.event.LiveBreakpointRemoved
import spp.protocol.instrument.log.event.LiveLogHit
import spp.protocol.instrument.log.event.LiveLogRemoved
import spp.protocol.instrument.event.LiveBreakpointHit
import spp.protocol.instrument.event.LiveInstrumentEvent
import spp.protocol.instrument.event.LiveInstrumentEventType
import spp.protocol.instrument.event.LiveLogHit

class SubscribeEvents : CliktCommand(
help = "Listens for and outputs live events. Subscribes to all events by default"
Expand Down Expand Up @@ -89,7 +88,7 @@ class SubscribeEvents : CliktCommand(
).await()
socket!!.handler(FrameParser(TCPServiceFrameParser(vertx, socket)))

vertx.eventBus().consumer<JsonObject>("local." + SourceMarkerServices.Provide.LIVE_INSTRUMENT_SUBSCRIBER) {
vertx.eventBus().consumer<JsonObject>(toLiveInstrumentSubscriberAddress(PlatformCLI.developer.id)) {
val liveEvent = Json.decodeValue(it.body().toString(), LiveInstrumentEvent::class.java)

//todo: impl filter on platform
Expand All @@ -107,15 +106,9 @@ class SubscribeEvents : CliktCommand(
return@consumer
}
}
LiveInstrumentEventType.BREAKPOINT_REMOVED -> {
val breakpointRemoved = Json.decodeValue(liveEvent.data, LiveBreakpointRemoved::class.java)
if (breakpointRemoved.breakpointId !in instrumentIds) {
return@consumer
}
}
LiveInstrumentEventType.LOG_REMOVED -> {
val logRemoved = Json.decodeValue(liveEvent.data, LiveLogRemoved::class.java)
if (logRemoved.logId !in instrumentIds) {
LiveInstrumentEventType.BREAKPOINT_REMOVED, LiveInstrumentEventType.LOG_REMOVED -> {
val logRemoved = deserializeLiveInstrumentRemoved(JsonObject(liveEvent.data))
if (logRemoved.liveInstrument.id !in instrumentIds) {
return@consumer
}
}
Expand Down Expand Up @@ -164,9 +157,9 @@ class SubscribeEvents : CliktCommand(
//register listener
FrameHelper.sendFrame(
BridgeEventType.REGISTER.name.lowercase(),
SourceMarkerServices.Provide.LIVE_INSTRUMENT_SUBSCRIBER,
JsonObject(),
socket
toLiveInstrumentSubscriberAddress(PlatformCLI.developer.id), null,
JsonObject().apply { PlatformCLI.developer.accessToken?.let { put("auth-token", it) } },
null, null, socket
)
println("Listening for events...")
}
Expand Down
14 changes: 6 additions & 8 deletions src/main/kotlin/spp/cli/commands/view/SubscribeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
package spp.cli.commands.view

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.arguments.multiple
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import eu.geekplace.javapinning.JavaPinning
Expand All @@ -36,7 +34,7 @@ import io.vertx.ext.eventbus.bridge.tcp.impl.protocol.FrameParser
import io.vertx.kotlin.coroutines.await
import kotlinx.coroutines.runBlocking
import spp.cli.PlatformCLI
import spp.protocol.SourceMarkerServices.Provide.LIVE_VIEW_SUBSCRIBER
import spp.protocol.SourceServices.Provide.toLiveViewSubscriberAddress
import spp.protocol.artifact.log.Log
import spp.protocol.artifact.log.LogOrderType
import spp.protocol.artifact.log.LogResult
Expand Down Expand Up @@ -93,7 +91,7 @@ class SubscribeView : CliktCommand(
).await()
socket!!.handler(FrameParser(TCPServiceFrameParser(vertx, socket)))

vertx.eventBus().consumer<JsonObject>("local.$LIVE_VIEW_SUBSCRIBER.${PlatformCLI.developer.id}") {
vertx.eventBus().consumer<JsonObject>(toLiveViewSubscriberAddress(PlatformCLI.developer.id)) {
val event = Json.decodeValue(it.body().toString(), LiveViewEvent::class.java)
if (outputFullEvent) {
println(event.metricsData)
Expand All @@ -109,9 +107,9 @@ class SubscribeView : CliktCommand(
//register listener
FrameHelper.sendFrame(
BridgeEventType.REGISTER.name.lowercase(),
"$LIVE_VIEW_SUBSCRIBER.${PlatformCLI.developer.id}",
JsonObject(),
socket
toLiveViewSubscriberAddress(PlatformCLI.developer.id), null,
JsonObject().apply { PlatformCLI.developer.accessToken?.let { put("auth-token", it) } },
null, null, socket
)
println("Listening for events...")
}
Expand Down Expand Up @@ -144,7 +142,7 @@ class SubscribeView : CliktCommand(
Int.MAX_VALUE
)
logsResult.logs.forEach {
println(it.getFormattedMessage())
println(it.toFormattedMessage())
}
}
}
2 changes: 1 addition & 1 deletion src/test/kotlin/integration/BatchLiveInstrumentCLI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Test
import spp.cli.Main
import spp.protocol.instrument.LiveBreakpoint
import spp.protocol.instrument.LiveInstrument
import spp.protocol.instrument.breakpoint.LiveBreakpoint

class BatchLiveInstrumentCLI : CLIIntegrationTest() {

Expand Down
8 changes: 4 additions & 4 deletions src/test/kotlin/integration/CLIIntegrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import io.vertx.core.json.Json
import io.vertx.core.json.JsonArray
import io.vertx.core.json.jackson.DatabindCodec
import spp.cli.Main
import spp.protocol.instrument.breakpoint.LiveBreakpoint
import spp.protocol.instrument.log.LiveLog
import spp.protocol.instrument.meter.LiveMeter
import spp.protocol.instrument.span.LiveSpan
import spp.protocol.instrument.LiveBreakpoint
import spp.protocol.instrument.LiveLog
import spp.protocol.instrument.LiveMeter
import spp.protocol.instrument.LiveSpan
import java.io.OutputStream
import java.io.PrintStream
import kotlin.reflect.KClass
Expand Down
6 changes: 3 additions & 3 deletions src/test/kotlin/integration/LiveInstrumentCLI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
*/
package integration

import spp.protocol.instrument.LiveInstrument
import spp.protocol.instrument.breakpoint.LiveBreakpoint
import spp.protocol.instrument.log.LiveLog
import io.vertx.core.json.Json
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import spp.cli.Main
import spp.protocol.instrument.LiveBreakpoint
import spp.protocol.instrument.LiveInstrument
import spp.protocol.instrument.LiveLog

class LiveInstrumentCLI : CLIIntegrationTest() {

Expand Down