From a33ea0f0477e18e04b69cc836a30e46761ba8694 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 26 Jun 2023 16:27:37 -0500 Subject: [PATCH 01/31] Add VCS support for SkyWalking receivers This commit adds VCS support to SkyWalking receivers by modifying the default handlers to include VCS information in the service context. ref: sourceplusplus/sourceplusplus#461 --- docker/e2e/Dockerfile-spp-platform | 19 +++- docker/e2e/spp-probe-platform.yml | 11 +-- platform/build.gradle.kts | 2 + .../spp/platform/common/util/ContextUtil.kt | 10 ++ platform/core/build.gradle.kts | 13 +++ .../spp/platform/core/SourcePlatform.kt | 5 +- .../interceptors/SkyWalkingGrpcInterceptor.kt | 21 ++++- .../platform/core/service/ServiceProvider.kt | 2 +- .../spp/platform/core/vcs/ServiceVCS.kt | 51 ++++++++++ .../vcs/providers/VCSEventModuleProvider.kt | 63 +++++++++++++ .../vcs/providers/VCSJVMModuleProvider.kt | 68 ++++++++++++++ .../vcs/providers/VCSLogModuleProvider.kt | 71 ++++++++++++++ .../vcs/providers/VCSMeterReceiverProvider.kt | 82 ++++++++++++++++ .../providers/VCSRegisterModuleProvider.kt | 76 +++++++++++++++ .../vcs/providers/VCSTraceModuleProvider.kt | 93 +++++++++++++++++++ ...ing.oap.server.library.module.ModuleDefine | 2 +- ...g.oap.server.library.module.ModuleProvider | 6 ++ .../src/test/resources/spp-test-probe.yml | 5 + platform/processor/live-view/build.gradle.kts | 9 ++ .../provider/LiveMeterReceiverProvider.kt | 1 - ...g.oap.server.library.module.ModuleProvider | 3 +- 21 files changed, 596 insertions(+), 17 deletions(-) create mode 100644 platform/core/src/main/kotlin/spp/platform/core/vcs/ServiceVCS.kt create mode 100644 platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSEventModuleProvider.kt create mode 100644 platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSJVMModuleProvider.kt create mode 100644 platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSLogModuleProvider.kt create mode 100644 platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSMeterReceiverProvider.kt create mode 100644 platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSRegisterModuleProvider.kt create mode 100644 platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSTraceModuleProvider.kt diff --git a/docker/e2e/Dockerfile-spp-platform b/docker/e2e/Dockerfile-spp-platform index f6226195a..b529ea14b 100644 --- a/docker/e2e/Dockerfile-spp-platform +++ b/docker/e2e/Dockerfile-spp-platform @@ -20,8 +20,23 @@ RUN printf "\nspp-live-instrument:\n selector: \${SPP_LIVE_INSTRUMENT:default}\ RUN printf "\nexporter:\n selector: \${SPP_LIVE_VIEW:default}\n default:\n" \ >> /skywalking/config/application.yml -# replace default receiver-meter with spp-live-meter-receiver -RUN sed -i -z 's/receiver-meter:\n selector: \${SW_RECEIVER_METER:default}\n default:/receiver-meter:\n selector: \${SW_RECEIVER_METER:spp-live-meter-receiver}\n spp-live-meter-receiver:/' /skywalking/config/application.yml +# replace default receiver-meter with spp-receiver-meter +RUN sed -i -z 's/receiver-meter:\n selector: \${SW_RECEIVER_METER:default\}\n default:/receiver-meter:\n selector: \${SW_RECEIVER_METER:spp-receiver-meter}\n spp-receiver-meter:/' /skywalking/config/application.yml + +# replace default receiver-trace with spp-receiver-trace +RUN sed -i -z 's/receiver-trace:\n selector: \${SW_RECEIVER_TRACE:default\}\n default:/receiver-trace:\n selector: \${SW_RECEIVER_TRACE:spp-receiver-trace}\n spp-receiver-trace:/' /skywalking/config/application.yml + +# replace default event-analyzer with spp-event-analyzer +RUN sed -i -z 's/event-analyzer:\n selector: \${SW_EVENT_ANALYZER:default}\n default:/event-analyzer:\n selector: \${SW_EVENT_ANALYZER:spp-event-analyzer}\n spp-event-analyzer:/' /skywalking/config/application.yml + +# replace default receiver-jvm with spp-receiver-jvm +RUN sed -i -z 's/receiver-jvm:\n selector: \${SW_RECEIVER_JVM:default\}\n default:/receiver-jvm:\n selector: \${SW_RECEIVER_JVM:spp-receiver-jvm}\n spp-receiver-jvm:/' /skywalking/config/application.yml + +# replace default receiver-log with spp-receiver-log +RUN sed -i -z 's/receiver-log:\n selector: \${SW_RECEIVER_LOG:default\}\n default:/receiver-log:\n selector: \${SW_RECEIVER_LOG:spp-receiver-log}\n spp-receiver-log:/' /skywalking/config/application.yml + +# replace default receiver-register with spp-receiver-register +RUN sed -i -z 's/receiver-register:\n selector: \${SW_RECEIVER_REGISTER:default\}\n default:/receiver-register:\n selector: \${SW_RECEIVER_REGISTER:spp-receiver-register}\n spp-receiver-register:/' /skywalking/config/application.yml ADD ./config/spp-platform.crt /skywalking/config/ ADD ./config/spp-platform.key /skywalking/config/ diff --git a/docker/e2e/spp-probe-platform.yml b/docker/e2e/spp-probe-platform.yml index e06e80365..ca5dbde01 100644 --- a/docker/e2e/spp-probe-platform.yml +++ b/docker/e2e/spp-probe-platform.yml @@ -1,5 +1,5 @@ spp: - enabled: ${SPP_PROBE_ENABLED:-true} + enabled: ${SPP_PROBE_ENABLED:-false} authentication: client_id: ${SPP_PROBE_CLIENT_ID:-test-id} client_secret: ${SPP_PROBE_CLIENT_SECRET:-test-secret} @@ -10,14 +10,13 @@ spp: delete_probe_directory_on_boot: ${SPP_PROBE_DELETE_PROBE_DIRECTORY_ON_BOOT:-false} wait_for_platform: ${SPP_PROBE_WAIT_FOR_PLATFORM:-false} quiet_mode: ${SPP_PROBE_QUIET_MODE:-false} + application: + environment: ${SPP_APPLICATION_ENVIRONMENT:-test} + version: ${SPP_APPLICATION_VERSION:-test} + git_commit: ${SPP_APPLICATION_GIT_COMMIT:-test} skywalking: logging: level: "DEBUG" agent: service_name: "spp-platform-ci" - -application: - environment: "ci" - version: "1.0.0" - git_commit: "8d9b0d9" diff --git a/platform/build.gradle.kts b/platform/build.gradle.kts index 034826617..4e73a62e6 100644 --- a/platform/build.gradle.kts +++ b/platform/build.gradle.kts @@ -79,6 +79,8 @@ subprojects { compileOnly("com.graphql-java:graphql-java:20.2") //tied to SkyWalking OAP version compileOnly("com.google.protobuf:protobuf-java:3.21.8") //tied to SkyWalking OAP version compileOnly("io.grpc:grpc-api:1.49.0") //tied to SkyWalking OAP version + compileOnly("io.grpc:grpc-stub:1.49.0") //tied to SkyWalking OAP version + compileOnly("com.linecorp.armeria:armeria:1.23.1") //tied to SkyWalking OAP version implementation("io.vertx:vertx-auth-jwt:$vertxVersion") implementation("io.vertx:vertx-redis-client:$vertxVersion") implementation("io.vertx:vertx-tcp-eventbus-bridge:$vertxVersion") diff --git a/platform/common/src/main/kotlin/spp/platform/common/util/ContextUtil.kt b/platform/common/src/main/kotlin/spp/platform/common/util/ContextUtil.kt index ac0c5f3ac..05b820749 100644 --- a/platform/common/src/main/kotlin/spp/platform/common/util/ContextUtil.kt +++ b/platform/common/src/main/kotlin/spp/platform/common/util/ContextUtil.kt @@ -30,6 +30,9 @@ object ContextUtil { @JvmStatic val TENANT_ID = Context.key("spp-platform.tenant-id")!! + @JvmStatic + val COMMIT_ID = Context.key("spp-platform.commit-id")!! + @JvmStatic fun addToVertx(context: Context?) { if (context == null) return @@ -55,5 +58,12 @@ object ContextUtil { vertxContext.removeLocal("tenant_id") } } + COMMIT_ID.get(context).let { + if (it != null) { + vertxContext.putLocal("commit_id", it) + } else { + vertxContext.removeLocal("commit_id") + } + } } } diff --git a/platform/core/build.gradle.kts b/platform/core/build.gradle.kts index 94f10854d..1f82a8f46 100644 --- a/platform/core/build.gradle.kts +++ b/platform/core/build.gradle.kts @@ -8,6 +8,7 @@ plugins { val platformGroup: String by project val projectVersion: String by project +val skywalkingVersion: String by project group = platformGroup version = project.properties["platformVersion"] as String? ?: projectVersion @@ -40,6 +41,18 @@ configure { dependencies { compileOnly(project(":platform:storage")) implementation(project(":platform:common")) + compileOnly("org.apache.skywalking:skywalking-meter-receiver-plugin:$skywalkingVersion") { + isTransitive = false + } + compileOnly("org.apache.skywalking:skywalking-jvm-receiver-plugin:$skywalkingVersion") { + isTransitive = false + } + compileOnly("org.apache.skywalking:skywalking-log-recevier-plugin:$skywalkingVersion") { + isTransitive = false + } + compileOnly("org.apache.skywalking:skywalking-management-receiver-plugin:$skywalkingVersion") { + isTransitive = false + } //todo: properly add test dependency testImplementation(project(":platform:common").dependencyProject.extensions.getByType(SourceSetContainer::class).test.get().output) diff --git a/platform/core/src/main/kotlin/spp/platform/core/SourcePlatform.kt b/platform/core/src/main/kotlin/spp/platform/core/SourcePlatform.kt index b4c234ef5..0b5941fa6 100644 --- a/platform/core/src/main/kotlin/spp/platform/core/SourcePlatform.kt +++ b/platform/core/src/main/kotlin/spp/platform/core/SourcePlatform.kt @@ -186,15 +186,16 @@ class SourcePlatform(private val manager: ModuleManager) : CoroutineVerticle() { } //Start services + val serviceProvider = ServiceProvider(jwt, manager) vertx.deployVerticle( - ServiceProvider(jwt, manager), + serviceProvider, DeploymentOptions().setConfig(config.put("SPP_INSTANCE_ID", SPP_INSTANCE_ID)) ).await() //Add SkyWalking interceptors val grpcHandlerRegister = manager.find(SharingServerModule.NAME) .provider().getService(GRPCHandlerRegister::class.java) - grpcHandlerRegister.addFilter(SkyWalkingGrpcInterceptor(vertx, config)) + grpcHandlerRegister.addFilter(SkyWalkingGrpcInterceptor(vertx, config, serviceProvider.managementService)) vertx.deployVerticle(SkyWalkingGraphqlInterceptor(router), DeploymentOptions().setConfig(config)).await() if (httpSslEnabled) { diff --git a/platform/core/src/main/kotlin/spp/platform/core/interceptors/SkyWalkingGrpcInterceptor.kt b/platform/core/src/main/kotlin/spp/platform/core/interceptors/SkyWalkingGrpcInterceptor.kt index b94ad0c55..ba4389555 100644 --- a/platform/core/src/main/kotlin/spp/platform/core/interceptors/SkyWalkingGrpcInterceptor.kt +++ b/platform/core/src/main/kotlin/spp/platform/core/interceptors/SkyWalkingGrpcInterceptor.kt @@ -21,18 +21,24 @@ import com.google.common.cache.CacheBuilder import io.grpc.* import io.vertx.core.Vertx import io.vertx.core.json.JsonObject +import io.vertx.kotlin.coroutines.await import io.vertx.kotlin.coroutines.dispatcher import kotlinx.coroutines.runBlocking import mu.KotlinLogging import spp.platform.common.util.ContextUtil import spp.platform.storage.SourceStorage +import spp.protocol.platform.status.InstanceConnection +import spp.protocol.service.LiveManagementService import java.util.concurrent.TimeUnit -class SkyWalkingGrpcInterceptor(private val vertx: Vertx, private val config: JsonObject) : ServerInterceptor { +class SkyWalkingGrpcInterceptor( + private val vertx: Vertx, + private val config: JsonObject, + private val managementService: LiveManagementService +) : ServerInterceptor { companion object { private val log = KotlinLogging.logger {} - private val AUTH_HEAD_HEADER_NAME = Metadata.Key.of("Authentication", Metadata.ASCII_STRING_MARSHALLER) } @@ -41,11 +47,20 @@ class SkyWalkingGrpcInterceptor(private val vertx: Vertx, private val config: Js .expireAfterAccess(1, TimeUnit.MINUTES) .build() + /** + * Intercepts gRPC calls and checks for authentication, adds VCS data to the context, and adds the tenant ID to the + * context if it is present in the auth header. + */ override fun interceptCall( call: ServerCall, headers: Metadata?, next: ServerCallHandler ): ServerCall.Listener { + val clients = runBlocking(vertx.dispatcher()) { managementService.getClients().await() } + val clientOb = clients.getJsonArray("probes").firstOrNull() as? JsonObject//todo: find real client + val client = clientOb?.let { InstanceConnection(it) } + val commitId = (client?.meta?.get("application") as? JsonObject)?.getString("git_commit") + val authHeader = headers?.get(AUTH_HEAD_HEADER_NAME) if (authHeader != null && probeAuthCache.getIfPresent(authHeader) != null) { val authParts = authHeader.split(":") @@ -57,6 +72,7 @@ class SkyWalkingGrpcInterceptor(private val vertx: Vertx, private val config: Js .withValue(ContextUtil.CLIENT_ID, clientId) .withValue(ContextUtil.CLIENT_ACCESS, clientSecret) .withValue(ContextUtil.TENANT_ID, tenantId) + .withValue(ContextUtil.COMMIT_ID, commitId) return Contexts.interceptCall(context, call, headers, next) } else { val authEnabled = config.getJsonObject("client-access")?.getString("enabled")?.toBooleanStrictOrNull() @@ -90,6 +106,7 @@ class SkyWalkingGrpcInterceptor(private val vertx: Vertx, private val config: Js .withValue(ContextUtil.CLIENT_ID, clientId) .withValue(ContextUtil.CLIENT_ACCESS, clientSecret) .withValue(ContextUtil.TENANT_ID, tenantId) + .withValue(ContextUtil.COMMIT_ID, commitId) Contexts.interceptCall(context, call, headers, next) } } diff --git a/platform/core/src/main/kotlin/spp/platform/core/service/ServiceProvider.kt b/platform/core/src/main/kotlin/spp/platform/core/service/ServiceProvider.kt index b8c274e22..e0f511ba8 100644 --- a/platform/core/src/main/kotlin/spp/platform/core/service/ServiceProvider.kt +++ b/platform/core/src/main/kotlin/spp/platform/core/service/ServiceProvider.kt @@ -51,7 +51,7 @@ class ServiceProvider( private lateinit var discovery: ServiceDiscovery private lateinit var managementServiceRecord: Record - private lateinit var managementService: LiveManagementService + lateinit var managementService: LiveManagementService override suspend fun start() { try { diff --git a/platform/core/src/main/kotlin/spp/platform/core/vcs/ServiceVCS.kt b/platform/core/src/main/kotlin/spp/platform/core/vcs/ServiceVCS.kt new file mode 100644 index 000000000..cdf55487b --- /dev/null +++ b/platform/core/src/main/kotlin/spp/platform/core/vcs/ServiceVCS.kt @@ -0,0 +1,51 @@ +/* + * Source++, the continuous feedback platform for developers. + * Copyright (C) 2022-2023 CodeBrig, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package spp.platform.core.vcs + +import com.google.protobuf.Message +import org.apache.skywalking.apm.network.language.agent.v3.MeterData +import spp.platform.common.util.ContextUtil + +object ServiceVCS { + + fun getServiceName(message: Message): String { + if (message.descriptorForType.findFieldByName("service") != null) { + val service = message.getField(message.descriptorForType.findFieldByName("service")).toString() + if (service.isEmpty() && message is MeterData) { + return "" // not all MeterData messages have a service name + } + require(service.isNotEmpty()) { "Message ${message.descriptorForType} does not have a service name" } + + return service + getCommitId() + } else if (message.descriptorForType.findFieldByName("source") != null) { + val source = message.getField(message.descriptorForType.findFieldByName("source")) + if (source is Message) { + val service = source.getField(source.descriptorForType.findFieldByName("service")).toString() + require(service.isNotEmpty()) { "Message ${message.descriptorForType} does not have a service name" } + + return service + getCommitId() + } + } + + throw IllegalArgumentException("Message " + message.descriptorForType + " does not have a service name") + } + + private fun getCommitId(): String { + return ContextUtil.COMMIT_ID.get()?.let { "|$it" } ?: "" + } +} diff --git a/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSEventModuleProvider.kt b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSEventModuleProvider.kt new file mode 100644 index 000000000..a6c332dd0 --- /dev/null +++ b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSEventModuleProvider.kt @@ -0,0 +1,63 @@ +/* + * Source++, the continuous feedback platform for developers. + * Copyright (C) 2022-2023 CodeBrig, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package spp.platform.core.vcs.providers + +import org.apache.skywalking.apm.network.event.v3.Event +import org.apache.skywalking.oap.server.analyzer.event.EventAnalyzerModule +import org.apache.skywalking.oap.server.analyzer.event.EventAnalyzerModuleProvider +import org.apache.skywalking.oap.server.analyzer.event.EventAnalyzerService +import org.apache.skywalking.oap.server.analyzer.event.EventAnalyzerServiceImpl +import org.apache.skywalking.oap.server.analyzer.event.listener.EventAnalyzerListener +import org.apache.skywalking.oap.server.library.module.ModuleManager +import spp.platform.core.vcs.ServiceVCS + +/** + * Overrides the default [EventAnalyzerServiceImpl] to add the VCS service name to the request. + */ +class VCSEventModuleProvider : EventAnalyzerModuleProvider() { + + override fun name(): String = "spp-event-analyzer" + + override fun start() { + super.start() + + val analyzerService = manager.find(EventAnalyzerModule.NAME).provider() + .getService(EventAnalyzerService::class.java) as EventAnalyzerServiceImpl + registerServiceImplementation( + EventAnalyzerService::class.java, + VCSEventAnalyzerService(analyzerService, manager) + ) + } + + private class VCSEventAnalyzerService( + private val delegate: EventAnalyzerServiceImpl, + manager: ModuleManager + ) : EventAnalyzerServiceImpl(manager) { + override fun analyze(event: Event) = delegate.analyze( + event.toBuilder().setSource( + event.source.toBuilder().setService( + ServiceVCS.getServiceName(event) + ).build() + ).build() + ) + + override fun add(factory: EventAnalyzerListener.Factory) = delegate.add(factory) + override fun getEventAnalyzerListenerFactories(): MutableList = + delegate.eventAnalyzerListenerFactories + } +} diff --git a/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSJVMModuleProvider.kt b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSJVMModuleProvider.kt new file mode 100644 index 000000000..162a67aba --- /dev/null +++ b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSJVMModuleProvider.kt @@ -0,0 +1,68 @@ +/* + * Source++, the continuous feedback platform for developers. + * Copyright (C) 2022-2023 CodeBrig, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package spp.platform.core.vcs.providers + +import io.grpc.stub.StreamObserver +import org.apache.skywalking.apm.network.common.v3.Commands +import org.apache.skywalking.apm.network.language.agent.v3.JVMMetricCollection +import org.apache.skywalking.oap.server.core.CoreModule +import org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoaderService +import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister +import org.apache.skywalking.oap.server.library.module.ModuleManager +import org.apache.skywalking.oap.server.receiver.jvm.provider.JVMModuleProvider +import org.apache.skywalking.oap.server.receiver.jvm.provider.JVMOALDefine +import org.apache.skywalking.oap.server.receiver.jvm.provider.handler.JVMMetricReportServiceHandler +import org.apache.skywalking.oap.server.receiver.jvm.provider.handler.JVMMetricReportServiceHandlerCompat +import org.apache.skywalking.oap.server.receiver.sharing.server.SharingServerModule +import spp.platform.core.vcs.ServiceVCS + +/** + * Overrides the default [JVMMetricReportServiceHandler] to add the VCS service name to the request. + */ +class VCSJVMModuleProvider : JVMModuleProvider() { + + override fun name(): String = "spp-receiver-jvm" + + override fun start() { + // load official analysis + manager.find(CoreModule.NAME) + .provider() + .getService(OALEngineLoaderService::class.java) + .load(JVMOALDefine.INSTANCE) + + val grpcHandlerRegister = manager.find(SharingServerModule.NAME) + .provider() + .getService(GRPCHandlerRegister::class.java) + val jvmMetricReportServiceHandler = + VCSJVMMetricReportServiceHandler(manager) + grpcHandlerRegister.addHandler(jvmMetricReportServiceHandler) + grpcHandlerRegister.addHandler(JVMMetricReportServiceHandlerCompat(jvmMetricReportServiceHandler)) + } + + private class VCSJVMMetricReportServiceHandler( + manager: ModuleManager, + private val delegate: JVMMetricReportServiceHandler = JVMMetricReportServiceHandler(manager) + ) : JVMMetricReportServiceHandler(manager) { + override fun collect(request: JVMMetricCollection, responseObserver: StreamObserver) = + delegate.collect( + request.toBuilder().setService( + ServiceVCS.getServiceName(request) + ).build(), responseObserver + ) + } +} diff --git a/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSLogModuleProvider.kt b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSLogModuleProvider.kt new file mode 100644 index 000000000..7724671ce --- /dev/null +++ b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSLogModuleProvider.kt @@ -0,0 +1,71 @@ +/* + * Source++, the continuous feedback platform for developers. + * Copyright (C) 2022-2023 CodeBrig, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package spp.platform.core.vcs.providers + +import com.linecorp.armeria.common.HttpMethod +import io.grpc.stub.StreamObserver +import org.apache.skywalking.apm.network.common.v3.Commands +import org.apache.skywalking.apm.network.logging.v3.LogData +import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister +import org.apache.skywalking.oap.server.core.server.HTTPHandlerRegister +import org.apache.skywalking.oap.server.library.module.ModuleManager +import org.apache.skywalking.oap.server.receiver.sharing.server.SharingServerModule +import org.apache.skywalking.oap.server.recevier.log.provider.LogModuleProvider +import org.apache.skywalking.oap.server.recevier.log.provider.handler.grpc.LogReportServiceGrpcHandler +import org.apache.skywalking.oap.server.recevier.log.provider.handler.rest.LogReportServiceHTTPHandler +import spp.platform.core.vcs.ServiceVCS + +/** + * Overrides the default [LogReportServiceGrpcHandler] to add the VCS service name to the request. + */ +class VCSLogModuleProvider : LogModuleProvider() { + + override fun name(): String = "spp-receiver-log" + + override fun start() { + val grpcHandlerRegister = manager.find(SharingServerModule.NAME) + .provider() + .getService(GRPCHandlerRegister::class.java) + + grpcHandlerRegister.addHandler(VCSLogReportServiceGrpcHandler(manager)) + + val httpHandlerRegister = manager.find(SharingServerModule.NAME) + .provider() + .getService(HTTPHandlerRegister::class.java) + httpHandlerRegister.addHandler(LogReportServiceHTTPHandler(manager), listOf(HttpMethod.POST)) + } + + private class VCSLogReportServiceGrpcHandler( + manager: ModuleManager, + private val delegate: LogReportServiceGrpcHandler = LogReportServiceGrpcHandler(manager) + ) : LogReportServiceGrpcHandler(manager) { + override fun collect(responseObserver: StreamObserver): StreamObserver { + val streamObserver = delegate.collect(responseObserver) + return object : StreamObserver { + override fun onNext(value: LogData) = streamObserver.onNext( + value.toBuilder().setService( + ServiceVCS.getServiceName(value) + ).build() + ) + + override fun onError(t: Throwable) = streamObserver.onError(t) + override fun onCompleted() = streamObserver.onCompleted() + } + } + } +} diff --git a/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSMeterReceiverProvider.kt b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSMeterReceiverProvider.kt new file mode 100644 index 000000000..92200ae8f --- /dev/null +++ b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSMeterReceiverProvider.kt @@ -0,0 +1,82 @@ +/* + * Source++, the continuous feedback platform for developers. + * Copyright (C) 2022-2023 CodeBrig, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package spp.platform.core.vcs.providers + +import io.grpc.stub.StreamObserver +import org.apache.skywalking.apm.network.common.v3.Commands +import org.apache.skywalking.apm.network.language.agent.v3.MeterData +import org.apache.skywalking.apm.network.language.agent.v3.MeterDataCollection +import org.apache.skywalking.oap.server.analyzer.module.AnalyzerModule +import org.apache.skywalking.oap.server.analyzer.provider.meter.process.IMeterProcessService +import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister +import org.apache.skywalking.oap.server.library.module.ModuleManager +import org.apache.skywalking.oap.server.receiver.meter.provider.MeterReceiverProvider +import org.apache.skywalking.oap.server.receiver.meter.provider.handler.MeterServiceHandler +import org.apache.skywalking.oap.server.receiver.meter.provider.handler.MeterServiceHandlerCompat +import org.apache.skywalking.oap.server.receiver.sharing.server.SharingServerModule +import spp.platform.core.vcs.ServiceVCS + +/** + * Overrides the default [MeterServiceHandler] to add the VCS service name to the request. + */ +class VCSMeterReceiverProvider : MeterReceiverProvider() { + + override fun name(): String = "spp-receiver-meter" + + override fun start() { + //todo: LiveMeterProcessService + val processService = manager.find(AnalyzerModule.NAME) + .provider() + .getService(IMeterProcessService::class.java) + val grpcHandlerRegister = manager.find(SharingServerModule.NAME) + .provider() + .getService(GRPCHandlerRegister::class.java) + val meterServiceHandlerCompat = VCSMeterServiceHandler(manager, processService!!) + grpcHandlerRegister.addHandler(meterServiceHandlerCompat) + grpcHandlerRegister.addHandler(MeterServiceHandlerCompat(meterServiceHandlerCompat)) + } + + private class VCSMeterServiceHandler( + manager: ModuleManager, + processService: IMeterProcessService, + private val delegate: MeterServiceHandler = MeterServiceHandler(manager, processService) + ) : MeterServiceHandler(manager, processService) { + override fun collect(responseObserver: StreamObserver): StreamObserver { + val streamObserver = delegate.collect(responseObserver) + return object : StreamObserver { + override fun onNext(value: MeterData) = streamObserver.onNext( + value.toBuilder().setService( + ServiceVCS.getServiceName(value) + ).build() + ) + + override fun onError(t: Throwable) = streamObserver.onError(t) + override fun onCompleted() = streamObserver.onCompleted() + } + } + + override fun collectBatch(responseObserver: StreamObserver): StreamObserver { + val streamObserver = delegate.collectBatch(responseObserver) + return object : StreamObserver { + override fun onNext(value: MeterDataCollection) = streamObserver.onNext(value) + override fun onError(t: Throwable) = streamObserver.onError(t) + override fun onCompleted() = streamObserver.onCompleted() + } + } + } +} diff --git a/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSRegisterModuleProvider.kt b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSRegisterModuleProvider.kt new file mode 100644 index 000000000..66bed49bf --- /dev/null +++ b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSRegisterModuleProvider.kt @@ -0,0 +1,76 @@ +/* + * Source++, the continuous feedback platform for developers. + * Copyright (C) 2022-2023 CodeBrig, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package spp.platform.core.vcs.providers + +import com.linecorp.armeria.common.HttpMethod +import io.grpc.stub.StreamObserver +import org.apache.skywalking.apm.network.common.v3.Commands +import org.apache.skywalking.apm.network.management.v3.InstancePingPkg +import org.apache.skywalking.apm.network.management.v3.InstanceProperties +import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister +import org.apache.skywalking.oap.server.core.server.HTTPHandlerRegister +import org.apache.skywalking.oap.server.library.module.ModuleManager +import org.apache.skywalking.oap.server.receiver.register.provider.RegisterModuleProvider +import org.apache.skywalking.oap.server.receiver.register.provider.handler.v8.grpc.ManagementServiceGRPCHandler +import org.apache.skywalking.oap.server.receiver.register.provider.handler.v8.grpc.ManagementServiceGrpcHandlerCompat +import org.apache.skywalking.oap.server.receiver.register.provider.handler.v8.rest.ManagementServiceHTTPHandler +import org.apache.skywalking.oap.server.receiver.sharing.server.SharingServerModule +import spp.platform.core.vcs.ServiceVCS + +/** + * Overrides the default [ManagementServiceGRPCHandler] to add the VCS service name to the request. + */ +class VCSRegisterModuleProvider : RegisterModuleProvider() { + + override fun name(): String = "spp-receiver-register" + + override fun start() { + val grpcHandlerRegister = manager.find(SharingServerModule.NAME) + .provider() + .getService(GRPCHandlerRegister::class.java) + val managementServiceHTTPHandler = + VCSManagementServiceGRPCHandler(manager) + grpcHandlerRegister.addHandler(managementServiceHTTPHandler) + grpcHandlerRegister.addHandler(ManagementServiceGrpcHandlerCompat(managementServiceHTTPHandler)) + + val httpHandlerRegister = manager.find(SharingServerModule.NAME) + .provider() + .getService(HTTPHandlerRegister::class.java) + httpHandlerRegister.addHandler(ManagementServiceHTTPHandler(manager), listOf(HttpMethod.POST)) + } + + private class VCSManagementServiceGRPCHandler( + manager: ModuleManager, + private val delegate: ManagementServiceGRPCHandler = ManagementServiceGRPCHandler(manager) + ) : ManagementServiceGRPCHandler(manager) { + + override fun reportInstanceProperties(request: InstanceProperties, responseObserver: StreamObserver) = + delegate.reportInstanceProperties( + request.toBuilder().setService( + ServiceVCS.getServiceName(request) + ).build(), responseObserver + ) + + override fun keepAlive(request: InstancePingPkg, responseObserver: StreamObserver) = + delegate.keepAlive( + request.toBuilder().setService( + ServiceVCS.getServiceName(request) + ).build(), responseObserver + ) + } +} diff --git a/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSTraceModuleProvider.kt b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSTraceModuleProvider.kt new file mode 100644 index 000000000..411ef77dd --- /dev/null +++ b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSTraceModuleProvider.kt @@ -0,0 +1,93 @@ +/* + * Source++, the continuous feedback platform for developers. + * Copyright (C) 2022-2023 CodeBrig, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package spp.platform.core.vcs.providers + +import com.linecorp.armeria.common.HttpMethod +import io.grpc.stub.StreamObserver +import org.apache.skywalking.apm.network.common.v3.Commands +import org.apache.skywalking.apm.network.language.agent.v3.SegmentCollection +import org.apache.skywalking.apm.network.language.agent.v3.SegmentObject +import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister +import org.apache.skywalking.oap.server.core.server.HTTPHandlerRegister +import org.apache.skywalking.oap.server.library.module.ModuleManager +import org.apache.skywalking.oap.server.receiver.sharing.server.SharingServerModule +import org.apache.skywalking.oap.server.receiver.trace.provider.TraceModuleProvider +import org.apache.skywalking.oap.server.receiver.trace.provider.handler.v8.grpc.SpanAttachedEventReportServiceHandler +import org.apache.skywalking.oap.server.receiver.trace.provider.handler.v8.grpc.TraceSegmentReportServiceHandler +import org.apache.skywalking.oap.server.receiver.trace.provider.handler.v8.grpc.TraceSegmentReportServiceHandlerCompat +import org.apache.skywalking.oap.server.receiver.trace.provider.handler.v8.rest.TraceSegmentReportHandler +import spp.platform.core.vcs.ServiceVCS + +/** + * Overrides the default [TraceSegmentReportServiceHandler] to add the VCS service name to the request. + */ +class VCSTraceModuleProvider : TraceModuleProvider() { + + override fun name(): String = "spp-receiver-trace" + + override fun start() { + val grpcHandlerRegister = manager.find(SharingServerModule.NAME) + .provider() + .getService(GRPCHandlerRegister::class.java) + val httpHandlerRegister = manager.find(SharingServerModule.NAME) + .provider() + .getService(HTTPHandlerRegister::class.java) + + val traceSegmentReportServiceHandler = VCSTraceSegmentReportServiceHandler(manager) + grpcHandlerRegister.addHandler(traceSegmentReportServiceHandler) + grpcHandlerRegister.addHandler(TraceSegmentReportServiceHandlerCompat(traceSegmentReportServiceHandler)) + grpcHandlerRegister.addHandler(SpanAttachedEventReportServiceHandler(manager)) + + httpHandlerRegister.addHandler( + TraceSegmentReportHandler(manager), + listOf(HttpMethod.POST) + ) + } + + private class VCSTraceSegmentReportServiceHandler( + moduleManager: ModuleManager, + private val delegate: TraceSegmentReportServiceHandler = TraceSegmentReportServiceHandler(moduleManager) + ) : TraceSegmentReportServiceHandler(moduleManager) { + + override fun collect(responseObserver: StreamObserver): StreamObserver { + val streamObserver = delegate.collect(responseObserver) + return object : StreamObserver { + override fun onNext(value: SegmentObject) = streamObserver.onNext( + value.toBuilder().setService( + ServiceVCS.getServiceName(value) + ).build() + ) + + override fun onError(t: Throwable) = streamObserver.onError(t) + override fun onCompleted() = streamObserver.onCompleted() + } + } + + override fun collectInSync(request: SegmentCollection, responseObserver: StreamObserver) { + delegate.collectInSync(request, object : StreamObserver { + override fun onNext(value: Commands) { + //todo: ContinuousProfilingPolicyQuery.ServiceName + responseObserver.onNext(value) + } + + override fun onError(t: Throwable) = responseObserver.onError(t) + override fun onCompleted() = responseObserver.onCompleted() + }) + } + } +} diff --git a/platform/core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine b/platform/core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine index f935ae2de..60882f3f4 100644 --- a/platform/core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine +++ b/platform/core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine @@ -1 +1 @@ -spp.platform.core.SourceCoreModule +spp.platform.core.SourceCoreModule \ No newline at end of file diff --git a/platform/core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider b/platform/core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider index 8dc582168..89236e625 100644 --- a/platform/core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider +++ b/platform/core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider @@ -1 +1,7 @@ spp.platform.core.SourceCoreProvider +spp.platform.core.vcs.providers.VCSTraceModuleProvider +spp.platform.core.vcs.providers.VCSEventModuleProvider +spp.platform.core.vcs.providers.VCSJVMModuleProvider +spp.platform.core.vcs.providers.VCSLogModuleProvider +spp.platform.core.vcs.providers.VCSRegisterModuleProvider +spp.platform.core.vcs.providers.VCSMeterReceiverProvider \ No newline at end of file diff --git a/platform/processor/live-instrument/src/test/resources/spp-test-probe.yml b/platform/processor/live-instrument/src/test/resources/spp-test-probe.yml index 1d122e096..a4ee08e87 100644 --- a/platform/processor/live-instrument/src/test/resources/spp-test-probe.yml +++ b/platform/processor/live-instrument/src/test/resources/spp-test-probe.yml @@ -4,6 +4,11 @@ spp: client_secret: "test-secret" platform_host: "localhost" platform_port: 12800 + application: + environment: ${SPP_APPLICATION_ENVIRONMENT:-test} + version: ${SPP_APPLICATION_VERSION:-test} + git_commit: ${SPP_APPLICATION_GIT_COMMIT:-test} + skywalking: logging: level: "DEBUG" diff --git a/platform/processor/live-view/build.gradle.kts b/platform/processor/live-view/build.gradle.kts index 941d2b9cc..0b977b227 100644 --- a/platform/processor/live-view/build.gradle.kts +++ b/platform/processor/live-view/build.gradle.kts @@ -41,6 +41,15 @@ dependencies { compileOnly("org.apache.skywalking:skywalking-meter-receiver-plugin:$skywalkingVersion") { isTransitive = false } + compileOnly("org.apache.skywalking:skywalking-jvm-receiver-plugin:$skywalkingVersion") { + isTransitive = false + } + compileOnly("org.apache.skywalking:skywalking-log-recevier-plugin:$skywalkingVersion") { + isTransitive = false + } + compileOnly("org.apache.skywalking:skywalking-management-receiver-plugin:$skywalkingVersion") { + isTransitive = false + } testImplementation(project(":probes:jvm:boot")) testImplementation("org.apache.logging.log4j:log4j-core:2.20.0") diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/provider/LiveMeterReceiverProvider.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/provider/LiveMeterReceiverProvider.kt index f2449a58b..e8ff7e575 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/provider/LiveMeterReceiverProvider.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/provider/LiveMeterReceiverProvider.kt @@ -39,6 +39,5 @@ class LiveMeterReceiverProvider : MeterReceiverProvider() { .getService(IMeterProcessService::class.java) as MeterProcessService val analyzerModule = manager.find(AnalyzerModule.NAME).provider() analyzerModule.registerServiceImplementation(IMeterProcessService::class.java, LiveMeterProcessService(process)) - super.start() } } diff --git a/platform/processor/live-view/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider b/platform/processor/live-view/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider index 1213ca308..ab1f02b2f 100644 --- a/platform/processor/live-view/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider +++ b/platform/processor/live-view/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider @@ -1,2 +1 @@ -spp.processor.view.provider.LiveViewProvider -spp.processor.view.provider.LiveMeterReceiverProvider \ No newline at end of file +spp.processor.view.provider.LiveViewProvider \ No newline at end of file From f94d3e782574c02b6bb49235a479742aa0efc785 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 26 Jun 2023 18:05:59 -0500 Subject: [PATCH 02/31] Add more precise filtering for live metrics and logs based on service, serviceInstance and commitId, ensuring that only relevant subscribers receive updates. --- .../processor/view/impl/view/LiveLogView.kt | 29 +++++++++++++------ .../processor/view/impl/view/LiveMeterView.kt | 18 +++++++----- .../view/impl/view/util/EntityNaming.kt | 4 --- .../src/test/resources/spp-test-probe.yml | 5 ++++ 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt index 4133d9470..c5b519b03 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt @@ -28,9 +28,9 @@ import org.apache.skywalking.oap.log.analyzer.provider.log.listener.LogAnalysisL import org.apache.skywalking.oap.log.analyzer.provider.log.listener.LogAnalysisListenerFactory import org.apache.skywalking.oap.server.core.analysis.Layer import spp.platform.common.ClusterConnection +import spp.platform.common.util.ContextUtil import spp.processor.view.ViewProcessor import spp.processor.view.impl.view.model.LiveGaugeValueMetrics -import spp.processor.view.impl.view.util.EntityNaming.isSameService import spp.processor.view.impl.view.util.MetricTypeSubscriptionCache import spp.processor.view.impl.view.util.ViewSubscriber import spp.protocol.artifact.log.Log @@ -80,9 +80,14 @@ class LiveLogView(private val subscriptionCache: MetricTypeSubscriptionCache) : //remove subscribers with additional filters subs = subs.filter { - val service = it.subscription.artifactLocation?.service - if (service != null && !isSameService(service, logData.service)) { - return@filter false + val subLocation = it.subscription.artifactLocation + if (subLocation != null) { + val logDataLocation = subLocation.copy( + service = subLocation.service?.let { logData.service.substringBefore("|") }, + serviceInstance = subLocation.serviceInstance?.let { logData.serviceInstance }, + commitId = subLocation.commitId?.let { ContextUtil.COMMIT_ID.get() } + ) + return@filter subLocation.isSameLocation(logDataLocation) } return@filter true }.toSet() @@ -92,13 +97,19 @@ class LiveLogView(private val subscriptionCache: MetricTypeSubscriptionCache) : subbedArtifacts = subscriptionCache["service_logs"] if (subbedArtifacts != null) { - var subs = subbedArtifacts[logData.service].orEmpty() + subbedArtifacts["*"].orEmpty() + var subs = subbedArtifacts[logData.service.substringBefore("|")].orEmpty() + + subbedArtifacts["*"].orEmpty() //remove subscribers with additional filters subs = subs.filter { - val service = it.subscription.artifactLocation?.service - if (service != null && !isSameService(service, logData.service)) { - return@filter false + val subLocation = it.subscription.artifactLocation + if (subLocation != null) { + val logDataLocation = subLocation.copy( + service = subLocation.service?.let { logData.service.substringBefore("|") }, + serviceInstance = subLocation.serviceInstance?.let { logData.serviceInstance }, + commitId = subLocation.commitId?.let { ContextUtil.COMMIT_ID.get() } + ) + return@filter subLocation.isSameLocation(logDataLocation) } return@filter true }.toSet() @@ -118,7 +129,7 @@ class LiveLogView(private val subscriptionCache: MetricTypeSubscriptionCache) : val logSource = logData.tags.dataList.find { it.key == "source" }?.value val logLineNumber = logData.tags.dataList.find { it.key == "line" }?.value?.toInt() val logLocation = if (logSource != null) { - LiveSourceLocation( + LiveSourceLocation( //todo: this is different than logDataLocation above logSource, logLineNumber ?: -1, service = logData.service, diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt index 1e1001251..0d41fcf34 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt @@ -20,6 +20,7 @@ package spp.processor.view.impl.view import io.vertx.core.json.JsonArray import io.vertx.core.json.JsonObject import mu.KotlinLogging +import org.apache.skywalking.oap.server.core.analysis.IDManager import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics import org.apache.skywalking.oap.server.core.analysis.metrics.PercentMetrics import org.apache.skywalking.oap.server.core.analysis.metrics.WithMetadata @@ -31,7 +32,6 @@ import spp.platform.storage.SourceStorage import spp.processor.view.ViewProcessor import spp.processor.view.ViewProcessor.realtimeMetricCache import spp.processor.view.impl.view.util.* -import spp.processor.view.impl.view.util.EntityNaming.isSameService import spp.processor.view.model.LiveMetricConvert import spp.protocol.instrument.event.LiveMeterHit import java.time.Instant @@ -77,6 +77,7 @@ class LiveMeterView(private val subscriptionCache: MetricTypeSubscriptionCache) val jsonEvent = toViewEventJson(metrics, realTime) val metricService = EntityNaming.getServiceId(metrics) + val metricServiceName = metricService?.let { IDManager.ServiceID.analysisId(it).name } val metricServiceInstance = EntityNaming.getServiceInstanceId(metadata) if (metricName.startsWith("spp_")) { log.debug { "Processing Source++ metrics: {} - Data: {}".args(metricName, jsonEvent) } @@ -106,13 +107,14 @@ class LiveMeterView(private val subscriptionCache: MetricTypeSubscriptionCache) //remove subscribers with additional filters subs = subs.filter { - val service = it.subscription.artifactLocation?.service - if (service != null && metricService != null && !isSameService(metricService, service)) { - return@filter false - } - val serviceInstance = it.subscription.artifactLocation?.serviceInstance - if (serviceInstance != null && serviceInstance != metricServiceInstance) { - return@filter false + val subLocation = it.subscription.artifactLocation + if (subLocation != null) { + val metricsDataLocation = subLocation.copy( + service = subLocation.service?.let { metricServiceName?.substringBefore("|") }, + serviceInstance = subLocation.serviceInstance?.let { metricServiceInstance }, + commitId = subLocation.commitId?.let { metricServiceName?.substringAfter("|") } + ) + return@filter subLocation.isSameLocation(metricsDataLocation) } return@filter true }.toSet() diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/util/EntityNaming.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/util/EntityNaming.kt index 4e80a62b0..fc9b0d8ac 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/util/EntityNaming.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/util/EntityNaming.kt @@ -115,8 +115,4 @@ object EntityNaming { } return null } - - fun isSameService(serviceIdOrName: String, serviceName: String): Boolean { - return serviceIdOrName == serviceName || serviceIdOrName == IDManager.ServiceID.buildId(serviceName, true) - } } diff --git a/platform/processor/live-view/src/test/resources/spp-test-probe.yml b/platform/processor/live-view/src/test/resources/spp-test-probe.yml index c281edd85..42fafec8b 100644 --- a/platform/processor/live-view/src/test/resources/spp-test-probe.yml +++ b/platform/processor/live-view/src/test/resources/spp-test-probe.yml @@ -4,6 +4,11 @@ spp: client_secret: "test-secret" platform_host: "localhost" platform_port: 12800 + application: + environment: ${SPP_APPLICATION_ENVIRONMENT:-test} + version: ${SPP_APPLICATION_VERSION:-test} + git_commit: ${SPP_APPLICATION_GIT_COMMIT:-test} + skywalking: logging: level: "DEBUG" From e7aee84623ccff7e38811b16f49451d45c43a1ab Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 26 Jun 2023 18:16:24 -0500 Subject: [PATCH 03/31] ci: enable self probe --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 135887f61..c3a81f807 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,7 @@ env: GRADLE_OPTS: -Dorg.gradle.caching=true -Dorg.gradle.daemon=false -Xmx5g -Xms5g GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true GRADLE_BUILD_ACTION_CACHE_KEY_JOB: ${{ github.workflow }} + SPP_PROBE_ENABLED: "true" SPP_PROBE_WAIT_FOR_PLATFORM: "true" SPP_PROBE_PLATFORM_HOST: "https://cloud.sourceplus.plus" SPP_PROBE_SSL_ENABLED: "true" From 317f6a98f3930147c2af7291635d96d6f65f9e14 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 26 Jun 2023 20:34:18 -0500 Subject: [PATCH 04/31] Add the missing SPP_PROBE_ENABLED environment variable to docker-compose.yml, allowing users to enable/disable the SPP probe feature more easily --- docker/e2e/docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/e2e/docker-compose.yml b/docker/e2e/docker-compose.yml index 247c97c7f..27e1bdf56 100644 --- a/docker/e2e/docker-compose.yml +++ b/docker/e2e/docker-compose.yml @@ -18,6 +18,7 @@ services: dockerfile: Dockerfile-spp-platform environment: - JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5106 -javaagent:/tmp/spp-probe/spp-probe.jar + - SPP_PROBE_ENABLED=${SPP_PROBE_ENABLED} - SPP_PROBE_WAIT_FOR_PLATFORM=${SPP_PROBE_WAIT_FOR_PLATFORM} - SPP_PROBE_PLATFORM_HOST=${SPP_PROBE_PLATFORM_HOST} - SPP_PROBE_SSL_ENABLED=${SPP_PROBE_SSL_ENABLED} From b048e7d20cab4fcffffd6712df5f0efa07a1405f Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 26 Jun 2023 21:00:44 -0500 Subject: [PATCH 05/31] Add git commit and environment info to Docker setup --- .github/workflows/build.yml | 20 ++++++++++++++++++++ docker/e2e/docker-compose.yml | 2 ++ 2 files changed, 22 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c3a81f807..6da5dfd72 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,6 +83,11 @@ jobs: gradle-home-cache-excludes: | caches/modules-2/files-2.1/com.jetbrains.intellij.idea + - name: Set env + run: | + echo "SPP_APPLICATION_GIT_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV + echo "SPP_APPLICATION_ENVIRONMENT=ci" >> $GITHUB_ENV + - name: Start spp-platform id: start_platform run: ./gradlew :platform:assembleUp @@ -169,6 +174,11 @@ jobs: gradle-home-cache-excludes: | caches/modules-2/files-2.1/com.jetbrains.intellij.idea + - name: Set env + run: | + echo "SPP_APPLICATION_GIT_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV + echo "SPP_APPLICATION_ENVIRONMENT=ci" >> $GITHUB_ENV + - name: Start spp-platform id: start_platform run: ./gradlew :platform:assembleUp @@ -245,6 +255,11 @@ jobs: echo " environment:" >> docker-compose.override.yml echo " - SPP_CLIENT_ACCESS_ENABLED=false" >> docker-compose.override.yml + - name: Set env + run: | + echo "SPP_APPLICATION_GIT_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV + echo "SPP_APPLICATION_ENVIRONMENT=ci" >> $GITHUB_ENV + - name: Start spp-platform id: start_platform run: ./gradlew :platform:assembleUp @@ -307,6 +322,11 @@ jobs: gradle-home-cache-excludes: | caches/modules-2/files-2.1/com.jetbrains.intellij.idea + - name: Set env + run: | + echo "SPP_APPLICATION_GIT_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV + echo "SPP_APPLICATION_ENVIRONMENT=ci" >> $GITHUB_ENV + - name: Start spp-platform id: start_platform run: ./gradlew :platform:assembleUp diff --git a/docker/e2e/docker-compose.yml b/docker/e2e/docker-compose.yml index 27e1bdf56..09f108d85 100644 --- a/docker/e2e/docker-compose.yml +++ b/docker/e2e/docker-compose.yml @@ -18,6 +18,8 @@ services: dockerfile: Dockerfile-spp-platform environment: - JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5106 -javaagent:/tmp/spp-probe/spp-probe.jar + - SPP_APPLICATION_GIT_COMMIT=${SPP_APPLICATION_GIT_COMMIT} + - SPP_APPLICATION_ENVIRONMENT=${SPP_APPLICATION_ENVIRONMENT} - SPP_PROBE_ENABLED=${SPP_PROBE_ENABLED} - SPP_PROBE_WAIT_FOR_PLATFORM=${SPP_PROBE_WAIT_FOR_PLATFORM} - SPP_PROBE_PLATFORM_HOST=${SPP_PROBE_PLATFORM_HOST} From ff3661cb941c18861ac5049c89a0eb554a6fd981 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 26 Jun 2023 21:03:35 -0500 Subject: [PATCH 06/31] Add git commit and environment to e2e config --- docker/e2e/.env | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/e2e/.env b/docker/e2e/.env index 6113d2db0..ac9bcfe0a 100644 --- a/docker/e2e/.env +++ b/docker/e2e/.env @@ -4,4 +4,6 @@ SPP_PROBE_SSL_ENABLED=false SPP_PROBE_CLIENT_ID=test-id SPP_PROBE_CLIENT_SECRET=test-secret SPP_PROBE_TENANT_ID=test-tenant -SPP_PROBE_PLATFORM_CERTIFICATE= \ No newline at end of file +SPP_PROBE_PLATFORM_CERTIFICATE= +SPP_APPLICATION_GIT_COMMIT= +SPP_APPLICATION_ENVIRONMENT=local \ No newline at end of file From b139bf959fd79994d4c37c5d586e863573ae6223 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 26 Jun 2023 21:07:34 -0500 Subject: [PATCH 07/31] Add SPP_PROBE_ENABLED to e2e .env file --- docker/e2e/.env | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/e2e/.env b/docker/e2e/.env index ac9bcfe0a..1586fc281 100644 --- a/docker/e2e/.env +++ b/docker/e2e/.env @@ -1,3 +1,4 @@ +SPP_PROBE_ENABLED=false SPP_PROBE_WAIT_FOR_PLATFORM=false SPP_PROBE_PLATFORM_HOST=localhost SPP_PROBE_SSL_ENABLED=false From a018025d4ce241211b8196261aa7e583d55f4094 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 26 Jun 2023 21:14:34 -0500 Subject: [PATCH 08/31] chore: clean --- docker/e2e/spp-probe-platform.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/e2e/spp-probe-platform.yml b/docker/e2e/spp-probe-platform.yml index ca5dbde01..c7f21ae04 100644 --- a/docker/e2e/spp-probe-platform.yml +++ b/docker/e2e/spp-probe-platform.yml @@ -11,9 +11,9 @@ spp: wait_for_platform: ${SPP_PROBE_WAIT_FOR_PLATFORM:-false} quiet_mode: ${SPP_PROBE_QUIET_MODE:-false} application: - environment: ${SPP_APPLICATION_ENVIRONMENT:-test} - version: ${SPP_APPLICATION_VERSION:-test} - git_commit: ${SPP_APPLICATION_GIT_COMMIT:-test} + environment: ${SPP_APPLICATION_ENVIRONMENT:-} + version: ${SPP_APPLICATION_VERSION:-} + git_commit: ${SPP_APPLICATION_GIT_COMMIT:-} skywalking: logging: From 8d7dda244b12cf17baa72fa39624a1d93576edb7 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Tue, 27 Jun 2023 13:32:47 -0500 Subject: [PATCH 09/31] Add VCSIntegrationTest to check for versioned breakpoint hits by instrument --- .../live-instrument/build.gradle.kts | 1 + .../kotlin/integration/VCSIntegrationTest.kt | 110 ++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 platform/processor/live-instrument/src/test/kotlin/integration/VCSIntegrationTest.kt diff --git a/platform/processor/live-instrument/build.gradle.kts b/platform/processor/live-instrument/build.gradle.kts index faa7b6a53..2a430c9e0 100644 --- a/platform/processor/live-instrument/build.gradle.kts +++ b/platform/processor/live-instrument/build.gradle.kts @@ -39,6 +39,7 @@ dependencies { compileOnly(project(":platform:storage")) testImplementation(project(":probes:jvm:boot")) + testCompileOnly(project(":probes:jvm:common")) testImplementation("org.apache.logging.log4j:log4j-core:2.20.0") //todo: properly add test dependency testImplementation(project(":platform:common").dependencyProject.extensions.getByType(SourceSetContainer::class).test.get().output) diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/VCSIntegrationTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/VCSIntegrationTest.kt new file mode 100644 index 000000000..11c856894 --- /dev/null +++ b/platform/processor/live-instrument/src/test/kotlin/integration/VCSIntegrationTest.kt @@ -0,0 +1,110 @@ +/* + * Source++, the continuous feedback platform for developers. + * Copyright (C) 2022-2023 CodeBrig, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package integration + +import io.vertx.core.json.JsonObject +import io.vertx.junit5.VertxTestContext +import io.vertx.kotlin.coroutines.await +import kotlinx.coroutines.delay +import kotlinx.coroutines.runBlocking +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.Isolated +import spp.probe.ProbeConfiguration +import spp.protocol.instrument.LiveBreakpoint +import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.service.listen.addBreakpointHitListener +import java.util.concurrent.atomic.AtomicInteger + +@Isolated +class VCSIntegrationTest : LiveInstrumentIntegrationTest() { + + private fun doTest() { + startEntrySpan("doTest") + addLineLabel("done") { Throwable().stackTrace[0].lineNumber } + stopSpan() + } + + @Test + fun `listen to versioned breakpoint hits by instrument`(): Unit = runBlocking { + setupLineLabels { + doTest() + } + + val probeId = ProbeConfiguration.PROBE_ID + managementService.updateActiveProbeMetadata( + probeId, + JsonObject().put( + "application", + JsonObject().put("git_commit", "test1") + ) + ).await() + delay(2000) + + val hitCount = AtomicInteger() + var testContext = VertxTestContext() + val instrument = instrumentService.addLiveInstrument( + LiveBreakpoint( + location = LiveSourceLocation( + VCSIntegrationTest::class.java.name, + getLineNumber("done"), + "spp-test-probe" + ), + applyImmediately = true, + id = testNameAsUniqueInstrumentId, + hitLimit = 2 + ) + ).await() + vertx.addBreakpointHitListener(instrument.id!!) { bpHit -> + log.info("Received breakpoint hit: $bpHit") + testContext.verify { + assertTrue(bpHit.stackTrace.elements.isNotEmpty()) + val topFrame = bpHit.stackTrace.elements.first() + assertEquals(1, topFrame.variables.size) + } + + if (hitCount.incrementAndGet() == 1) { + testContext.verify { + assertEquals(instrument.location.service + "|" + "test1", bpHit.service) + } + } else { + testContext.verify { + assertEquals(instrument.location.service + "|" + "test2", bpHit.service) + } + } + testContext.completeNow() + }.await() + + doTest() + errorOnTimeout(testContext) + testContext = VertxTestContext() + + managementService.updateActiveProbeMetadata( + probeId, + JsonObject().put( + "application", + JsonObject().put("git_commit", "test2") + ) + ).await() + delay(2000) + + doTest() + errorOnTimeout(testContext) + } +} From aa4138fb07c9e7e3a165ac72d1af64adfb893a9b Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Tue, 27 Jun 2023 14:51:38 -0500 Subject: [PATCH 10/31] Add integration tests for VCS live view and refactor existing tests --- ...egrationTest.kt => VCSLiveInstrumentIT.kt} | 4 +- .../integration/RealtimeLiveViewTest.kt | 2 - .../test/kotlin/integration/VCSLiveViewIT.kt | 157 ++++++++++++++++++ 3 files changed, 159 insertions(+), 4 deletions(-) rename platform/processor/live-instrument/src/test/kotlin/integration/{VCSIntegrationTest.kt => VCSLiveInstrumentIT.kt} (96%) create mode 100644 platform/processor/live-view/src/test/kotlin/integration/VCSLiveViewIT.kt diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/VCSIntegrationTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/VCSLiveInstrumentIT.kt similarity index 96% rename from platform/processor/live-instrument/src/test/kotlin/integration/VCSIntegrationTest.kt rename to platform/processor/live-instrument/src/test/kotlin/integration/VCSLiveInstrumentIT.kt index 11c856894..3781fabce 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/VCSIntegrationTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/VCSLiveInstrumentIT.kt @@ -33,7 +33,7 @@ import spp.protocol.service.listen.addBreakpointHitListener import java.util.concurrent.atomic.AtomicInteger @Isolated -class VCSIntegrationTest : LiveInstrumentIntegrationTest() { +class VCSLiveInstrumentIT : LiveInstrumentIntegrationTest() { private fun doTest() { startEntrySpan("doTest") @@ -62,7 +62,7 @@ class VCSIntegrationTest : LiveInstrumentIntegrationTest() { val instrument = instrumentService.addLiveInstrument( LiveBreakpoint( location = LiveSourceLocation( - VCSIntegrationTest::class.java.name, + VCSLiveInstrumentIT::class.java.name, getLineNumber("done"), "spp-test-probe" ), diff --git a/platform/processor/live-view/src/test/kotlin/integration/RealtimeLiveViewTest.kt b/platform/processor/live-view/src/test/kotlin/integration/RealtimeLiveViewTest.kt index d9bd8ab6a..9ea72057a 100644 --- a/platform/processor/live-view/src/test/kotlin/integration/RealtimeLiveViewTest.kt +++ b/platform/processor/live-view/src/test/kotlin/integration/RealtimeLiveViewTest.kt @@ -38,8 +38,6 @@ class RealtimeLiveViewTest : PlatformIntegrationTest() { @Test fun `realtime instance_jvm_cpu`(): Unit = runBlocking { - viewService.clearLiveViews().await() - val subscriptionId = viewService.addLiveView( LiveView( entityIds = mutableSetOf(MetricType.INSTANCE_JVM_CPU.asRealtime().metricId), diff --git a/platform/processor/live-view/src/test/kotlin/integration/VCSLiveViewIT.kt b/platform/processor/live-view/src/test/kotlin/integration/VCSLiveViewIT.kt new file mode 100644 index 000000000..b6ea84863 --- /dev/null +++ b/platform/processor/live-view/src/test/kotlin/integration/VCSLiveViewIT.kt @@ -0,0 +1,157 @@ +/* + * Source++, the continuous feedback platform for developers. + * Copyright (C) 2022-2023 CodeBrig, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package integration + +import io.vertx.core.json.JsonObject +import io.vertx.junit5.VertxTestContext +import io.vertx.kotlin.coroutines.await +import kotlinx.coroutines.delay +import kotlinx.coroutines.runBlocking +import org.apache.skywalking.oap.server.core.analysis.IDManager +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNotNull +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.Isolated +import spp.probe.ProbeConfiguration +import spp.protocol.artifact.metrics.MetricType +import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscription +import spp.protocol.view.LiveView +import spp.protocol.view.LiveViewConfig +import spp.protocol.view.LiveViewEvent + +@Isolated +class VCSLiveViewIT : PlatformIntegrationTest() { + + @Test + fun `specific versioned realtime instance_jvm_cpu`(): Unit = runBlocking { + val subscriptionId = viewService.addLiveView( + LiveView( + entityIds = mutableSetOf(MetricType.INSTANCE_JVM_CPU.asRealtime().metricId), + viewConfig = LiveViewConfig( + "test", + listOf(MetricType.INSTANCE_JVM_CPU.asRealtime().metricId) + ), + artifactLocation = LiveSourceLocation("", service = "spp-test-probe", commitId = "test1") + ) + ).await().subscriptionId!! + + val probeId = ProbeConfiguration.PROBE_ID + managementService.updateActiveProbeMetadata( + probeId, + JsonObject().put( + "application", + JsonObject().put("git_commit", "test1") + ) + ).await() + delay(2000) + var testContext = VertxTestContext() + verifyHit(testContext, subscriptionId, IDManager.ServiceID.buildId("spp-test-probe|test1", true)) + if (testContext.failed()) { + throw testContext.causeOfFailure() + } + + managementService.updateActiveProbeMetadata( + probeId, + JsonObject().put( + "application", + JsonObject().put("git_commit", "test2") + ) + ).await() + delay(2000) + testContext = VertxTestContext() + verifyHit(testContext, subscriptionId, IDManager.ServiceID.buildId("spp-test-probe|test2", true), false) + if (testContext.failed()) { + throw testContext.causeOfFailure() + } + + //clean up + assertNotNull(viewService.removeLiveView(subscriptionId).await()) + } + + @Test + fun `versioned realtime instance_jvm_cpu`(): Unit = runBlocking { + val subscriptionId = viewService.addLiveView( + LiveView( + entityIds = mutableSetOf(MetricType.INSTANCE_JVM_CPU.asRealtime().metricId), + viewConfig = LiveViewConfig( + "test", + listOf(MetricType.INSTANCE_JVM_CPU.asRealtime().metricId) + ), + artifactLocation = LiveSourceLocation("", service = "spp-test-probe") + ) + ).await().subscriptionId!! + + val probeId = ProbeConfiguration.PROBE_ID + managementService.updateActiveProbeMetadata( + probeId, + JsonObject().put( + "application", + JsonObject().put("git_commit", "test1") + ) + ).await() + delay(2000) + var testContext = VertxTestContext() + verifyHit(testContext, subscriptionId, IDManager.ServiceID.buildId("spp-test-probe|test1", true)) + if (testContext.failed()) { + throw testContext.causeOfFailure() + } + + managementService.updateActiveProbeMetadata( + probeId, + JsonObject().put( + "application", + JsonObject().put("git_commit", "test2") + ) + ).await() + delay(2000) + testContext = VertxTestContext() + verifyHit(testContext, subscriptionId, IDManager.ServiceID.buildId("spp-test-probe|test2", true)) + if (testContext.failed()) { + throw testContext.causeOfFailure() + } + + //clean up + assertNotNull(viewService.removeLiveView(subscriptionId).await()) + } + + private suspend fun verifyHit( + testContext: VertxTestContext, + subscriptionId: String, + verifyServiceId: String, + errorOnTimeout: Boolean = true + ) { + val consumer = vertx.eventBus().consumer(toLiveViewSubscription(subscriptionId)) + consumer.handler { + val liveViewEvent = LiveViewEvent(it.body()) + val rawMetrics = JsonObject(liveViewEvent.metricsData) + log.info("Received metrics: $rawMetrics") + + testContext.verify { + assertEquals(verifyServiceId, rawMetrics.getString("serviceId")) + } + testContext.completeNow() + } + if (errorOnTimeout) { + errorOnTimeout(testContext) + } else { + successOnTimeout(testContext) + } + consumer.unregister().await() + } +} From 93b3f6535ef2c2c94fc8d9ff8602d320c06db2e1 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Tue, 27 Jun 2023 14:52:03 -0500 Subject: [PATCH 11/31] Add common JVM probes to testCompileOnly in live-view build --- platform/processor/live-view/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/processor/live-view/build.gradle.kts b/platform/processor/live-view/build.gradle.kts index 0b977b227..2a25f5a75 100644 --- a/platform/processor/live-view/build.gradle.kts +++ b/platform/processor/live-view/build.gradle.kts @@ -52,6 +52,7 @@ dependencies { } testImplementation(project(":probes:jvm:boot")) + testCompileOnly(project(":probes:jvm:common")) testImplementation("org.apache.logging.log4j:log4j-core:2.20.0") //todo: properly add test dependency testImplementation(project(":platform:common").dependencyProject.extensions.getByType(SourceSetContainer::class).test.get().output) From c7ea5cea69b8530ce9ebd7c7e42bdafa08640314 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Tue, 27 Jun 2023 18:03:27 -0500 Subject: [PATCH 12/31] chore: re-impl LiveMeterProcessService --- .../vcs/providers/VCSMeterReceiverProvider.kt | 1 - .../view/impl/LiveMeterProcessService.kt | 23 +++++++++- .../provider/LiveMeterReceiverProvider.kt | 43 ------------------- .../view/provider/LiveViewProvider.kt | 12 ++++++ 4 files changed, 33 insertions(+), 46 deletions(-) delete mode 100644 platform/processor/live-view/src/main/kotlin/spp/processor/view/provider/LiveMeterReceiverProvider.kt diff --git a/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSMeterReceiverProvider.kt b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSMeterReceiverProvider.kt index 92200ae8f..afbb9d208 100644 --- a/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSMeterReceiverProvider.kt +++ b/platform/core/src/main/kotlin/spp/platform/core/vcs/providers/VCSMeterReceiverProvider.kt @@ -39,7 +39,6 @@ class VCSMeterReceiverProvider : MeterReceiverProvider() { override fun name(): String = "spp-receiver-meter" override fun start() { - //todo: LiveMeterProcessService val processService = manager.find(AnalyzerModule.NAME) .provider() .getService(IMeterProcessService::class.java) diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveMeterProcessService.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveMeterProcessService.kt index fbac9d2f3..11931ee96 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveMeterProcessService.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveMeterProcessService.kt @@ -18,16 +18,31 @@ package spp.processor.view.impl import org.apache.skywalking.apm.network.language.agent.v3.MeterData -import org.apache.skywalking.oap.server.analyzer.provider.meter.process.IMeterProcessService +import org.apache.skywalking.oap.meter.analyzer.MetricConvert +import org.apache.skywalking.oap.server.analyzer.provider.meter.config.MeterConfig import org.apache.skywalking.oap.server.analyzer.provider.meter.process.MeterProcessService import org.apache.skywalking.oap.server.analyzer.provider.meter.process.MeterProcessor +import org.apache.skywalking.oap.server.library.module.ModuleManager import spp.processor.view.model.LiveMetricConvert import spp.protocol.instrument.LiveMeter +import spp.protocol.instrument.meter.MeterPartition +import spp.protocol.view.rule.RulePartition -class LiveMeterProcessService(private val delegate: MeterProcessService) : IMeterProcessService by delegate { +/** + * Replaces the default meter process service to allows for processing + * meters with [MeterPartition]s via [RulePartition]s. + */ +class LiveMeterProcessService( + private val delegate: MeterProcessService, + manager: ModuleManager, +) : MeterProcessService(manager) { private val existingPartitions = mutableSetOf() + override fun start(configs: MutableList?) { + delegate.start(configs) + } + override fun createProcessor(): MeterProcessor { val processor = delegate.createProcessor() return object : MeterProcessor(delegate) { @@ -58,4 +73,8 @@ class LiveMeterProcessService(private val delegate: MeterProcessService) : IMete override fun process() = processor.process() } } + + override fun converts(): MutableList { + return delegate.converts() + } } diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/provider/LiveMeterReceiverProvider.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/provider/LiveMeterReceiverProvider.kt deleted file mode 100644 index e8ff7e575..000000000 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/provider/LiveMeterReceiverProvider.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Source++, the continuous feedback platform for developers. - * Copyright (C) 2022-2023 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.processor.view.provider - -import org.apache.skywalking.oap.server.analyzer.module.AnalyzerModule -import org.apache.skywalking.oap.server.analyzer.provider.meter.process.IMeterProcessService -import org.apache.skywalking.oap.server.analyzer.provider.meter.process.MeterProcessService -import org.apache.skywalking.oap.server.receiver.meter.provider.MeterReceiverProvider -import spp.processor.view.impl.LiveMeterProcessService -import spp.protocol.instrument.meter.MeterPartition -import spp.protocol.view.rule.RulePartition - -/** - * Replaces the default meter process service with the live meter process service. - * This is done to allow [LiveMeterProcessService] to process meters with [MeterPartition]s via [RulePartition]s. - */ -class LiveMeterReceiverProvider : MeterReceiverProvider() { - - override fun name(): String = "spp-live-meter-receiver" - - override fun start() { - val process = manager.find(AnalyzerModule.NAME) - .provider() - .getService(IMeterProcessService::class.java) as MeterProcessService - val analyzerModule = manager.find(AnalyzerModule.NAME).provider() - analyzerModule.registerServiceImplementation(IMeterProcessService::class.java, LiveMeterProcessService(process)) - } -} diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/provider/LiveViewProvider.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/provider/LiveViewProvider.kt index 3fc873c39..3db4db29d 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/provider/LiveViewProvider.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/provider/LiveViewProvider.kt @@ -23,6 +23,8 @@ import kotlinx.coroutines.launch import mu.KotlinLogging import org.apache.skywalking.oap.log.analyzer.module.LogAnalyzerModule import org.apache.skywalking.oap.server.analyzer.module.AnalyzerModule +import org.apache.skywalking.oap.server.analyzer.provider.meter.process.IMeterProcessService +import org.apache.skywalking.oap.server.analyzer.provider.meter.process.MeterProcessService import org.apache.skywalking.oap.server.core.CoreModule import org.apache.skywalking.oap.server.core.CoreModuleConfig import org.apache.skywalking.oap.server.core.analysis.manual.log.LogRecord @@ -46,6 +48,7 @@ import org.joor.Reflect import spp.platform.common.ClusterConnection import spp.processor.view.ViewProcessor import spp.processor.view.ViewProcessor.liveViewService +import spp.processor.view.impl.LiveMeterProcessService import spp.processor.view.impl.SPPRemoteClient import java.util.concurrent.atomic.AtomicReference @@ -95,6 +98,15 @@ class LiveViewProvider : ModuleProvider() { override fun start() { log.info("Starting spp-live-view") + val process = manager.find(AnalyzerModule.NAME) + .provider() + .getService(IMeterProcessService::class.java) as MeterProcessService + val analyzerModule = manager.find(AnalyzerModule.NAME).provider() + analyzerModule.registerServiceImplementation( + IMeterProcessService::class.java, + LiveMeterProcessService(process, manager) + ) + val sppRemoteClient = AtomicReference() class SPPRemoteClientManager : RemoteClientManager { From 656bdaec4479ee389619ef9873e05afccae3246f Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Tue, 27 Jun 2023 18:23:15 -0500 Subject: [PATCH 13/31] test: isolate --- .../src/test/kotlin/integration/LiveMeterPartitionTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/processor/live-view/src/test/kotlin/integration/LiveMeterPartitionTest.kt b/platform/processor/live-view/src/test/kotlin/integration/LiveMeterPartitionTest.kt index 6a431ebcf..e334176e7 100644 --- a/platform/processor/live-view/src/test/kotlin/integration/LiveMeterPartitionTest.kt +++ b/platform/processor/live-view/src/test/kotlin/integration/LiveMeterPartitionTest.kt @@ -26,6 +26,7 @@ import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.Isolated import spp.protocol.instrument.LiveMeter import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.meter.* @@ -36,6 +37,7 @@ import spp.protocol.view.LiveViewEvent import spp.protocol.view.rule.RulePartition import spp.protocol.view.rule.ViewRule +@Isolated class LiveMeterPartitionTest : LiveInstrumentIntegrationTest() { @Suppress("UNUSED_VARIABLE") From c0ffc2927e75603ae4711e91f8d5c62e7ea21482 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Tue, 27 Jun 2023 19:02:10 -0500 Subject: [PATCH 14/31] refactor: move packages --- .../src/main/kotlin/spp/processor/view/ViewProcessor.kt | 2 +- .../kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt | 2 +- .../main/kotlin/spp/processor/view/impl/SPPRemoteClient.kt | 2 +- .../main/kotlin/spp/processor/view/impl/view/LiveLogView.kt | 4 ++-- .../kotlin/spp/processor/view/impl/view/LiveMeterView.kt | 6 +++++- .../kotlin/spp/processor/view/impl/view/LiveTraceView.kt | 2 +- .../processor/view/impl/view/util/EntitySubscribersCache.kt | 1 + .../processor/view/{impl/view => }/model/ClusterMetrics.kt | 2 +- .../view/{impl/view => }/model/LiveGaugeValueMetrics.kt | 2 +- .../view/{impl/view/util => model}/ViewSubscriber.kt | 2 +- .../src/test/kotlin/integration/MetricsSerializationTest.kt | 2 +- .../view/{impl/view => }/model/ClusterMetricsTest.kt | 2 +- 12 files changed, 17 insertions(+), 12 deletions(-) rename platform/processor/live-view/src/main/kotlin/spp/processor/view/{impl/view => }/model/ClusterMetrics.kt (98%) rename platform/processor/live-view/src/main/kotlin/spp/processor/view/{impl/view => }/model/LiveGaugeValueMetrics.kt (98%) rename platform/processor/live-view/src/main/kotlin/spp/processor/view/{impl/view/util => model}/ViewSubscriber.kt (97%) rename platform/processor/live-view/src/test/kotlin/spp/processor/view/{impl/view => }/model/ClusterMetricsTest.kt (98%) diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/ViewProcessor.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/ViewProcessor.kt index 064ce0024..23a88b99e 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/ViewProcessor.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/ViewProcessor.kt @@ -42,7 +42,7 @@ import spp.platform.common.FeedbackProcessor import spp.platform.storage.ExpiringSharedData import spp.platform.storage.SourceStorage import spp.processor.view.impl.LiveViewServiceImpl -import spp.processor.view.impl.view.model.ClusterMetrics +import spp.processor.view.model.ClusterMetrics import spp.protocol.platform.auth.RolePermission import spp.protocol.platform.developer.SelfInfo import spp.protocol.service.LiveManagementService diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt index f90fdb68e..729f921ae 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt @@ -59,7 +59,7 @@ import spp.processor.view.impl.view.LiveMeterView import spp.processor.view.impl.view.LiveTraceView import spp.processor.view.impl.view.util.EntitySubscribersCache import spp.processor.view.impl.view.util.MetricTypeSubscriptionCache -import spp.processor.view.impl.view.util.ViewSubscriber +import spp.processor.view.model.ViewSubscriber import spp.processor.view.model.LiveMeterConfig import spp.processor.view.model.LiveMetricConvert import spp.processor.view.model.LiveMetricConvert.Companion.NOP_RULE diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/SPPRemoteClient.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/SPPRemoteClient.kt index f6b4c4fde..900403561 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/SPPRemoteClient.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/SPPRemoteClient.kt @@ -30,7 +30,7 @@ import org.apache.skywalking.oap.server.library.module.ModuleManager import org.joor.Reflect import spp.platform.common.ClusterConnection import spp.processor.view.ViewProcessor -import spp.processor.view.impl.view.model.ClusterMetrics +import spp.processor.view.model.ClusterMetrics import spp.processor.view.impl.view.util.EntityNaming import spp.protocol.artifact.metrics.MetricType diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt index c5b519b03..b62fe65de 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt @@ -30,9 +30,9 @@ import org.apache.skywalking.oap.server.core.analysis.Layer import spp.platform.common.ClusterConnection import spp.platform.common.util.ContextUtil import spp.processor.view.ViewProcessor -import spp.processor.view.impl.view.model.LiveGaugeValueMetrics +import spp.processor.view.model.LiveGaugeValueMetrics import spp.processor.view.impl.view.util.MetricTypeSubscriptionCache -import spp.processor.view.impl.view.util.ViewSubscriber +import spp.processor.view.model.ViewSubscriber import spp.protocol.artifact.log.Log import spp.protocol.instrument.location.LiveSourceLocation import java.time.Instant diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt index 0d41fcf34..734b2adfc 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt @@ -31,8 +31,12 @@ import spp.platform.common.util.args import spp.platform.storage.SourceStorage import spp.processor.view.ViewProcessor import spp.processor.view.ViewProcessor.realtimeMetricCache -import spp.processor.view.impl.view.util.* +import spp.processor.view.impl.view.util.EntityNaming +import spp.processor.view.impl.view.util.InternalRealtimeViewSubscriber +import spp.processor.view.impl.view.util.InternalViewSubscriber +import spp.processor.view.impl.view.util.MetricTypeSubscriptionCache import spp.processor.view.model.LiveMetricConvert +import spp.processor.view.model.ViewSubscriber import spp.protocol.instrument.event.LiveMeterHit import java.time.Instant import java.util.concurrent.CopyOnWriteArrayList diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveTraceView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveTraceView.kt index d51f7fb7f..a70b09cee 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveTraceView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveTraceView.kt @@ -29,7 +29,7 @@ import org.apache.skywalking.oap.server.library.module.ModuleManager import org.slf4j.LoggerFactory import spp.platform.common.ClusterConnection import spp.processor.view.impl.view.util.MetricTypeSubscriptionCache -import spp.processor.view.impl.view.util.ViewSubscriber +import spp.processor.view.model.ViewSubscriber import spp.protocol.artifact.trace.Trace import spp.protocol.artifact.trace.TraceSpan import spp.protocol.artifact.trace.TraceSpanLogEntry diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/util/EntitySubscribersCache.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/util/EntitySubscribersCache.kt index 36120961c..ba7a87aed 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/util/EntitySubscribersCache.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/util/EntitySubscribersCache.kt @@ -17,6 +17,7 @@ */ package spp.processor.view.impl.view.util +import spp.processor.view.model.ViewSubscriber import java.util.concurrent.ConcurrentHashMap class EntitySubscribersCache : ConcurrentHashMap>() diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/model/ClusterMetrics.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/model/ClusterMetrics.kt similarity index 98% rename from platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/model/ClusterMetrics.kt rename to platform/processor/live-view/src/main/kotlin/spp/processor/view/model/ClusterMetrics.kt index 72c296fcd..7dea04c5b 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/model/ClusterMetrics.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/model/ClusterMetrics.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.processor.view.impl.view.model +package spp.processor.view.model import io.vertx.core.buffer.Buffer import io.vertx.core.shareddata.ClusterSerializable diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/model/LiveGaugeValueMetrics.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/model/LiveGaugeValueMetrics.kt similarity index 98% rename from platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/model/LiveGaugeValueMetrics.kt rename to platform/processor/live-view/src/main/kotlin/spp/processor/view/model/LiveGaugeValueMetrics.kt index f08699753..499956c4a 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/model/LiveGaugeValueMetrics.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/model/LiveGaugeValueMetrics.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.processor.view.impl.view.model +package spp.processor.view.model import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics import org.apache.skywalking.oap.server.core.analysis.metrics.MetricsMetaInfo diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/util/ViewSubscriber.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/model/ViewSubscriber.kt similarity index 97% rename from platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/util/ViewSubscriber.kt rename to platform/processor/live-view/src/main/kotlin/spp/processor/view/model/ViewSubscriber.kt index 1e851c801..05646e6f8 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/util/ViewSubscriber.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/model/ViewSubscriber.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.processor.view.impl.view.util +package spp.processor.view.model import io.vertx.core.eventbus.MessageConsumer import io.vertx.core.json.JsonObject diff --git a/platform/processor/live-view/src/test/kotlin/integration/MetricsSerializationTest.kt b/platform/processor/live-view/src/test/kotlin/integration/MetricsSerializationTest.kt index 0ea745616..c33ed0e64 100644 --- a/platform/processor/live-view/src/test/kotlin/integration/MetricsSerializationTest.kt +++ b/platform/processor/live-view/src/test/kotlin/integration/MetricsSerializationTest.kt @@ -22,7 +22,7 @@ import io.vertx.kotlin.coroutines.await import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test -import spp.processor.view.impl.view.model.ClusterMetrics +import spp.processor.view.model.ClusterMetrics import java.util.* class MetricsSerializationTest : PlatformIntegrationTest() { diff --git a/platform/processor/live-view/src/test/kotlin/spp/processor/view/impl/view/model/ClusterMetricsTest.kt b/platform/processor/live-view/src/test/kotlin/spp/processor/view/model/ClusterMetricsTest.kt similarity index 98% rename from platform/processor/live-view/src/test/kotlin/spp/processor/view/impl/view/model/ClusterMetricsTest.kt rename to platform/processor/live-view/src/test/kotlin/spp/processor/view/model/ClusterMetricsTest.kt index 0429ebb56..0997f5b1f 100644 --- a/platform/processor/live-view/src/test/kotlin/spp/processor/view/impl/view/model/ClusterMetricsTest.kt +++ b/platform/processor/live-view/src/test/kotlin/spp/processor/view/model/ClusterMetricsTest.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.processor.view.impl.view.model +package spp.processor.view.model import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity import org.apache.skywalking.oap.server.core.analysis.meter.function.AcceptableValue From e83025b54b62c3b5933210b9f9d9edd9a160b459 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Tue, 27 Jun 2023 19:26:12 -0500 Subject: [PATCH 15/31] style: detekt --- .../main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt | 2 +- .../src/main/kotlin/spp/processor/view/impl/SPPRemoteClient.kt | 2 +- .../src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt index 729f921ae..9692847d4 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt @@ -59,10 +59,10 @@ import spp.processor.view.impl.view.LiveMeterView import spp.processor.view.impl.view.LiveTraceView import spp.processor.view.impl.view.util.EntitySubscribersCache import spp.processor.view.impl.view.util.MetricTypeSubscriptionCache -import spp.processor.view.model.ViewSubscriber import spp.processor.view.model.LiveMeterConfig import spp.processor.view.model.LiveMetricConvert import spp.processor.view.model.LiveMetricConvert.Companion.NOP_RULE +import spp.processor.view.model.ViewSubscriber import spp.protocol.artifact.metrics.MetricStep import spp.protocol.artifact.metrics.MetricType import spp.protocol.artifact.trace.TraceSpan diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/SPPRemoteClient.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/SPPRemoteClient.kt index 900403561..2dd33c2ac 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/SPPRemoteClient.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/SPPRemoteClient.kt @@ -30,8 +30,8 @@ import org.apache.skywalking.oap.server.library.module.ModuleManager import org.joor.Reflect import spp.platform.common.ClusterConnection import spp.processor.view.ViewProcessor -import spp.processor.view.model.ClusterMetrics import spp.processor.view.impl.view.util.EntityNaming +import spp.processor.view.model.ClusterMetrics import spp.protocol.artifact.metrics.MetricType class SPPRemoteClient( diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt index b62fe65de..3f3d996dc 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt @@ -30,8 +30,8 @@ import org.apache.skywalking.oap.server.core.analysis.Layer import spp.platform.common.ClusterConnection import spp.platform.common.util.ContextUtil import spp.processor.view.ViewProcessor -import spp.processor.view.model.LiveGaugeValueMetrics import spp.processor.view.impl.view.util.MetricTypeSubscriptionCache +import spp.processor.view.model.LiveGaugeValueMetrics import spp.processor.view.model.ViewSubscriber import spp.protocol.artifact.log.Log import spp.protocol.instrument.location.LiveSourceLocation From 11b65e24899e57e94dc486eb45d612e66093e780 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 13:51:07 -0500 Subject: [PATCH 16/31] refactor: migrate LiveSourceLocation.service to Service type --- .../spp/platform/common/util/ContextUtil.kt | 10 +++++++ .../spp/platform/core/vcs/ServiceVCS.kt | 14 +++++++-- .../src/test/kotlin/integration/JWTTest.kt | 3 +- .../instrument/impl/LiveLogAnalyzer.kt | 3 +- .../integration/LiveInstrumentEventsTest.kt | 3 +- .../kotlin/integration/LiveInstrumentTest.kt | 30 ++++++++++++++----- .../LiveVariablePresentationTest.kt | 3 +- .../NegativePrimitiveConditionITTest.kt | 7 +++-- .../integration/PrimitiveConditionITTest.kt | 7 +++-- .../integration/RemoveInstrumentsTest.kt | 21 ++++++++++--- .../SimplePrimitivesLiveInstrumentTest.kt | 3 +- .../kotlin/integration/VCSLiveInstrumentIT.kt | 7 +++-- .../AtomicValueLiveBreakpointTest.kt | 3 +- .../breakpoint/BreakpointRedactionTest.kt | 3 +- .../CyclicObjectLiveBreakpointTest.kt | 3 +- .../DeepObjectLiveBreakpointTest.kt | 3 +- .../breakpoint/HitLimitLiveBreakpointTest.kt | 3 +- .../breakpoint/InnerClassBreakpointTest.kt | 3 +- .../LargeArrayLiveBreakpointTest.kt | 3 +- .../breakpoint/LargeListLiveBreakpointTest.kt | 3 +- .../breakpoint/LargeMapLiveBreakpointTest.kt | 3 +- .../LargeObjectLiveBreakpointTest.kt | 3 +- .../LargePrimitiveArrayLiveBreakpointTest.kt | 3 +- .../breakpoint/LargeSetLiveBreakpointTest.kt | 3 +- .../breakpoint/LiveBreakpointTest.kt | 5 ++-- .../breakpoint/MetaLiveBreakpointTest.kt | 3 +- .../breakpoint/MultiLiveBreakpointTest.kt | 9 +++--- .../breakpoint/NullArrayLiveBreakpointTest.kt | 3 +- .../RemoveByLocationLiveBreakpointTest.kt | 17 +++++++---- .../SimpleCollectionsLiveBreakpointTest.kt | 3 +- .../breakpoint/SmallMapLiveBreakpointTest.kt | 7 +++-- .../breakpoint/ThrottleLiveBreakpointTest.kt | 7 +++-- .../integration/log/FormatLiveLogTest.kt | 3 +- .../kotlin/integration/log/LiveLogTest.kt | 13 ++++---- .../integration/meter/LiveMeterCountTest.kt | 9 +++--- .../integration/meter/LiveMeterGaugeTest.kt | 5 ++-- .../integration/meter/LiveMeterRateTest.kt | 3 +- .../processor/view/impl/view/LiveLogView.kt | 7 +++-- .../processor/view/impl/view/LiveMeterView.kt | 4 ++- .../integration/LiveLogSubscriptionTest.kt | 8 +++-- .../integration/LiveMeterPartitionTest.kt | 3 +- .../integration/RealtimeLiveViewTest.kt | 6 +++- .../test/kotlin/integration/VCSLiveViewIT.kt | 12 ++++++-- protocol | 2 +- 44 files changed, 191 insertions(+), 85 deletions(-) diff --git a/platform/common/src/main/kotlin/spp/platform/common/util/ContextUtil.kt b/platform/common/src/main/kotlin/spp/platform/common/util/ContextUtil.kt index 05b820749..6333a808f 100644 --- a/platform/common/src/main/kotlin/spp/platform/common/util/ContextUtil.kt +++ b/platform/common/src/main/kotlin/spp/platform/common/util/ContextUtil.kt @@ -33,6 +33,9 @@ object ContextUtil { @JvmStatic val COMMIT_ID = Context.key("spp-platform.commit-id")!! + @JvmStatic + val ENVIRONMENT = Context.key("spp-platform.environment")!! + @JvmStatic fun addToVertx(context: Context?) { if (context == null) return @@ -65,5 +68,12 @@ object ContextUtil { vertxContext.removeLocal("commit_id") } } + ENVIRONMENT.get(context).let { + if (it != null) { + vertxContext.putLocal("environment", it) + } else { + vertxContext.removeLocal("environment") + } + } } } diff --git a/platform/core/src/main/kotlin/spp/platform/core/vcs/ServiceVCS.kt b/platform/core/src/main/kotlin/spp/platform/core/vcs/ServiceVCS.kt index cdf55487b..7c4a4e87b 100644 --- a/platform/core/src/main/kotlin/spp/platform/core/vcs/ServiceVCS.kt +++ b/platform/core/src/main/kotlin/spp/platform/core/vcs/ServiceVCS.kt @@ -31,21 +31,29 @@ object ServiceVCS { } require(service.isNotEmpty()) { "Message ${message.descriptorForType} does not have a service name" } - return service + getCommitId() + return service + getEnvironment() + getCommitId() } else if (message.descriptorForType.findFieldByName("source") != null) { val source = message.getField(message.descriptorForType.findFieldByName("source")) if (source is Message) { val service = source.getField(source.descriptorForType.findFieldByName("service")).toString() require(service.isNotEmpty()) { "Message ${message.descriptorForType} does not have a service name" } - return service + getCommitId() + return service + getEnvironment() + getCommitId() } } throw IllegalArgumentException("Message " + message.descriptorForType + " does not have a service name") } + private fun getEnvironment(): String { + val env = ContextUtil.ENVIRONMENT.get() + if (env.isNullOrEmpty()) return "" + return "|$env" + } + private fun getCommitId(): String { - return ContextUtil.COMMIT_ID.get()?.let { "|$it" } ?: "" + val commitId = ContextUtil.COMMIT_ID.get() + if (commitId.isNullOrEmpty()) return "" + return "|$commitId" } } diff --git a/platform/core/src/test/kotlin/integration/JWTTest.kt b/platform/core/src/test/kotlin/integration/JWTTest.kt index 69d985de1..d44645f45 100644 --- a/platform/core/src/test/kotlin/integration/JWTTest.kt +++ b/platform/core/src/test/kotlin/integration/JWTTest.kt @@ -29,6 +29,7 @@ import spp.protocol.marshall.ServiceExceptionConverter import spp.protocol.platform.auth.AccessType.BLACK_LIST import spp.protocol.platform.auth.DeveloperRole import spp.protocol.platform.auth.RolePermission.ADD_LIVE_BREAKPOINT +import spp.protocol.platform.general.Service import spp.protocol.service.LiveInstrumentService import spp.protocol.service.error.InstrumentAccessDenied import spp.protocol.service.error.PermissionAccessDenied @@ -42,7 +43,7 @@ class JWTTest : PlatformIntegrationTest() { val testContext = VertxTestContext() instrumentService.addLiveInstrument( LiveBreakpoint( - location = LiveSourceLocation(JWTTest::class.java.name, 1, "spp-test-probe"), + location = LiveSourceLocation(JWTTest::class.java.name, 1, Service.fromName("spp-test-probe")), condition = "1 == 2" ) ).onComplete { diff --git a/platform/processor/live-instrument/src/main/kotlin/spp/processor/instrument/impl/LiveLogAnalyzer.kt b/platform/processor/live-instrument/src/main/kotlin/spp/processor/instrument/impl/LiveLogAnalyzer.kt index 705f53c16..cffc9d356 100644 --- a/platform/processor/live-instrument/src/main/kotlin/spp/processor/instrument/impl/LiveLogAnalyzer.kt +++ b/platform/processor/live-instrument/src/main/kotlin/spp/processor/instrument/impl/LiveLogAnalyzer.kt @@ -39,6 +39,7 @@ import spp.protocol.artifact.log.LogOrderType import spp.protocol.artifact.log.LogResult import spp.protocol.instrument.event.LiveLogHit import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import java.time.Instant import java.util.concurrent.TimeUnit import kotlin.collections.set @@ -84,7 +85,7 @@ class LiveLogAnalyzer : LogAnalysisListener, LogAnalysisListenerFactory { LiveSourceLocation( logSource, logLineNumber ?: -1, - service = logData.service, + service = Service.fromName(logData.service), serviceInstance = logData.serviceInstance ) } else null diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/LiveInstrumentEventsTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/LiveInstrumentEventsTest.kt index cd992833a..e55e6bfb0 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/LiveInstrumentEventsTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/LiveInstrumentEventsTest.kt @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.event.* import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.LiveInstrumentListener import spp.protocol.service.listen.addLiveInstrumentListener import java.util.concurrent.atomic.AtomicInteger @@ -66,7 +67,7 @@ class LiveInstrumentEventsTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveInstrumentEventsTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = instrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/LiveInstrumentTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/LiveInstrumentTest.kt index dd0ac9445..ca1997616 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/LiveInstrumentTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/LiveInstrumentTest.kt @@ -26,6 +26,7 @@ import org.junit.jupiter.api.parallel.Isolated import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.LiveLog import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener import spp.protocol.service.listen.addLogHitListener import java.util.concurrent.atomic.AtomicInteger @@ -59,7 +60,12 @@ class LiveInstrumentTest : LiveInstrumentIntegrationTest() { @Test fun getLiveInstrumentById(): Unit = runBlocking { val instrument = instrumentService.addLiveInstrument( - LiveBreakpoint(location = LiveSourceLocation("integration.LiveInstrumentTest", 1, "spp-test-probe")) + LiveBreakpoint( + location = LiveSourceLocation( + "integration.LiveInstrumentTest", 1, + Service.fromName("spp-test-probe") + ) + ) ).await() val originalId = instrument.id!! @@ -73,8 +79,18 @@ class LiveInstrumentTest : LiveInstrumentIntegrationTest() { fun getLiveInstrumentByIds(): Unit = runBlocking { val instrument = instrumentService.addLiveInstruments( listOf( - LiveBreakpoint(location = LiveSourceLocation("integration.LiveInstrumentTest", 1, "spp-test-probe")), - LiveBreakpoint(location = LiveSourceLocation("integration.LiveInstrumentTest", 2, "spp-test-probe")) + LiveBreakpoint( + location = LiveSourceLocation( + "integration.LiveInstrumentTest", 1, + Service.fromName("spp-test-probe") + ) + ), + LiveBreakpoint( + location = LiveSourceLocation( + "integration.LiveInstrumentTest", 2, + Service.fromName("spp-test-probe") + ) + ) ) ).await() @@ -120,7 +136,7 @@ class LiveInstrumentTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveInstrumentTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = "$testNameAsInstrumentId-log" @@ -131,7 +147,7 @@ class LiveInstrumentTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveInstrumentTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = "$testNameAsInstrumentId-breakpoint" @@ -166,7 +182,7 @@ class LiveInstrumentTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveInstrumentTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), "1==2", applyImmediately = true, @@ -178,7 +194,7 @@ class LiveInstrumentTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveInstrumentTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = "$testNameAsInstrumentId-breakpoint" diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/LiveVariablePresentationTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/LiveVariablePresentationTest.kt index d1251bee9..e5e6991e8 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/LiveVariablePresentationTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/LiveVariablePresentationTest.kt @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener import java.math.BigInteger import java.time.* @@ -199,7 +200,7 @@ class LiveVariablePresentationTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveVariablePresentationTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/NegativePrimitiveConditionITTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/NegativePrimitiveConditionITTest.kt index 38d916a50..f9b066589 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/NegativePrimitiveConditionITTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/NegativePrimitiveConditionITTest.kt @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Assumptions.assumeTrue import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener @Suppress("UNUSED_VARIABLE", "unused") @@ -73,7 +74,7 @@ class NegativePrimitiveConditionITTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( NegativePrimitiveConditionITTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), condition = "staticFields[fieldI] == 100", applyImmediately = true @@ -107,7 +108,7 @@ class NegativePrimitiveConditionITTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( NegativePrimitiveConditionITTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), condition = "fields[instanceI] == 100", applyImmediately = true @@ -141,7 +142,7 @@ class NegativePrimitiveConditionITTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( NegativePrimitiveConditionITTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), condition = "localVariables[localI] == 100", applyImmediately = true diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/PrimitiveConditionITTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/PrimitiveConditionITTest.kt index ed9e020f1..ec3f6aa0a 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/PrimitiveConditionITTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/PrimitiveConditionITTest.kt @@ -23,6 +23,7 @@ import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener @Suppress("UNUSED_VARIABLE", "unused") @@ -65,7 +66,7 @@ class PrimitiveConditionITTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( PrimitiveConditionITTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), condition = "staticFields[fieldI] == 100", applyImmediately = true, @@ -96,7 +97,7 @@ class PrimitiveConditionITTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( PrimitiveConditionITTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), condition = "fields[instanceI] == 100", applyImmediately = true, @@ -127,7 +128,7 @@ class PrimitiveConditionITTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( PrimitiveConditionITTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), condition = "localVariables[localI] == 100", applyImmediately = true, diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/RemoveInstrumentsTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/RemoveInstrumentsTest.kt index 943c86051..c2501c5c6 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/RemoveInstrumentsTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/RemoveInstrumentsTest.kt @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.event.LiveInstrumentRemoved import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.LiveInstrumentListener import spp.protocol.service.listen.addLiveInstrumentListener import java.util.concurrent.atomic.AtomicInteger @@ -39,11 +40,17 @@ class RemoveInstrumentsTest : LiveInstrumentIntegrationTest() { val instruments = instrumentService.addLiveInstruments( listOf( LiveBreakpoint( - location = LiveSourceLocation(RemoveInstrumentsTest::class.java.name, service = "spp-test-probe"), + location = LiveSourceLocation( + RemoveInstrumentsTest::class.java.name, + service = Service.fromName("spp-test-probe") + ), id = testNameAsUniqueInstrumentId ), LiveBreakpoint( - location = LiveSourceLocation(RemoveInstrumentsTest::class.java.name, service = "spp-test-probe"), + location = LiveSourceLocation( + RemoveInstrumentsTest::class.java.name, + service = Service.fromName("spp-test-probe") + ), id = testNameAsUniqueInstrumentId ) ) @@ -56,7 +63,10 @@ class RemoveInstrumentsTest : LiveInstrumentIntegrationTest() { override fun onInstrumentRemovedEvent(event: LiveInstrumentRemoved) { testContext.verify { assertEquals( - LiveSourceLocation(RemoveInstrumentsTest::class.java.name, service = "spp-test-probe"), + LiveSourceLocation( + RemoveInstrumentsTest::class.java.name, + service = Service.fromName("spp-test-probe") + ), event.instrument.location ) @@ -71,7 +81,10 @@ class RemoveInstrumentsTest : LiveInstrumentIntegrationTest() { } val removeInstruments = instrumentService.removeLiveInstruments( - LiveSourceLocation(RemoveInstrumentsTest::class.java.name, service = "spp-test-probe") + LiveSourceLocation( + RemoveInstrumentsTest::class.java.name, + service = Service.fromName("spp-test-probe") + ) ).await() assertEquals(2, removeInstruments.size) diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/SimplePrimitivesLiveInstrumentTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/SimplePrimitivesLiveInstrumentTest.kt index 18a7810de..16a324e6c 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/SimplePrimitivesLiveInstrumentTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/SimplePrimitivesLiveInstrumentTest.kt @@ -24,6 +24,7 @@ import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener class SimplePrimitivesLiveInstrumentTest : LiveInstrumentIntegrationTest() { @@ -134,7 +135,7 @@ class SimplePrimitivesLiveInstrumentTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( SimplePrimitivesLiveInstrumentTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/VCSLiveInstrumentIT.kt b/platform/processor/live-instrument/src/test/kotlin/integration/VCSLiveInstrumentIT.kt index 3781fabce..aff68c7ca 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/VCSLiveInstrumentIT.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/VCSLiveInstrumentIT.kt @@ -29,6 +29,7 @@ import org.junit.jupiter.api.parallel.Isolated import spp.probe.ProbeConfiguration import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener import java.util.concurrent.atomic.AtomicInteger @@ -64,7 +65,7 @@ class VCSLiveInstrumentIT : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( VCSLiveInstrumentIT::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsUniqueInstrumentId, @@ -81,11 +82,11 @@ class VCSLiveInstrumentIT : LiveInstrumentIntegrationTest() { if (hitCount.incrementAndGet() == 1) { testContext.verify { - assertEquals(instrument.location.service + "|" + "test1", bpHit.service) + assertEquals(instrument.location.service?.name + "|" + "test1", bpHit.service) } } else { testContext.verify { - assertEquals(instrument.location.service + "|" + "test2", bpHit.service) + assertEquals(instrument.location.service?.name + "|" + "test2", bpHit.service) } } testContext.completeNow() diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/AtomicValueLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/AtomicValueLiveBreakpointTest.kt index 75446cd49..0e36b2435 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/AtomicValueLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/AtomicValueLiveBreakpointTest.kt @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.variable.LiveVariable +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicReference @@ -116,7 +117,7 @@ class AtomicValueLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( AtomicValueLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true ) diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/BreakpointRedactionTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/BreakpointRedactionTest.kt index dbd6618bb..69fb54272 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/BreakpointRedactionTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/BreakpointRedactionTest.kt @@ -29,6 +29,7 @@ import spp.protocol.platform.auth.DeveloperRole import spp.protocol.platform.auth.RedactionType import spp.protocol.platform.auth.RedactionType.IDENTIFIER_MATCH import spp.protocol.platform.auth.RolePermission +import spp.protocol.platform.general.Service import spp.protocol.service.LiveInstrumentService import spp.protocol.service.listen.addBreakpointHitListener @@ -105,7 +106,7 @@ class BreakpointRedactionTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( BreakpointRedactionTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true ) diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/CyclicObjectLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/CyclicObjectLiveBreakpointTest.kt index a4ba6d874..7ba742c5e 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/CyclicObjectLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/CyclicObjectLiveBreakpointTest.kt @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener class CyclicObjectLiveBreakpointTest : LiveInstrumentIntegrationTest() { @@ -98,7 +99,7 @@ class CyclicObjectLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( CyclicObjectLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/DeepObjectLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/DeepObjectLiveBreakpointTest.kt index 25bcba1b5..90f3292cc 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/DeepObjectLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/DeepObjectLiveBreakpointTest.kt @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener @Suppress("unused", "UNUSED_VARIABLE") @@ -133,7 +134,7 @@ class DeepObjectLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( DeepObjectLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/HitLimitLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/HitLimitLiveBreakpointTest.kt index 89d9fdd97..7b133c05f 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/HitLimitLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/HitLimitLiveBreakpointTest.kt @@ -28,6 +28,7 @@ import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.event.LiveInstrumentRemoved import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.throttle.InstrumentThrottle +import spp.protocol.platform.general.Service import spp.protocol.service.listen.LiveInstrumentListener import spp.protocol.service.listen.addBreakpointHitListener import spp.protocol.service.listen.addLiveInstrumentListener @@ -53,7 +54,7 @@ class HitLimitLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( HitLimitLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), hitLimit = 11, throttle = InstrumentThrottle.NONE, diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/InnerClassBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/InnerClassBreakpointTest.kt index dbbcc6a79..15655af1c 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/InnerClassBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/InnerClassBreakpointTest.kt @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.variable.LiveVariableScope +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener @Suppress("UNUSED_VARIABLE") @@ -52,7 +53,7 @@ class InnerClassBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( InnerClass::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsUniqueInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeArrayLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeArrayLiveBreakpointTest.kt index 9dea22329..892a13027 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeArrayLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeArrayLiveBreakpointTest.kt @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener import java.util.* @@ -84,7 +85,7 @@ class LargeArrayLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LargeArrayLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true ) diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeListLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeListLiveBreakpointTest.kt index df1a2e643..5de2abcd3 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeListLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeListLiveBreakpointTest.kt @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener class LargeListLiveBreakpointTest : LiveInstrumentIntegrationTest() { @@ -85,7 +86,7 @@ class LargeListLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LargeListLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeMapLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeMapLiveBreakpointTest.kt index 6f9c655d8..47fdd8904 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeMapLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeMapLiveBreakpointTest.kt @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener class LargeMapLiveBreakpointTest : LiveInstrumentIntegrationTest() { @@ -82,7 +83,7 @@ class LargeMapLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LargeMapLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeObjectLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeObjectLiveBreakpointTest.kt index 4d53fd586..12e4d84bc 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeObjectLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeObjectLiveBreakpointTest.kt @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener @Suppress("UNUSED_VARIABLE") @@ -83,7 +84,7 @@ class LargeObjectLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LargeObjectLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargePrimitiveArrayLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargePrimitiveArrayLiveBreakpointTest.kt index 1401eb2f9..95cc61ff1 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargePrimitiveArrayLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargePrimitiveArrayLiveBreakpointTest.kt @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener import java.util.* @@ -83,7 +84,7 @@ class LargePrimitiveArrayLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LargePrimitiveArrayLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeSetLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeSetLiveBreakpointTest.kt index 28b1b5111..1062c2d79 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeSetLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LargeSetLiveBreakpointTest.kt @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener class LargeSetLiveBreakpointTest : LiveInstrumentIntegrationTest() { @@ -84,7 +85,7 @@ class LargeSetLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LargeSetLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LiveBreakpointTest.kt index 2d66a9115..8c858feb4 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/LiveBreakpointTest.kt @@ -28,6 +28,7 @@ import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.event.* import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.marshall.ServiceExceptionConverter +import spp.protocol.platform.general.Service import spp.protocol.service.error.LiveInstrumentException import spp.protocol.service.listen.LiveInstrumentListener import spp.protocol.service.listen.addLiveInstrumentListener @@ -142,7 +143,7 @@ class LiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true ) @@ -218,7 +219,7 @@ class LiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), condition = "2==2", applyImmediately = true diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/MetaLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/MetaLiveBreakpointTest.kt index 9e9b7c6b1..f3270e421 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/MetaLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/MetaLiveBreakpointTest.kt @@ -24,6 +24,7 @@ import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service class MetaLiveBreakpointTest : LiveInstrumentIntegrationTest() { @@ -138,7 +139,7 @@ class MetaLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( MetaLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsUniqueInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/MultiLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/MultiLiveBreakpointTest.kt index d8d7b44dc..4db286609 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/MultiLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/MultiLiveBreakpointTest.kt @@ -29,6 +29,7 @@ import spp.protocol.artifact.exception.sourceAsLineNumber import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.event.LiveBreakpointHit import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit @@ -73,7 +74,7 @@ class MultiLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( MultiLiveBreakpointTest::class.java.name, getLineNumber("line1"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = "$testNameAsInstrumentId-1" @@ -82,7 +83,7 @@ class MultiLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( MultiLiveBreakpointTest::class.java.name, getLineNumber("line1"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = "$testNameAsInstrumentId-2" @@ -143,7 +144,7 @@ class MultiLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( MultiLiveBreakpointTest::class.java.name, getLineNumber("line1"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = "$testNameAsInstrumentId-1" @@ -152,7 +153,7 @@ class MultiLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( MultiLiveBreakpointTest::class.java.name, getLineNumber("line2"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = "$testNameAsInstrumentId-2" diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/NullArrayLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/NullArrayLiveBreakpointTest.kt index 1b147aa65..8afe2fb23 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/NullArrayLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/NullArrayLiveBreakpointTest.kt @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener @Suppress("UNUSED_VARIABLE") @@ -76,7 +77,7 @@ class NullArrayLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( NullArrayLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/RemoveByLocationLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/RemoveByLocationLiveBreakpointTest.kt index e7e46b7b1..659964578 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/RemoveByLocationLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/RemoveByLocationLiveBreakpointTest.kt @@ -28,6 +28,7 @@ import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.event.LiveBreakpointHit import spp.protocol.instrument.event.LiveInstrumentApplied import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.LiveInstrumentListener import spp.protocol.service.listen.addBreakpointHitListener import spp.protocol.service.listen.addLiveInstrumentListener @@ -94,7 +95,7 @@ class RemoveByLocationLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( RemoveByLocationLiveBreakpointTest::class.java.name, getLineNumber("line1"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), hitLimit = 2, //applyImmediately = true, @@ -104,7 +105,7 @@ class RemoveByLocationLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( RemoveByLocationLiveBreakpointTest::class.java.name, getLineNumber("line2"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), hitLimit = 2, //applyImmediately = true, @@ -127,7 +128,7 @@ class RemoveByLocationLiveBreakpointTest : LiveInstrumentIntegrationTest() { LiveSourceLocation( RemoveByLocationLiveBreakpointTest::class.java.name, getLineNumber("line1"), - "spp-test-probe" + Service.fromName("spp-test-probe") ) ).await() testContext.verify { @@ -137,7 +138,10 @@ class RemoveByLocationLiveBreakpointTest : LiveInstrumentIntegrationTest() { //ensure line1 is removed and line2 is still there val remainingInstruments = instrumentService.getLiveInstrumentsByLocation( - LiveSourceLocation(RemoveByLocationLiveBreakpointTest::class.java.name, service = "spp-test-probe") + LiveSourceLocation( + RemoveByLocationLiveBreakpointTest::class.java.name, + service = Service.fromName("spp-test-probe") + ) ).await() testContext.verify { assertEquals(1, remainingInstruments.size) @@ -154,7 +158,10 @@ class RemoveByLocationLiveBreakpointTest : LiveInstrumentIntegrationTest() { assertEquals( 1, instrumentService.removeLiveInstruments( - LiveSourceLocation(RemoveByLocationLiveBreakpointTest::class.java.name, service = "spp-test-probe") + LiveSourceLocation( + RemoveByLocationLiveBreakpointTest::class.java.name, + service = Service.fromName("spp-test-probe") + ) ).await().size ) } diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/SimpleCollectionsLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/SimpleCollectionsLiveBreakpointTest.kt index 6899e2479..1d5719d95 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/SimpleCollectionsLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/SimpleCollectionsLiveBreakpointTest.kt @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener @Suppress("UNUSED_VARIABLE") @@ -183,7 +184,7 @@ class SimpleCollectionsLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( SimpleCollectionsLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/SmallMapLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/SmallMapLiveBreakpointTest.kt index 51da399a5..9ac945ab8 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/SmallMapLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/SmallMapLiveBreakpointTest.kt @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener class SmallMapLiveBreakpointTest : LiveInstrumentIntegrationTest() { @@ -104,7 +105,7 @@ class SmallMapLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( SmallMapLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true ) @@ -159,7 +160,7 @@ class SmallMapLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( SmallMapLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true ) @@ -214,7 +215,7 @@ class SmallMapLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( SmallMapLiveBreakpointTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true ) diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/ThrottleLiveBreakpointTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/ThrottleLiveBreakpointTest.kt index 02764fa3a..7a1b85f03 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/ThrottleLiveBreakpointTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/breakpoint/ThrottleLiveBreakpointTest.kt @@ -28,6 +28,7 @@ import spp.protocol.instrument.LiveBreakpoint import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.throttle.InstrumentThrottle import spp.protocol.instrument.throttle.ThrottleStep +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addBreakpointHitListener import java.util.concurrent.atomic.AtomicInteger @@ -73,7 +74,7 @@ class ThrottleLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( ThrottleLiveBreakpointTest::class.java.name, getLineNumber("throttle1"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), hitLimit = -1, applyImmediately = true, @@ -119,7 +120,7 @@ class ThrottleLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( ThrottleLiveBreakpointTest::class.java.name, getLineNumber("throttle2"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), hitLimit = -1, throttle = InstrumentThrottle(2, ThrottleStep.SECOND), @@ -165,7 +166,7 @@ class ThrottleLiveBreakpointTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( ThrottleLiveBreakpointTest::class.java.name, getLineNumber("throttle3"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), hitLimit = -1, throttle = InstrumentThrottle.NONE, diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/log/FormatLiveLogTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/log/FormatLiveLogTest.kt index 8c7eee76a..7bbe0606a 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/log/FormatLiveLogTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/log/FormatLiveLogTest.kt @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveLog import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.listen.addLogHitListener class FormatLiveLogTest : LiveInstrumentIntegrationTest() { @@ -72,7 +73,7 @@ class FormatLiveLogTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( FormatLiveLogTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), applyImmediately = true, id = testNameAsInstrumentId diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/log/LiveLogTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/log/LiveLogTest.kt index 22339370c..27da8be56 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/log/LiveLogTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/log/LiveLogTest.kt @@ -29,6 +29,7 @@ import spp.protocol.instrument.LiveLog import spp.protocol.instrument.event.* import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.marshall.ServiceExceptionConverter +import spp.protocol.platform.general.Service import spp.protocol.service.error.LiveInstrumentException import spp.protocol.service.listen.LiveInstrumentListener import spp.protocol.service.listen.addLiveInstrumentListener @@ -101,7 +102,7 @@ class LiveLogTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveLogTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), logFormat = "addHitRemove", applyImmediately = true @@ -140,7 +141,7 @@ class LiveLogTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( "FakeClass", 4, - "spp-test-probe" + Service.fromName("spp-test-probe") ), condition = "1==2", logFormat = "removeById" @@ -185,7 +186,7 @@ class LiveLogTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveLogTest::class.java.name, 100, - "spp-test-probe" + Service.fromName("spp-test-probe") ), condition = "1==2", logFormat = "removeMultipleByLocation" @@ -195,7 +196,7 @@ class LiveLogTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveLogTest::class.java.name, 100, - "spp-test-probe" + Service.fromName("spp-test-probe") ), condition = "1==3", logFormat = "removeMultipleByLocation" @@ -208,7 +209,7 @@ class LiveLogTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveLogTest::class.java.name, 100, - "spp-test-probe" + Service.fromName("spp-test-probe") ) ).onComplete { if (it.succeeded()) { @@ -240,7 +241,7 @@ class LiveLogTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveLogTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), condition = "1===2", logFormat = "addLogWithInvalidCondition", diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterCountTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterCountTest.kt index 27aba57d0..fdd188654 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterCountTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterCountTest.kt @@ -32,6 +32,7 @@ import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.meter.MeterType import spp.protocol.instrument.meter.MetricValue import spp.protocol.instrument.meter.MetricValueType +import spp.protocol.platform.general.Service import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscriberAddress import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscription import spp.protocol.view.LiveView @@ -66,7 +67,7 @@ class LiveMeterCountTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveMeterCountTest::class.java.name, getLineNumber("count1"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), id = testNameAsUniqueInstrumentId, applyImmediately = true @@ -130,7 +131,7 @@ class LiveMeterCountTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveMeterCountTest::class.java.name, getLineNumber("count2"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), id = testNameAsUniqueInstrumentId, applyImmediately = true @@ -194,7 +195,7 @@ class LiveMeterCountTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveMeterCountTest::class.java.name, getLineNumber("count3"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), id = testNameAsUniqueInstrumentId, applyImmediately = true @@ -214,7 +215,7 @@ class LiveMeterCountTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveMeterCountTest::class.java.name, getLineNumber("count3"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), id = testNameAsUniqueInstrumentId, meta = mapOf("metric.mode" to "RATE"), diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt index d4604ae87..ed4c56e3c 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt @@ -31,6 +31,7 @@ import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.meter.MeterType import spp.protocol.instrument.meter.MetricValue import spp.protocol.instrument.meter.MetricValueType +import spp.protocol.platform.general.Service import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscription import spp.protocol.view.LiveView import spp.protocol.view.LiveViewConfig @@ -71,7 +72,7 @@ class LiveMeterGaugeTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveMeterGaugeTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), id = instrumentId, applyImmediately = true, @@ -157,7 +158,7 @@ class LiveMeterGaugeTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveMeterGaugeTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), id = testNameAsUniqueInstrumentId, applyImmediately = true, diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterRateTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterRateTest.kt index 04e80046f..6507048d1 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterRateTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterRateTest.kt @@ -35,6 +35,7 @@ import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.meter.MeterType import spp.protocol.instrument.meter.MetricValue import spp.protocol.instrument.meter.MetricValueType +import spp.protocol.platform.general.Service import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscription import spp.protocol.view.LiveView import spp.protocol.view.LiveViewConfig @@ -66,7 +67,7 @@ class LiveMeterRateTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveMeterRateTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), id = testNameAsUniqueInstrumentId, meta = mapOf("metric.mode" to "RATE"), diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt index 3f3d996dc..2afe23469 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt @@ -35,6 +35,7 @@ import spp.processor.view.model.LiveGaugeValueMetrics import spp.processor.view.model.ViewSubscriber import spp.protocol.artifact.log.Log import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import java.time.Instant import java.time.ZoneOffset import java.time.format.DateTimeFormatterBuilder @@ -83,7 +84,7 @@ class LiveLogView(private val subscriptionCache: MetricTypeSubscriptionCache) : val subLocation = it.subscription.artifactLocation if (subLocation != null) { val logDataLocation = subLocation.copy( - service = subLocation.service?.let { logData.service.substringBefore("|") }, + service = subLocation.service?.copy(name = logData.service.substringBefore("|")), serviceInstance = subLocation.serviceInstance?.let { logData.serviceInstance }, commitId = subLocation.commitId?.let { ContextUtil.COMMIT_ID.get() } ) @@ -105,7 +106,7 @@ class LiveLogView(private val subscriptionCache: MetricTypeSubscriptionCache) : val subLocation = it.subscription.artifactLocation if (subLocation != null) { val logDataLocation = subLocation.copy( - service = subLocation.service?.let { logData.service.substringBefore("|") }, + service = subLocation.service?.copy(name = logData.service.substringBefore("|")), serviceInstance = subLocation.serviceInstance?.let { logData.serviceInstance }, commitId = subLocation.commitId?.let { ContextUtil.COMMIT_ID.get() } ) @@ -132,7 +133,7 @@ class LiveLogView(private val subscriptionCache: MetricTypeSubscriptionCache) : LiveSourceLocation( //todo: this is different than logDataLocation above logSource, logLineNumber ?: -1, - service = logData.service, + service = Service.fromName(logData.service), serviceInstance = logData.serviceInstance ) } else null diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt index 734b2adfc..58117c615 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt @@ -114,7 +114,9 @@ class LiveMeterView(private val subscriptionCache: MetricTypeSubscriptionCache) val subLocation = it.subscription.artifactLocation if (subLocation != null) { val metricsDataLocation = subLocation.copy( - service = subLocation.service?.let { metricServiceName?.substringBefore("|") }, + service = subLocation.service?.let { service -> + metricServiceName?.let { service.copy(name = it.substringBefore("|")) } + }, serviceInstance = subLocation.serviceInstance?.let { metricServiceInstance }, commitId = subLocation.commitId?.let { metricServiceName?.substringAfter("|") } ) diff --git a/platform/processor/live-view/src/test/kotlin/integration/LiveLogSubscriptionTest.kt b/platform/processor/live-view/src/test/kotlin/integration/LiveLogSubscriptionTest.kt index e393144ed..5497105c8 100644 --- a/platform/processor/live-view/src/test/kotlin/integration/LiveLogSubscriptionTest.kt +++ b/platform/processor/live-view/src/test/kotlin/integration/LiveLogSubscriptionTest.kt @@ -29,6 +29,7 @@ import org.junit.jupiter.api.parallel.Isolated import spp.protocol.artifact.log.Log import spp.protocol.instrument.LiveLog import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscription import spp.protocol.view.LiveView import spp.protocol.view.LiveViewConfig @@ -54,7 +55,7 @@ class LiveLogSubscriptionTest : LiveInstrumentIntegrationTest() { LiveSourceLocation( LiveLogSubscriptionTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), id = testNameAsUniqueInstrumentId, hitLimit = 5, @@ -65,7 +66,10 @@ class LiveLogSubscriptionTest : LiveInstrumentIntegrationTest() { LiveView( entityIds = mutableSetOf(liveLog.logFormat), viewConfig = LiveViewConfig("test", listOf("endpoint_logs")), - artifactLocation = LiveSourceLocation("", service = "spp-test-probe") + artifactLocation = LiveSourceLocation( + "", + service = Service.fromName("spp-test-probe") + ) ) ).await().subscriptionId!! log.info("Using subscription id: {}", subscriptionId) diff --git a/platform/processor/live-view/src/test/kotlin/integration/LiveMeterPartitionTest.kt b/platform/processor/live-view/src/test/kotlin/integration/LiveMeterPartitionTest.kt index 33295bc3c..15c17486f 100644 --- a/platform/processor/live-view/src/test/kotlin/integration/LiveMeterPartitionTest.kt +++ b/platform/processor/live-view/src/test/kotlin/integration/LiveMeterPartitionTest.kt @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test import spp.protocol.instrument.LiveMeter import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.meter.* +import spp.protocol.platform.general.Service import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscription import spp.protocol.view.LiveView import spp.protocol.view.LiveViewConfig @@ -62,7 +63,7 @@ class LiveMeterPartitionTest : LiveInstrumentIntegrationTest() { location = LiveSourceLocation( LiveMeterPartitionTest::class.java.name, getLineNumber("done"), - "spp-test-probe" + Service.fromName("spp-test-probe") ), id = testNameAsUniqueInstrumentId, applyImmediately = true diff --git a/platform/processor/live-view/src/test/kotlin/integration/RealtimeLiveViewTest.kt b/platform/processor/live-view/src/test/kotlin/integration/RealtimeLiveViewTest.kt index 9ea72057a..5a607d345 100644 --- a/platform/processor/live-view/src/test/kotlin/integration/RealtimeLiveViewTest.kt +++ b/platform/processor/live-view/src/test/kotlin/integration/RealtimeLiveViewTest.kt @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.parallel.Isolated import spp.protocol.artifact.metrics.MetricType import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscription import spp.protocol.view.LiveView import spp.protocol.view.LiveViewConfig @@ -45,7 +46,10 @@ class RealtimeLiveViewTest : PlatformIntegrationTest() { "test", listOf(MetricType.INSTANCE_JVM_CPU.asRealtime().metricId) ), - artifactLocation = LiveSourceLocation("", service = "spp-test-probe") + artifactLocation = LiveSourceLocation( + "", + service = Service.fromName("spp-test-probe") + ) ) ).await().subscriptionId!! diff --git a/platform/processor/live-view/src/test/kotlin/integration/VCSLiveViewIT.kt b/platform/processor/live-view/src/test/kotlin/integration/VCSLiveViewIT.kt index b6ea84863..09759caeb 100644 --- a/platform/processor/live-view/src/test/kotlin/integration/VCSLiveViewIT.kt +++ b/platform/processor/live-view/src/test/kotlin/integration/VCSLiveViewIT.kt @@ -30,6 +30,7 @@ import org.junit.jupiter.api.parallel.Isolated import spp.probe.ProbeConfiguration import spp.protocol.artifact.metrics.MetricType import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.platform.general.Service import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscription import spp.protocol.view.LiveView import spp.protocol.view.LiveViewConfig @@ -47,7 +48,11 @@ class VCSLiveViewIT : PlatformIntegrationTest() { "test", listOf(MetricType.INSTANCE_JVM_CPU.asRealtime().metricId) ), - artifactLocation = LiveSourceLocation("", service = "spp-test-probe", commitId = "test1") + artifactLocation = LiveSourceLocation( + "", + service = Service.fromName("spp-test-probe"), + commitId = "test1" + ) ) ).await().subscriptionId!! @@ -93,7 +98,10 @@ class VCSLiveViewIT : PlatformIntegrationTest() { "test", listOf(MetricType.INSTANCE_JVM_CPU.asRealtime().metricId) ), - artifactLocation = LiveSourceLocation("", service = "spp-test-probe") + artifactLocation = LiveSourceLocation( + "", + service = Service.fromName("spp-test-probe") + ) ) ).await().subscriptionId!! diff --git a/protocol b/protocol index 89c115bf8..1127ad15f 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit 89c115bf84cf9ce000213bc7639fa75862be78f3 +Subproject commit 1127ad15fa305486dae10d74a76f00ee902d91f7 From 3f068726d46d7da3b5c729987545b0a01a5d68b9 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 13:53:43 -0500 Subject: [PATCH 17/31] build(deps): bump --- interfaces/jetbrains | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/jetbrains b/interfaces/jetbrains index 30b5d355a..6959ef53a 160000 --- a/interfaces/jetbrains +++ b/interfaces/jetbrains @@ -1 +1 @@ -Subproject commit 30b5d355a67358051e65e892a0c6bd8557e0d164 +Subproject commit 6959ef53aa1d6282176f14787140df561b5bcaad From b18697de557fd437c92c3269cbbc73650e164ad5 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 14:05:18 -0500 Subject: [PATCH 18/31] build(deps): bump --- protocol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol b/protocol index 1127ad15f..36c8a4dee 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit 1127ad15fa305486dae10d74a76f00ee902d91f7 +Subproject commit 36c8a4dee2503e655582da04f5d024076224406a From fdd71c2941b50fc2bb9a726f89d47620c1ac474e Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 18:29:24 -0500 Subject: [PATCH 19/31] Refactor LiveView implementation and Service object structure --- .../spp/platform/common/util/ContextUtil.kt | 4 +- .../core/service/LiveManagementServiceImpl.kt | 1 - .../spp/platform/core/vcs/ServiceVCS.kt | 4 +- .../kotlin/integration/VCSLiveInstrumentIT.kt | 14 ++++++- .../integration/meter/LiveMeterCountTest.kt | 10 +++-- .../integration/meter/LiveMeterGaugeTest.kt | 16 ++------ .../integration/meter/LiveMeterRateTest.kt | 13 +------ .../view/impl/LiveViewServiceImpl.kt | 18 ++++----- .../processor/view/impl/view/LiveLogView.kt | 32 ++++++---------- .../processor/view/impl/view/LiveMeterView.kt | 21 +++------- .../processor/view/impl/view/LiveTraceView.kt | 3 +- .../integration/LiveLogSubscriptionTest.kt | 5 +-- .../integration/LiveMeterPartitionTest.kt | 5 ++- .../integration/RealtimeLiveViewTest.kt | 6 +-- .../test/kotlin/integration/VCSLiveViewIT.kt | 38 +++++++++++-------- protocol | 2 +- 16 files changed, 86 insertions(+), 106 deletions(-) diff --git a/platform/common/src/main/kotlin/spp/platform/common/util/ContextUtil.kt b/platform/common/src/main/kotlin/spp/platform/common/util/ContextUtil.kt index 6333a808f..a6eacce94 100644 --- a/platform/common/src/main/kotlin/spp/platform/common/util/ContextUtil.kt +++ b/platform/common/src/main/kotlin/spp/platform/common/util/ContextUtil.kt @@ -65,14 +65,14 @@ object ContextUtil { if (it != null) { vertxContext.putLocal("commit_id", it) } else { - vertxContext.removeLocal("commit_id") + vertxContext.put("commit_id", "null") } } ENVIRONMENT.get(context).let { if (it != null) { vertxContext.putLocal("environment", it) } else { - vertxContext.removeLocal("environment") + vertxContext.put("environment", "null") } } } diff --git a/platform/core/src/main/kotlin/spp/platform/core/service/LiveManagementServiceImpl.kt b/platform/core/src/main/kotlin/spp/platform/core/service/LiveManagementServiceImpl.kt index 9f33ae8ee..a2d2f0a9a 100644 --- a/platform/core/src/main/kotlin/spp/platform/core/service/LiveManagementServiceImpl.kt +++ b/platform/core/src/main/kotlin/spp/platform/core/service/LiveManagementServiceImpl.kt @@ -570,7 +570,6 @@ class LiveManagementServiceImpl( services.forEach { result.add( Service( - id = it.id, name = it.name, group = it.group, shortName = it.shortName, diff --git a/platform/core/src/main/kotlin/spp/platform/core/vcs/ServiceVCS.kt b/platform/core/src/main/kotlin/spp/platform/core/vcs/ServiceVCS.kt index 7c4a4e87b..f42514b69 100644 --- a/platform/core/src/main/kotlin/spp/platform/core/vcs/ServiceVCS.kt +++ b/platform/core/src/main/kotlin/spp/platform/core/vcs/ServiceVCS.kt @@ -47,13 +47,13 @@ object ServiceVCS { private fun getEnvironment(): String { val env = ContextUtil.ENVIRONMENT.get() - if (env.isNullOrEmpty()) return "" + if (env.isNullOrEmpty()) return "|null" return "|$env" } private fun getCommitId(): String { val commitId = ContextUtil.COMMIT_ID.get() - if (commitId.isNullOrEmpty()) return "" + if (commitId.isNullOrEmpty()) return "|null" return "|$commitId" } } diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/VCSLiveInstrumentIT.kt b/platform/processor/live-instrument/src/test/kotlin/integration/VCSLiveInstrumentIT.kt index aff68c7ca..ace56f802 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/VCSLiveInstrumentIT.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/VCSLiveInstrumentIT.kt @@ -82,11 +82,21 @@ class VCSLiveInstrumentIT : LiveInstrumentIntegrationTest() { if (hitCount.incrementAndGet() == 1) { testContext.verify { - assertEquals(instrument.location.service?.name + "|" + "test1", bpHit.service) + assertEquals( + instrument.location.service?.name + + "|" + instrument.location.service?.environment.toString() + + "|" + "test1", + bpHit.service + ) } } else { testContext.verify { - assertEquals(instrument.location.service?.name + "|" + "test2", bpHit.service) + assertEquals( + instrument.location.service?.name + + "|" + instrument.location.service?.environment.toString() + + "|" + "test2", + bpHit.service + ) } } testContext.completeNow() diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterCountTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterCountTest.kt index fdd188654..c5fdaf125 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterCountTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterCountTest.kt @@ -78,6 +78,7 @@ class LiveMeterCountTest : LiveInstrumentIntegrationTest() { LiveView( entityIds = mutableSetOf(liveMeter.id!!), viewConfig = LiveViewConfig("test", listOf(liveMeter.id!!)), + service = Service.fromName("spp-test-probe") ) ).await().subscriptionId!! @@ -141,7 +142,8 @@ class LiveMeterCountTest : LiveInstrumentIntegrationTest() { val subscriptionId = viewService.addLiveView( LiveView( entityIds = mutableSetOf(liveMeter.id!!), - viewConfig = LiveViewConfig("test", listOf(liveMeter.id!!)) + viewConfig = LiveViewConfig("test", listOf(liveMeter.id!!)), + service = Service.fromName("spp-test-probe") ) ).await().subscriptionId!! @@ -205,7 +207,8 @@ class LiveMeterCountTest : LiveInstrumentIntegrationTest() { val subscriptionId1 = viewService.addLiveView( LiveView( entityIds = mutableSetOf(liveMeter1.id!!), - viewConfig = LiveViewConfig("test", listOf(liveMeter1.id!!)) + viewConfig = LiveViewConfig("test", listOf(liveMeter1.id!!)), + service = Service.fromName("spp-test-probe") ) ).await().subscriptionId!! @@ -226,7 +229,8 @@ class LiveMeterCountTest : LiveInstrumentIntegrationTest() { val subscriptionId2 = viewService.addLiveView( LiveView( entityIds = mutableSetOf(liveMeter2.id!!), - viewConfig = LiveViewConfig("test", listOf(liveMeter2.id!!)) + viewConfig = LiveViewConfig("test", listOf(liveMeter2.id!!)), + service = Service.fromName("spp-test-probe") ) ).await().subscriptionId!! diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt index ed4c56e3c..6c6644d18 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt @@ -24,8 +24,6 @@ import io.vertx.kotlin.coroutines.await import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test -import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.artifact.ArtifactType import spp.protocol.instrument.LiveMeter import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.meter.MeterType @@ -96,18 +94,11 @@ class LiveMeterGaugeTest : LiveInstrumentIntegrationTest() { val subscriptionId = viewService.addLiveView( LiveView( entityIds = mutableSetOf(liveMeter.id!!), - artifactQualifiedName = ArtifactQualifiedName( - LiveMeterGaugeTest::class.java.name, - type = ArtifactType.EXPRESSION - ), - artifactLocation = LiveSourceLocation( - LiveMeterGaugeTest::class.java.name, - getLineNumber("done") - ), viewConfig = LiveViewConfig( "test", listOf(liveMeter.id!!) - ) + ), + service = Service.fromName("spp-test-probe") ) ).await().subscriptionId!! @@ -182,7 +173,8 @@ class LiveMeterGaugeTest : LiveInstrumentIntegrationTest() { val subscriptionId = viewService.addLiveView( LiveView( entityIds = mutableSetOf(liveMeter.id!!), - viewConfig = LiveViewConfig("test", listOf(liveMeter.id!!)) + viewConfig = LiveViewConfig("test", listOf(liveMeter.id!!)), + service = Service.fromName("spp-test-probe") ) ).await().subscriptionId!! diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterRateTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterRateTest.kt index 6507048d1..734f2ab64 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterRateTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterRateTest.kt @@ -28,8 +28,6 @@ import org.junit.jupiter.api.Assumptions.assumeTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.parallel.Isolated -import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.artifact.ArtifactType import spp.protocol.instrument.LiveMeter import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.meter.MeterType @@ -92,18 +90,11 @@ class LiveMeterRateTest : LiveInstrumentIntegrationTest() { val subscriptionId = viewService.addLiveView( LiveView( entityIds = mutableSetOf(liveMeter.id!!), - artifactQualifiedName = ArtifactQualifiedName( - LiveMeterRateTest::class.java.name, - type = ArtifactType.EXPRESSION - ), - artifactLocation = LiveSourceLocation( - LiveMeterRateTest::class.java.name, - getLineNumber("done") - ), viewConfig = LiveViewConfig( "test", listOf(liveMeter.id!!) - ) + ), + service = Service.fromName("spp-test-probe") ) ).await().subscriptionId!! diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt index 9692847d4..f423cf31a 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt @@ -252,7 +252,6 @@ class LiveViewServiceImpl : CoroutineVerticle(), LiveViewService { LiveViewEvent( sub.subscriptionId!!, sub.entityIds.first(), - sub.artifactQualifiedName, firstEvent.getString("timeBucket"), sub.viewConfig, events.toString() @@ -261,7 +260,6 @@ class LiveViewServiceImpl : CoroutineVerticle(), LiveViewService { LiveViewEvent( sub.subscriptionId!!, sub.entityIds.first(), - sub.artifactQualifiedName, event.getString("timeBucket"), sub.viewConfig, event.toString() @@ -312,11 +310,11 @@ class LiveViewServiceImpl : CoroutineVerticle(), LiveViewService { if (unsubbedSubscriber != null) { val removedView = LiveView( - unsubbedSubscriber!!.subscription.subscriptionId, unsubbedSubscriber!!.subscription.entityIds, - unsubbedSubscriber!!.subscription.artifactQualifiedName, - unsubbedSubscriber!!.subscription.artifactLocation, - unsubbedSubscriber!!.subscription.viewConfig + unsubbedSubscriber!!.subscription.viewConfig, + unsubbedSubscriber!!.subscription.service, + unsubbedSubscriber!!.subscription.serviceInstance, + unsubbedSubscriber!!.subscription.subscriptionId, ) log.debug { "Removed live view: {}".args(removedView) } @@ -397,11 +395,11 @@ class LiveViewServiceImpl : CoroutineVerticle(), LiveViewService { if (subbedUser != null) { promise.complete( LiveView( - subbedUser!!.subscription.subscriptionId, subbedUser!!.subscription.entityIds, - subbedUser!!.subscription.artifactQualifiedName, - subbedUser!!.subscription.artifactLocation, - subbedUser!!.subscription.viewConfig + subbedUser!!.subscription.viewConfig, + subbedUser!!.subscription.service, + subbedUser!!.subscription.serviceInstance, + subbedUser!!.subscription.subscriptionId, ) ) } else { diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt index 2afe23469..bdfaff55e 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt @@ -28,7 +28,6 @@ import org.apache.skywalking.oap.log.analyzer.provider.log.listener.LogAnalysisL import org.apache.skywalking.oap.log.analyzer.provider.log.listener.LogAnalysisListenerFactory import org.apache.skywalking.oap.server.core.analysis.Layer import spp.platform.common.ClusterConnection -import spp.platform.common.util.ContextUtil import spp.processor.view.ViewProcessor import spp.processor.view.impl.view.util.MetricTypeSubscriptionCache import spp.processor.view.model.LiveGaugeValueMetrics @@ -81,15 +80,12 @@ class LiveLogView(private val subscriptionCache: MetricTypeSubscriptionCache) : //remove subscribers with additional filters subs = subs.filter { - val subLocation = it.subscription.artifactLocation - if (subLocation != null) { - val logDataLocation = subLocation.copy( - service = subLocation.service?.copy(name = logData.service.substringBefore("|")), - serviceInstance = subLocation.serviceInstance?.let { logData.serviceInstance }, - commitId = subLocation.commitId?.let { ContextUtil.COMMIT_ID.get() } - ) - return@filter subLocation.isSameLocation(logDataLocation) - } + if (it.subscription.serviceInstance?.let { + it != logData.serviceInstance + } == true) return@filter false + if (it.subscription.service?.let { + !it.isSameLocation(it.withName(logData.service)) + } == true) return@filter false return@filter true }.toSet() @@ -103,15 +99,12 @@ class LiveLogView(private val subscriptionCache: MetricTypeSubscriptionCache) : //remove subscribers with additional filters subs = subs.filter { - val subLocation = it.subscription.artifactLocation - if (subLocation != null) { - val logDataLocation = subLocation.copy( - service = subLocation.service?.copy(name = logData.service.substringBefore("|")), - serviceInstance = subLocation.serviceInstance?.let { logData.serviceInstance }, - commitId = subLocation.commitId?.let { ContextUtil.COMMIT_ID.get() } - ) - return@filter subLocation.isSameLocation(logDataLocation) - } + if (it.subscription.serviceInstance?.let { + it != logData.serviceInstance + } == true) return@filter false + if (it.subscription.service?.let { + !it.isSameLocation(it.withName(logData.service)) + } == true) return@filter false return@filter true }.toSet() @@ -152,7 +145,6 @@ class LiveLogView(private val subscriptionCache: MetricTypeSubscriptionCache) : val event = JsonObject() .put("type", "LOGS") .put("multiMetrics", false) - .put("artifactQualifiedName", JsonObject.mapFrom(sub.subscription.artifactQualifiedName)) .put("entityId", logPattern) .put("timeBucket", formatter.format(logRecord.timestamp)) .put("log", JsonObject.mapFrom(logRecord)) diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt index 58117c615..111be0a3b 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt @@ -111,17 +111,12 @@ class LiveMeterView(private val subscriptionCache: MetricTypeSubscriptionCache) //remove subscribers with additional filters subs = subs.filter { - val subLocation = it.subscription.artifactLocation - if (subLocation != null) { - val metricsDataLocation = subLocation.copy( - service = subLocation.service?.let { service -> - metricServiceName?.let { service.copy(name = it.substringBefore("|")) } - }, - serviceInstance = subLocation.serviceInstance?.let { metricServiceInstance }, - commitId = subLocation.commitId?.let { metricServiceName?.substringAfter("|") } - ) - return@filter subLocation.isSameLocation(metricsDataLocation) - } + if (it.subscription.serviceInstance?.let { + it != metricServiceInstance + } == true) return@filter false + if (it.subscription.service?.let { + !it.isSameLocation(it.withName(metricServiceName)) + } == true) return@filter false return@filter true }.toSet() @@ -201,10 +196,6 @@ class LiveMeterView(private val subscriptionCache: MetricTypeSubscriptionCache) val multiMetrics = JsonArray() waitingEventsForBucket.forEach { val metricsOb = JsonObject.mapFrom(it) - .put( - "artifactQualifiedName", - JsonObject.mapFrom(sub.subscription.artifactQualifiedName) - ) .put("entityName", EntityNaming.getEntityName((metrics as WithMetadata).meta)) log.trace { "Sending multi-metrics $metricsOb to ${sub.subscriberId}" } diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveTraceView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveTraceView.kt index a70b09cee..40ba21453 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveTraceView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveTraceView.kt @@ -92,7 +92,7 @@ class LiveTraceView( Instant.ofEpochMilli(span.startTime), Instant.ofEpochMilli(span.endTime), entityId, - subs.first().subscription.artifactQualifiedName, + null, span.spanType.name, span.peer, span.componentId.toString(), @@ -129,7 +129,6 @@ class LiveTraceView( val event = JsonObject() .put("type", "TRACES") .put("multiMetrics", false) - .put("artifactQualifiedName", JsonObject.mapFrom(sub.subscription.artifactQualifiedName)) .put("entityId", entityId) .put("timeBucket", formatter.format(trace.start)) .put("trace", JsonObject.mapFrom(trace)) diff --git a/platform/processor/live-view/src/test/kotlin/integration/LiveLogSubscriptionTest.kt b/platform/processor/live-view/src/test/kotlin/integration/LiveLogSubscriptionTest.kt index 5497105c8..8cc75277a 100644 --- a/platform/processor/live-view/src/test/kotlin/integration/LiveLogSubscriptionTest.kt +++ b/platform/processor/live-view/src/test/kotlin/integration/LiveLogSubscriptionTest.kt @@ -66,10 +66,7 @@ class LiveLogSubscriptionTest : LiveInstrumentIntegrationTest() { LiveView( entityIds = mutableSetOf(liveLog.logFormat), viewConfig = LiveViewConfig("test", listOf("endpoint_logs")), - artifactLocation = LiveSourceLocation( - "", - service = Service.fromName("spp-test-probe") - ) + service = Service.fromName("spp-test-probe") ) ).await().subscriptionId!! log.info("Using subscription id: {}", subscriptionId) diff --git a/platform/processor/live-view/src/test/kotlin/integration/LiveMeterPartitionTest.kt b/platform/processor/live-view/src/test/kotlin/integration/LiveMeterPartitionTest.kt index 15c17486f..8263fca0c 100644 --- a/platform/processor/live-view/src/test/kotlin/integration/LiveMeterPartitionTest.kt +++ b/platform/processor/live-view/src/test/kotlin/integration/LiveMeterPartitionTest.kt @@ -25,6 +25,7 @@ import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.Isolated import spp.protocol.instrument.LiveMeter import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.meter.* @@ -36,6 +37,7 @@ import spp.protocol.view.LiveViewEvent import spp.protocol.view.rule.RulePartition import spp.protocol.view.rule.ViewRule +@Isolated class LiveMeterPartitionTest : LiveInstrumentIntegrationTest() { @Suppress("UNUSED_VARIABLE") @@ -89,7 +91,8 @@ class LiveMeterPartitionTest : LiveInstrumentIntegrationTest() { viewConfig = LiveViewConfig( "test", listOf("${liveMeter.id}_true", "${liveMeter.id}_false") - ) + ), + service = Service.fromName("spp-test-probe") ) ).await().subscriptionId!! diff --git a/platform/processor/live-view/src/test/kotlin/integration/RealtimeLiveViewTest.kt b/platform/processor/live-view/src/test/kotlin/integration/RealtimeLiveViewTest.kt index 5a607d345..dd88ef72c 100644 --- a/platform/processor/live-view/src/test/kotlin/integration/RealtimeLiveViewTest.kt +++ b/platform/processor/live-view/src/test/kotlin/integration/RealtimeLiveViewTest.kt @@ -26,7 +26,6 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import org.junit.jupiter.api.parallel.Isolated import spp.protocol.artifact.metrics.MetricType -import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.platform.general.Service import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscription import spp.protocol.view.LiveView @@ -46,10 +45,7 @@ class RealtimeLiveViewTest : PlatformIntegrationTest() { "test", listOf(MetricType.INSTANCE_JVM_CPU.asRealtime().metricId) ), - artifactLocation = LiveSourceLocation( - "", - service = Service.fromName("spp-test-probe") - ) + service = Service.fromName("spp-test-probe") ) ).await().subscriptionId!! diff --git a/platform/processor/live-view/src/test/kotlin/integration/VCSLiveViewIT.kt b/platform/processor/live-view/src/test/kotlin/integration/VCSLiveViewIT.kt index 09759caeb..5f90ed9e1 100644 --- a/platform/processor/live-view/src/test/kotlin/integration/VCSLiveViewIT.kt +++ b/platform/processor/live-view/src/test/kotlin/integration/VCSLiveViewIT.kt @@ -22,14 +22,12 @@ import io.vertx.junit5.VertxTestContext import io.vertx.kotlin.coroutines.await import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking -import org.apache.skywalking.oap.server.core.analysis.IDManager import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test import org.junit.jupiter.api.parallel.Isolated import spp.probe.ProbeConfiguration import spp.protocol.artifact.metrics.MetricType -import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.platform.general.Service import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscription import spp.protocol.view.LiveView @@ -48,11 +46,7 @@ class VCSLiveViewIT : PlatformIntegrationTest() { "test", listOf(MetricType.INSTANCE_JVM_CPU.asRealtime().metricId) ), - artifactLocation = LiveSourceLocation( - "", - service = Service.fromName("spp-test-probe"), - commitId = "test1" - ) + service = Service.fromName("spp-test-probe").withCommitId("test1"), ) ).await().subscriptionId!! @@ -66,7 +60,11 @@ class VCSLiveViewIT : PlatformIntegrationTest() { ).await() delay(2000) var testContext = VertxTestContext() - verifyHit(testContext, subscriptionId, IDManager.ServiceID.buildId("spp-test-probe|test1", true)) + verifyHit( + testContext, + subscriptionId, + Service.fromName("spp-test-probe").withCommitId("test1").id + ) if (testContext.failed()) { throw testContext.causeOfFailure() } @@ -80,7 +78,12 @@ class VCSLiveViewIT : PlatformIntegrationTest() { ).await() delay(2000) testContext = VertxTestContext() - verifyHit(testContext, subscriptionId, IDManager.ServiceID.buildId("spp-test-probe|test2", true), false) + verifyHit( + testContext, + subscriptionId, + Service.fromName("spp-test-probe").withCommitId("test2").id, + false + ) if (testContext.failed()) { throw testContext.causeOfFailure() } @@ -98,10 +101,7 @@ class VCSLiveViewIT : PlatformIntegrationTest() { "test", listOf(MetricType.INSTANCE_JVM_CPU.asRealtime().metricId) ), - artifactLocation = LiveSourceLocation( - "", - service = Service.fromName("spp-test-probe") - ) + service = Service.fromName("spp-test-probe") ) ).await().subscriptionId!! @@ -115,7 +115,11 @@ class VCSLiveViewIT : PlatformIntegrationTest() { ).await() delay(2000) var testContext = VertxTestContext() - verifyHit(testContext, subscriptionId, IDManager.ServiceID.buildId("spp-test-probe|test1", true)) + verifyHit( + testContext, + subscriptionId, + Service.fromName("spp-test-probe").withCommitId("test1").id + ) if (testContext.failed()) { throw testContext.causeOfFailure() } @@ -129,7 +133,11 @@ class VCSLiveViewIT : PlatformIntegrationTest() { ).await() delay(2000) testContext = VertxTestContext() - verifyHit(testContext, subscriptionId, IDManager.ServiceID.buildId("spp-test-probe|test2", true)) + verifyHit( + testContext, + subscriptionId, + Service.fromName("spp-test-probe").withCommitId("test2").id + ) if (testContext.failed()) { throw testContext.causeOfFailure() } diff --git a/protocol b/protocol index 36c8a4dee..24562c4a9 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit 36c8a4dee2503e655582da04f5d024076224406a +Subproject commit 24562c4a9040d925fc4aff5d740348bc6faa30b6 From 7618b54b26ea4de2508a33c468cc6e657138f5e7 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 18:33:45 -0500 Subject: [PATCH 20/31] build(deps): bump --- demos/kotlin | 2 +- interfaces/cli | 2 +- interfaces/jetbrains | 2 +- probes/jvm | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/demos/kotlin b/demos/kotlin index 48af29a48..bd5832bae 160000 --- a/demos/kotlin +++ b/demos/kotlin @@ -1 +1 @@ -Subproject commit 48af29a48e0b70d599973f130f53841c5a67259a +Subproject commit bd5832bae51906c6988eaac179981cdee05f9483 diff --git a/interfaces/cli b/interfaces/cli index 854642d3a..d0f8b610e 160000 --- a/interfaces/cli +++ b/interfaces/cli @@ -1 +1 @@ -Subproject commit 854642d3a30eb501fe5f785025e30dce4a74fd15 +Subproject commit d0f8b610e4f59e6597798ccac629a84ece69e19f diff --git a/interfaces/jetbrains b/interfaces/jetbrains index 6959ef53a..8a6bf07d2 160000 --- a/interfaces/jetbrains +++ b/interfaces/jetbrains @@ -1 +1 @@ -Subproject commit 6959ef53aa1d6282176f14787140df561b5bcaad +Subproject commit 8a6bf07d29e539466cd18636d2b28324db71dce7 diff --git a/probes/jvm b/probes/jvm index deab9f234..fdb4d7375 160000 --- a/probes/jvm +++ b/probes/jvm @@ -1 +1 @@ -Subproject commit deab9f234a1c96bd678641cf7960eac6c839b33e +Subproject commit fdb4d7375a79ac58f001c3a71c0a622590223dde From 5b5613b9a806b38bc6d28c611558b9c2a1a961fb Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 22:10:54 -0500 Subject: [PATCH 21/31] Add VCS service search and metric merge functionality --- .../view/impl/LiveViewServiceImpl.kt | 67 +++++++++- .../kotlin/integration/VCSHistoricalViewIT.kt | 126 ++++++++++++++++++ 2 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 platform/processor/live-view/src/test/kotlin/integration/VCSHistoricalViewIT.kt diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt index f423cf31a..e5d4a3ffd 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt @@ -24,7 +24,9 @@ import io.vertx.core.json.JsonArray import io.vertx.core.json.JsonObject import io.vertx.kotlin.coroutines.CoroutineVerticle import io.vertx.kotlin.coroutines.await +import io.vertx.kotlin.coroutines.dispatcher import io.vertx.serviceproxy.ServiceException +import kotlinx.coroutines.runBlocking import mu.KotlinLogging import org.apache.skywalking.oap.log.analyzer.module.LogAnalyzerModule import org.apache.skywalking.oap.log.analyzer.provider.log.ILogAnalyzerService @@ -69,6 +71,8 @@ import spp.protocol.artifact.trace.TraceSpan import spp.protocol.artifact.trace.TraceSpanRef import spp.protocol.artifact.trace.TraceStack import spp.protocol.platform.PlatformAddress.MARKER_DISCONNECTED +import spp.protocol.platform.general.Service +import spp.protocol.service.LiveManagementService import spp.protocol.service.LiveViewService import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscriberAddress import spp.protocol.service.SourceServices.Subscribe.toLiveViewSubscription @@ -517,6 +521,55 @@ class LiveViewServiceImpl : CoroutineVerticle(), LiveViewService { entityId: String, duration: Duration, labels: List + ): JsonArray { + val service = try { + Service.fromId(entityId) + } catch (ignored: Exception) { + null + } + + return if (service != null) { + //todo: get VCS services more efficiently (search by active commits) + val devAuth = Vertx.currentContext().getLocal("developer") + val managementService = LiveManagementService.createProxy(vertx, devAuth.accessToken) + val allServices = runBlocking(vertx.dispatcher()) { managementService.getServices().await() } + val searchServices = allServices.filter { + service.isSameLocation(service.withName(it.name)) + } + + val allMetrics = mutableListOf() + searchServices.forEach { + val array = searchService(metricType, it.id, labels, duration) + for (i in 0 until array.size()) { + array.getJsonObject(i).put("service", it.toJson()) + } + allMetrics.add(array) + } + + val mergeArray = JsonArray() + repeat(allMetrics.first().count()) { + mergeArray.add(JsonObject()) + } + allMetrics.forEach { + it.forEachIndexed { i, metrics -> + val a = mergeArray.getJsonObject(i) + val b = metrics as JsonObject + if (a.getValue("value") == null) { + a.mergeIn(b) + } //todo: more accurate merging (env, metric type, etc) + } + } + mergeArray + } else { + searchService(metricType, entityId, labels, duration) + } + } + + private fun searchService( + metricType: MetricType, + entityId: String, + labels: List, + duration: Duration ): JsonArray { val condition = MetricsCondition() condition.name = metricType.metricId @@ -529,13 +582,23 @@ class LiveViewServiceImpl : CoroutineVerticle(), LiveViewService { JsonArray().apply { metricsQuery.readLabeledMetricsValues(condition, labels, duration).forEach { val label = it.label - it.values.values.forEach { add(JsonObject().put("value", it.value).put("label", label)) } + it.values.values.forEach { + val valueOb = JsonObject().put("label", label) + if (!it.isEmptyValue) { + valueOb.put("value", it.value) + } + add(valueOb) + } } } } else { JsonArray().apply { metricsQuery.readMetricsValues(condition, duration).values.values.forEach { - add(JsonObject().put("value", it.value)) + val valueOb = JsonObject() + if (!it.isEmptyValue) { + valueOb.put("value", it.value) + } + add(valueOb) } } } diff --git a/platform/processor/live-view/src/test/kotlin/integration/VCSHistoricalViewIT.kt b/platform/processor/live-view/src/test/kotlin/integration/VCSHistoricalViewIT.kt new file mode 100644 index 000000000..3065f5bed --- /dev/null +++ b/platform/processor/live-view/src/test/kotlin/integration/VCSHistoricalViewIT.kt @@ -0,0 +1,126 @@ +/* + * Source++, the continuous feedback platform for developers. + * Copyright (C) 2022-2023 CodeBrig, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package integration + +import io.vertx.core.json.JsonObject +import io.vertx.kotlin.coroutines.await +import kotlinx.coroutines.delay +import kotlinx.coroutines.runBlocking +import org.junit.jupiter.api.Assertions.assertNotNull +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Assumptions.assumeTrue +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.Isolated +import spp.probe.ProbeConfiguration +import spp.protocol.artifact.metrics.MetricStep +import spp.protocol.instrument.LiveMeter +import spp.protocol.instrument.location.LiveSourceLocation +import spp.protocol.instrument.meter.MeterType +import spp.protocol.instrument.meter.MetricValue +import spp.protocol.instrument.meter.MetricValueType +import spp.protocol.platform.general.Service +import spp.protocol.view.LiveView +import spp.protocol.view.LiveViewConfig +import spp.protocol.view.rule.ViewRule +import java.time.Instant +import java.time.temporal.ChronoUnit + +@Isolated +class VCSHistoricalViewIT : LiveInstrumentIntegrationTest() { + + private fun doTest() { + addLineLabel("done") { Throwable().stackTrace[0].lineNumber } + } + + @Test + fun `vcs historical view`(): Unit = runBlocking { + assumeTrue("true" == System.getProperty("test.includeSlow")) + setupLineLabels { + doTest() + } + + val liveMeter = LiveMeter( + MeterType.GAUGE, + MetricValue(MetricValueType.NUMBER, "2"), + location = LiveSourceLocation( + VCSHistoricalViewIT::class.java.name, + getLineNumber("done"), + Service.fromName("spp-test-probe") + ), + id = testNameAsUniqueInstrumentId, + applyImmediately = true + ) + + val rule = viewService.saveRule( + ViewRule( + name = liveMeter.id!!, + exp = buildString { + append("(") + append(liveMeter.id) + append(".downsampling(LATEST)") + append(").service(['service'], Layer.GENERAL)") + }, + meterIds = listOf(liveMeter.id!!) + ) + ).await() + + val subscriptionId = viewService.addLiveView( + LiveView( + entityIds = mutableSetOf(liveMeter.id!!), + viewConfig = LiveViewConfig("test", listOf(liveMeter.id!!)), + service = Service.fromName("spp-test-probe") + ) + ).await().subscriptionId!! + + instrumentService.addLiveInstrument(liveMeter).await() + doTest() + delay(75_000) + + //update commit id + val probeId = ProbeConfiguration.PROBE_ID + managementService.updateActiveProbeMetadata( + probeId, + JsonObject().put( + "application", + JsonObject().put("git_commit", "test1") + ) + ).await() + delay(75_000) + + val stop = Instant.now().truncatedTo(ChronoUnit.MINUTES) + val start = stop.minusSeconds(5 * 60L) + val historicalView = viewService.getHistoricalMetrics( + listOf(Service.fromName("spp-test-probe").id), + listOf(liveMeter.id!!), + MetricStep.MINUTE, start, stop + ).await() + assertTrue(historicalView.data.map { it as JsonObject }.any { + val service = Service(it.getJsonObject("service")) + it.getString("value") == "2" && service.commitId == "test" + }) + assertTrue(historicalView.data.map { it as JsonObject }.any { + val service = Service(it.getJsonObject("service")) + it.getString("value") == "2" && service.commitId == "test1" + }) + + //clean up + assertNotNull(instrumentService.removeLiveInstrument(liveMeter.id!!).await()) + assertNotNull(viewService.removeLiveView(subscriptionId).await()) + assertNotNull(viewService.deleteRule(rule.name).await()) + } +} From 8124d3405c6c4dae44ecf32b2f2f019b2bb01f48 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 22:30:37 -0500 Subject: [PATCH 22/31] fix: Service serialization --- .../kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt index e5d4a3ffd..a669a7f56 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/LiveViewServiceImpl.kt @@ -532,7 +532,9 @@ class LiveViewServiceImpl : CoroutineVerticle(), LiveViewService { //todo: get VCS services more efficiently (search by active commits) val devAuth = Vertx.currentContext().getLocal("developer") val managementService = LiveManagementService.createProxy(vertx, devAuth.accessToken) - val allServices = runBlocking(vertx.dispatcher()) { managementService.getServices().await() } + val allServices = runBlocking(vertx.dispatcher()) { + managementService.getServices().await().map { it.withName(it.name) } + } val searchServices = allServices.filter { service.isSameLocation(service.withName(it.name)) } From 3715341ce8a2844fe1cc3f3bca741d7ec8fcbe09 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 22:30:50 -0500 Subject: [PATCH 23/31] build(deps): bump --- protocol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol b/protocol index 24562c4a9..e58ad4c5f 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit 24562c4a9040d925fc4aff5d740348bc6faa30b6 +Subproject commit e58ad4c5f9b1f67dcd20e1e4b93a378a4ff3fdcc From 7337b438b020a33c93ec6f8eb2493bfea9dc7d79 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 22:32:32 -0500 Subject: [PATCH 24/31] build: copy SW_ env --- platform/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/build.gradle.kts b/platform/build.gradle.kts index 402d71f4d..77a152a18 100644 --- a/platform/build.gradle.kts +++ b/platform/build.gradle.kts @@ -230,8 +230,8 @@ dockerCompose { startedServices.set(listOf("redis", "spp-platform")) } - //transfer SPP_PROBE_ env vars to containers - System.getenv().filterKeys { it.startsWith("SPP_PROBE_") } + //transfer SPP_PROBE_/SW_ env vars to containers + System.getenv().filterKeys { it.startsWith("SPP_PROBE_") || it.startsWith("SW_") } .forEach { (key, value) -> environment.put(key, value) } } tasks.getByName("composeBuild") From 18642e98ea0c19973b84786f10daf5bf564bdafb Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 22:52:15 -0500 Subject: [PATCH 25/31] Remove unnecessary IDManager usage in LiveMeterView --- .../main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt index 111be0a3b..255db8ad2 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveMeterView.kt @@ -20,7 +20,6 @@ package spp.processor.view.impl.view import io.vertx.core.json.JsonArray import io.vertx.core.json.JsonObject import mu.KotlinLogging -import org.apache.skywalking.oap.server.core.analysis.IDManager import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics import org.apache.skywalking.oap.server.core.analysis.metrics.PercentMetrics import org.apache.skywalking.oap.server.core.analysis.metrics.WithMetadata @@ -81,7 +80,6 @@ class LiveMeterView(private val subscriptionCache: MetricTypeSubscriptionCache) val jsonEvent = toViewEventJson(metrics, realTime) val metricService = EntityNaming.getServiceId(metrics) - val metricServiceName = metricService?.let { IDManager.ServiceID.analysisId(it).name } val metricServiceInstance = EntityNaming.getServiceInstanceId(metadata) if (metricName.startsWith("spp_")) { log.debug { "Processing Source++ metrics: {} - Data: {}".args(metricName, jsonEvent) } @@ -115,7 +113,7 @@ class LiveMeterView(private val subscriptionCache: MetricTypeSubscriptionCache) it != metricServiceInstance } == true) return@filter false if (it.subscription.service?.let { - !it.isSameLocation(it.withName(metricServiceName)) + !it.isSameLocation(it.withId(metricService)) } == true) return@filter false return@filter true }.toSet() From d1d99d469bd211eae08249c0a75c87a91f578912 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 22:52:37 -0500 Subject: [PATCH 26/31] Update default values in spp-test-probe.yml --- .../live-instrument/src/test/resources/spp-test-probe.yml | 6 +++--- .../live-view/src/test/resources/spp-test-probe.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/processor/live-instrument/src/test/resources/spp-test-probe.yml b/platform/processor/live-instrument/src/test/resources/spp-test-probe.yml index a4ee08e87..53d378ec3 100644 --- a/platform/processor/live-instrument/src/test/resources/spp-test-probe.yml +++ b/platform/processor/live-instrument/src/test/resources/spp-test-probe.yml @@ -5,9 +5,9 @@ spp: platform_host: "localhost" platform_port: 12800 application: - environment: ${SPP_APPLICATION_ENVIRONMENT:-test} - version: ${SPP_APPLICATION_VERSION:-test} - git_commit: ${SPP_APPLICATION_GIT_COMMIT:-test} + environment: ${SPP_APPLICATION_ENVIRONMENT:-} + version: ${SPP_APPLICATION_VERSION:-} + git_commit: ${SPP_APPLICATION_GIT_COMMIT:-} skywalking: logging: diff --git a/platform/processor/live-view/src/test/resources/spp-test-probe.yml b/platform/processor/live-view/src/test/resources/spp-test-probe.yml index 42fafec8b..d64f98fed 100644 --- a/platform/processor/live-view/src/test/resources/spp-test-probe.yml +++ b/platform/processor/live-view/src/test/resources/spp-test-probe.yml @@ -5,9 +5,9 @@ spp: platform_host: "localhost" platform_port: 12800 application: - environment: ${SPP_APPLICATION_ENVIRONMENT:-test} - version: ${SPP_APPLICATION_VERSION:-test} - git_commit: ${SPP_APPLICATION_GIT_COMMIT:-test} + environment: ${SPP_APPLICATION_ENVIRONMENT:-} + version: ${SPP_APPLICATION_VERSION:-} + git_commit: ${SPP_APPLICATION_GIT_COMMIT:-} skywalking: logging: From da65d88e27099519fdcb75e18d2ddee27ca44776 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 22:53:12 -0500 Subject: [PATCH 27/31] build(deps): bump --- protocol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol b/protocol index e58ad4c5f..29e36caad 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit e58ad4c5f9b1f67dcd20e1e4b93a378a4ff3fdcc +Subproject commit 29e36caad06af39a48d274ca8352e7b4a39a9106 From 01d492752aa02096328ee942592abda94ef32d94 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 22:56:32 -0500 Subject: [PATCH 28/31] test: isolate --- .../src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt index 6c6644d18..a25ea34c7 100644 --- a/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt +++ b/platform/processor/live-instrument/src/test/kotlin/integration/meter/LiveMeterGaugeTest.kt @@ -24,6 +24,7 @@ import io.vertx.kotlin.coroutines.await import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.Isolated import spp.protocol.instrument.LiveMeter import spp.protocol.instrument.location.LiveSourceLocation import spp.protocol.instrument.meter.MeterType @@ -41,6 +42,7 @@ import java.io.Serializable import java.util.* import java.util.function.Supplier +@Isolated class LiveMeterGaugeTest : LiveInstrumentIntegrationTest() { @Suppress("UNUSED_VARIABLE") From 00bd543c9a9155a652a504fd3c9a3d0b912cd4b4 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 22:57:46 -0500 Subject: [PATCH 29/31] chore: clean --- .../src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt index bdfaff55e..8c7454394 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt @@ -123,7 +123,7 @@ class LiveLogView(private val subscriptionCache: MetricTypeSubscriptionCache) : val logSource = logData.tags.dataList.find { it.key == "source" }?.value val logLineNumber = logData.tags.dataList.find { it.key == "line" }?.value?.toInt() val logLocation = if (logSource != null) { - LiveSourceLocation( //todo: this is different than logDataLocation above + LiveSourceLocation( logSource, logLineNumber ?: -1, service = Service.fromName(logData.service), From b30c0b0dbe33d37b55363ab0fd72b1d668c1e036 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 28 Jun 2023 22:59:27 -0500 Subject: [PATCH 30/31] refactor: clean --- .../main/kotlin/spp/processor/view/impl/view/LiveLogView.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt index 8c7454394..96ad24211 100644 --- a/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt +++ b/platform/processor/live-view/src/main/kotlin/spp/processor/view/impl/view/LiveLogView.kt @@ -76,7 +76,8 @@ class LiveLogView(private val subscriptionCache: MetricTypeSubscriptionCache) : var subbedArtifacts = subscriptionCache["endpoint_logs"] if (subbedArtifacts != null) { val logPattern = logData.body.text.text - var subs = subbedArtifacts[logPattern].orEmpty() + subbedArtifacts["*"].orEmpty() + var subs = subbedArtifacts[logPattern].orEmpty() + + subbedArtifacts["*"].orEmpty() //remove subscribers with additional filters subs = subs.filter { @@ -94,7 +95,7 @@ class LiveLogView(private val subscriptionCache: MetricTypeSubscriptionCache) : subbedArtifacts = subscriptionCache["service_logs"] if (subbedArtifacts != null) { - var subs = subbedArtifacts[logData.service.substringBefore("|")].orEmpty() + + var subs = subbedArtifacts[Service.fromName(logData.service).name].orEmpty() + subbedArtifacts["*"].orEmpty() //remove subscribers with additional filters From 6b0d3ad327558efc71f11987b2e15598f9fc9225 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Sun, 2 Jul 2023 13:56:22 -0500 Subject: [PATCH 31/31] build(deps): bump --- interfaces/cli | 2 +- interfaces/jetbrains | 2 +- probes/nodejs | 2 +- probes/python | 2 +- protocol | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interfaces/cli b/interfaces/cli index d0f8b610e..30c045ca5 160000 --- a/interfaces/cli +++ b/interfaces/cli @@ -1 +1 @@ -Subproject commit d0f8b610e4f59e6597798ccac629a84ece69e19f +Subproject commit 30c045ca5ab7b7a9f6ba7f428008bbf161629ec7 diff --git a/interfaces/jetbrains b/interfaces/jetbrains index 8a6bf07d2..cb2eb20cf 160000 --- a/interfaces/jetbrains +++ b/interfaces/jetbrains @@ -1 +1 @@ -Subproject commit 8a6bf07d29e539466cd18636d2b28324db71dce7 +Subproject commit cb2eb20cf0b415d4e2b0cb7013da7c7890124d21 diff --git a/probes/nodejs b/probes/nodejs index 9c75f23c2..6570686b2 160000 --- a/probes/nodejs +++ b/probes/nodejs @@ -1 +1 @@ -Subproject commit 9c75f23c2ee4e69561cf6ede93a6f0e6661321f6 +Subproject commit 6570686b2bfe26f5afe9fd2d29835e96b0883e6f diff --git a/probes/python b/probes/python index 1879c2fa2..f65899c19 160000 --- a/probes/python +++ b/probes/python @@ -1 +1 @@ -Subproject commit 1879c2fa2c0c054f678ebc65f9f6f0ecea1ac244 +Subproject commit f65899c19775b851c214e33e7557289300de1465 diff --git a/protocol b/protocol index 29e36caad..68a6a9298 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit 29e36caad06af39a48d274ca8352e7b4a39a9106 +Subproject commit 68a6a9298dca71f127af6d694b92d155b7beb14c