Skip to content

v0.4.7 #724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
11e3191
archive media
BFergerson Mar 30, 2022
0620b8b
should be only place that needs null check
BFergerson Mar 30, 2022
deb2eb8
revert to dynamic
BFergerson Mar 30, 2022
d195fa4
fixes #701
BFergerson Mar 30, 2022
2aca7c3
use readme for unreleased
BFergerson Mar 30, 2022
8537719
Merge branch 'master' into dev
BFergerson Mar 30, 2022
86cc58c
verify oldest version
BFergerson Mar 30, 2022
52fcbbe
bump vertx
BFergerson Mar 30, 2022
4bc5313
determine locale
BFergerson Mar 30, 2022
bcf40e5
translate
BFergerson Mar 30, 2022
a6126cd
bump
BFergerson Mar 30, 2022
71b97a3
Merge branch 'master' into dev
BFergerson Mar 30, 2022
bda0f37
impl guide marks
BFergerson Apr 5, 2022
9d012b4
#610
BFergerson Apr 5, 2022
5ac86b6
url can be censored
BFergerson Apr 8, 2022
356f0f2
fix modified check
BFergerson Apr 10, 2022
c8eece3
dev id will always be system
BFergerson Apr 11, 2022
0e3732b
ability to get sw version
BFergerson Apr 11, 2022
d8d8988
#695
BFergerson Apr 11, 2022
3b5a715
sw 9 uses endpoint_resp_time instead of endpoint_avg
BFergerson Apr 11, 2022
92e0f2f
basic py coding for LCP
BFergerson Apr 12, 2022
0069854
Merge branch 'master' into dev
BFergerson Apr 12, 2022
dcfffb0
basic py coding for LCP
BFergerson Apr 12, 2022
22fb9fd
formatting
BFergerson Apr 13, 2022
ec6b4ef
correct defaults
BFergerson Apr 13, 2022
e2a205f
Merge remote-tracking branch 'origin/dev' into dev
BFergerson Apr 13, 2022
b98266b
sw 9 compatability
BFergerson Apr 13, 2022
c3afde4
use guide marks
BFergerson Apr 13, 2022
77102fa
fix isModified (handles override=true)
BFergerson Apr 13, 2022
ed52ee9
sw 9 compatability
BFergerson Apr 13, 2022
7c1d4a2
use guide marks
BFergerson Apr 13, 2022
b0c800b
override can't be modified
BFergerson Apr 18, 2022
a7df1ee
single page portals
BFergerson Apr 19, 2022
a2a4aa0
remove spp-skywalking-reroute header
BFergerson Apr 19, 2022
132cdfb
fix isModified
BFergerson Apr 19, 2022
7c95f0b
changed port 5445 to 12800 for live-platform
BFergerson Apr 19, 2022
6ec9ec5
impl failing endpoint indicator for SW oap
BFergerson Apr 19, 2022
e2e16bf
live platform supports endpoint id and endpoint name subs
BFergerson Apr 19, 2022
f86692e
send events directly to subs
BFergerson Apr 19, 2022
9127d1b
bump
BFergerson Apr 19, 2022
534cfb6
bump
BFergerson Apr 19, 2022
80d2b00
bump
BFergerson Apr 19, 2022
b04a58a
bump
BFergerson Apr 19, 2022
2aaa4f1
/graphql/spp endpoint
BFergerson Apr 20, 2022
ecfad11
Merge branch 'master' into dev
BFergerson Apr 20, 2022
99cc389
bump
BFergerson Apr 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kotlin.code.style=official

pluginGroup = spp.jetbrains
pluginName = Source++
projectVersion=0.4.6
projectVersion=0.4.7
pluginSinceBuild = 202.4357
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
# See https://jb.gg/intellij-platform-builds-list for available build versions
Expand Down
2 changes: 1 addition & 1 deletion monitor/src/main/graphql/.graphqlconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class SkywalkingClient(
serviceId = Optional.presentIfNotNull(request.serviceId),
serviceInstanceId = Optional.presentIfNotNull(request.serviceInstanceId),
endpointId = Optional.presentIfNotNull(request.endpointId),
endpointName = Optional.presentIfNotNull(request.endpointName),
queryDuration = Optional.Present(request.zonedDuration.toDuration(this)),
queryOrder = request.orderType.toQueryOrder(),
traceState = request.orderType.toTraceState(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ class SkywalkingMonitor(
private suspend fun setup() {
log.debug("Apache SkyWalking server: $serverUrl")
val httpBuilder = OkHttpClient().newBuilder()
.addInterceptor { chain ->
chain.proceed(
chain.request().newBuilder()
.addHeader("spp-skywalking-reroute", "true")
.build()
)
}
.hostnameVerifier { _, _ -> true }
if (!jwtToken.isNullOrEmpty()) {
httpBuilder.addInterceptor { chain ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ class SWLiveViewService : CoroutineVerticle(), LiveViewService {
subscriptionMap.forEach { (_, subscription) ->
launch(vertx.dispatcher()) {
when (subscription.subscription.liveViewConfig.viewName) {
"ACTIVITY" -> sendActivitySubscriptionUpdate(subscription)
"LOGS" -> pullLatestLogs(subscription)
"TRACES" -> sendTracesSubscriptionUpdate(subscription)
else -> TODO("not implemented")
else -> sendEndpointMetricSubscriptionUpdate(subscription)
}
}
}
Expand All @@ -92,7 +91,7 @@ class SWLiveViewService : CoroutineVerticle(), LiveViewService {

private suspend fun sendTracesSubscriptionUpdate(swSubscription: SWLiveViewSubscription) {
val subscription = swSubscription.subscription
val endpointId = subscription.artifactQualifiedName.operationName!! //todo: PortalEventListener sets temp
val endpointId = subscription.entityIds.first()
val traceResult = EndpointTracesBridge.getTraces(
GetEndpointTraces(
artifactQualifiedName = subscription.artifactQualifiedName,
Expand Down Expand Up @@ -167,15 +166,14 @@ class SWLiveViewService : CoroutineVerticle(), LiveViewService {
}
}

private suspend fun sendActivitySubscriptionUpdate(swSubscription: SWLiveViewSubscription) {
private suspend fun sendEndpointMetricSubscriptionUpdate(swSubscription: SWLiveViewSubscription) {
val subscription = swSubscription.subscription
val endpointId = subscription.artifactQualifiedName.operationName!! //todo: PortalEventListener & ActivityQuickStatsIndicator sets temp
val lastMetricsByTimeBucket = swSubscription.lastMetricsByTimeBucket
val endTime = ZonedDateTime.now().plusMinutes(1).truncatedTo(ChronoUnit.MINUTES) //exclusive
val startTime = endTime.minusMinutes(3)
val metricsRequest = GetEndpointMetrics(
subscription.liveViewConfig.viewMetrics,
endpointId, //subscription.entityIds.first(),
subscription.entityIds.first(),
ZonedDuration(startTime, endTime, SkywalkingClient.DurationStep.MINUTE)
)

Expand Down Expand Up @@ -216,8 +214,7 @@ class SWLiveViewService : CoroutineVerticle(), LiveViewService {
value: Any
): JsonObject {
return JsonObject()
.put("entityId", subscription.artifactQualifiedName.operationName) //todo: PortalEventListener sets temp
.put("entityName", subscription.entityIds.first())
.put("entityId", subscription.entityIds.first())
.put("serviceId", "todo")
.put("value", value)
.put("total", value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private void initComponents() {
textField1 = new AutocompleteField(
message("location") + ": " + location + "#" + inlayMark.getLineNumber(),
availableCommands, lookup, inlayMark.getArtifactQualifiedName(), true, true, SELECT_COLOR_RED);
textField1.setCellRenderer(new ControlBarCellRenderer(textField1));
textField1.setCellRenderer(new ControlBarCellRenderer(textField1, (ExpressionSourceMark) inlayMark));
label2 = new JLabel();

//======== this ========
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ public JComponent getContentPane() {
}

boolean isModified() {
if (!Arrays.equals(rootSourcePackageTextField.getText().split(","), config.getRootSourcePackages().toArray())) {
if (config.getOverride()) return false;

if (!Arrays.equals(Arrays.stream(rootSourcePackageTextField.getText().split(",")).filter(s -> !s.isEmpty()).toArray(), config.getRootSourcePackages().toArray())) {
return true;
}
if (!Objects.equals(autoResolveEndpointNamesCheckBox.isSelected(), config.getAutoResolveEndpointNames())) {
Expand All @@ -102,7 +104,7 @@ boolean isModified() {
if (!Objects.equals(debugConsoleCheckBox.isSelected(), config.getPluginConsoleEnabled())) {
return true;
}
if (!Objects.equals(serviceHostTextField.getText(), config.getServiceHost())) {
if (!Objects.equals(serviceHostTextField.getText(), config.getServiceHost() != null ? config.getServiceHost() : "")) {
return true;
}
if (!Objects.equals(accessTokenTextField.getText(), config.getAccessToken() != null ? config.getAccessToken() : "")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@
import static spp.jetbrains.sourcemarker.PluginBundle.message;
import static spp.jetbrains.sourcemarker.PluginUI.*;
import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener;
import static spp.protocol.marshall.ProtocolMarshaller.deserializeLiveInstrumentRemoved;
import static spp.protocol.SourceServices.Instance.INSTANCE;
import static spp.protocol.instrument.event.LiveInstrumentEventType.BREAKPOINT_HIT;
import static spp.protocol.instrument.event.LiveInstrumentEventType.BREAKPOINT_REMOVED;
import static spp.protocol.marshall.ProtocolMarshaller.deserializeLiveInstrumentRemoved;

public class BreakpointStatusBar extends JPanel implements StatusBar, InstrumentEventListener, VisibleAreaListener {
public class BreakpointStatusBar extends JPanel implements StatusBar, InstrumentEventListener, VisibleAreaListener {

private final InlayMark inlayMark;
private final LiveSourceLocation sourceLocation;
Expand Down Expand Up @@ -146,7 +146,7 @@ public void setWrapperPanel(JPanel wrapperPanel) {
@Override
public void visibleAreaChanged(VisibleAreaEvent e) {
breakpointConditionField.hideAutocompletePopup();
if(popup != null) {
if (popup != null) {
popup.dispose();
popup = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
import eu.geekplace.javapinning.JavaPinning
import eu.geekplace.javapinning.pin.Pin
import io.vertx.core.MultiMap
import io.vertx.core.Vertx
import io.vertx.core.VertxOptions
import io.vertx.core.http.HttpClientOptions
Expand All @@ -44,7 +45,6 @@ import io.vertx.core.json.DecodeException
import io.vertx.core.json.Json
import io.vertx.core.json.JsonObject
import io.vertx.core.net.TrustOptions
import io.vertx.ext.auth.impl.jose.JWT
import io.vertx.kotlin.coroutines.await
import io.vertx.kotlin.coroutines.dispatcher
import io.vertx.servicediscovery.ServiceDiscovery
Expand Down Expand Up @@ -88,6 +88,7 @@ import spp.protocol.service.LiveService
import spp.protocol.service.LiveViewService
import java.awt.Dimension
import java.io.File
import javax.net.ssl.SSLHandshakeException

/**
* Sets up the SourceMarker plugin by configuring and initializing the various plugin modules.
Expand Down Expand Up @@ -304,7 +305,7 @@ object SourceMarkerPlugin {
if (persistedConfig == null && fileConfig != null) {
fileConfig
} else {
SourceMarkerConfig(override = true)
persistedConfig ?: SourceMarkerConfig()
}
}
return config
Expand Down Expand Up @@ -413,7 +414,7 @@ object SourceMarkerPlugin {

private suspend fun initServices(project: Project, config: SourceMarkerConfig) {
if (!config.serviceHost.isNullOrBlank()) {
val servicePort = config.getServicePortNormalized()!!
val servicePort = config.getServicePortNormalized()
val certificatePins = mutableListOf<String>()
certificatePins.addAll(config.certificatePins)
val httpClientOptions = if (certificatePins.isNotEmpty()) {
Expand All @@ -437,8 +438,9 @@ object SourceMarkerPlugin {
val tokenUri = "/api/new-token?access_token=" + config.accessToken
val req = vertx.createHttpClient(httpClientOptions).request(
RequestOptions()
.setHeaders(MultiMap.caseInsensitiveMultiMap().add("spp-platform-request", "true"))
.setSsl(config.isSsl())
.setHost(config.serviceHostNormalized!!)
.setHost(config.serviceHostNormalized)
.setPort(servicePort)
.setURI(tokenUri)
).await()
Expand All @@ -456,38 +458,73 @@ object SourceMarkerPlugin {
}
} else {
//try default local access
val defaultAccessToken = "change-me"
val tokenUri = "/api/new-token?access_token=$defaultAccessToken"
val req = vertx.createHttpClient(HttpClientOptions().setSsl(true).setVerifyHost(false).setTrustAll(true))
.request(
RequestOptions()
.setHost("localhost")
.setPort(SourceMarkerConfig.DEFAULT_SERVICE_PORT)
.setURI(tokenUri)
).await()
req.end().await()
val resp = req.response().await()
if (resp.statusCode() in 200..299) {
val body = resp.body().await().toString()
config.serviceToken = body
try {
tryDefaultAccess(true, config, project)
} catch (e: SSLHandshakeException) {
tryDefaultAccess(false, config, project)
} catch (e: Exception) {
log.warn("Unable to find local live platform", e)
}
}
}

private suspend fun tryDefaultAccess(ssl: Boolean, config: SourceMarkerConfig, project: Project) {
val defaultAccessToken = "change-me"
val tokenUri = "/api/new-token?access_token=$defaultAccessToken"
val req = vertx.createHttpClient(HttpClientOptions().setSsl(ssl).setVerifyHost(false).setTrustAll(true))
.request(
RequestOptions()
.setHeaders(MultiMap.caseInsensitiveMultiMap().add("spp-platform-request", "true"))
.setHost("localhost")
.setPort(SourceMarkerConfig.DEFAULT_SERVICE_PORT)
.setURI(tokenUri)
).await()
req.end().await()

val resp = req.response().await()
if (resp.statusCode() in 200..299) {
val body = resp.body().await().toString()
config.serviceToken = body
if (ssl) {
config.serviceHost = "https://localhost:" + SourceMarkerConfig.DEFAULT_SERVICE_PORT
config.accessToken = defaultAccessToken
config.verifyHost = false
} else {
config.serviceHost = "http://localhost:" + SourceMarkerConfig.DEFAULT_SERVICE_PORT
}
config.accessToken = defaultAccessToken
config.verifyHost = false

val projectSettings = PropertiesComponent.getInstance(project)
projectSettings.setValue("sourcemarker_plugin_config", Json.encode(config))
val projectSettings = PropertiesComponent.getInstance(project)
projectSettings.setValue("sourcemarker_plugin_config", Json.encode(config))

discoverAvailableServices(config, project)
discoverAvailableServices(config, project)

//auto-established notification
Notifications.Bus.notify(
Notification(
message("plugin_name"), "Connection auto-established",
"You have successfully auto-connected. ${message("plugin_name")} is now fully activated.",
NotificationType.INFORMATION
)
//auto-established notification
Notifications.Bus.notify(
Notification(
message("plugin_name"), "Connection auto-established",
"You have successfully auto-connected to Live Platform. ${message("plugin_name")} is now fully activated.",
NotificationType.INFORMATION
)
)
} else if (resp.statusCode() == 405) {
//found skywalking OAP server
if (ssl) {
config.serviceHost = "https://localhost:" + SourceMarkerConfig.DEFAULT_SERVICE_PORT
} else {
config.serviceHost = "http://localhost:" + SourceMarkerConfig.DEFAULT_SERVICE_PORT
config.verifyHost = false
}
val projectSettings = PropertiesComponent.getInstance(project)
projectSettings.setValue("sourcemarker_plugin_config", Json.encode(config))

//auto-established notification
Notifications.Bus.notify(
Notification(
message("plugin_name"), "Connection auto-established",
"You have successfully auto-connected to Apache SkyWalking. ${message("plugin_name")} is now fully activated.",
NotificationType.INFORMATION
)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import spp.jetbrains.marker.source.SourceFileMarker
import spp.jetbrains.marker.source.mark.api.MethodSourceMark
import spp.jetbrains.marker.source.mark.api.SourceMark
import spp.jetbrains.marker.source.mark.api.component.swing.SwingSourceMarkComponentProvider
import spp.jetbrains.marker.source.mark.api.event.SourceMarkEvent
import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode.*
import spp.jetbrains.marker.source.mark.inlay.ExpressionInlayMark
import spp.jetbrains.marker.source.mark.inlay.InlayMark
Expand Down Expand Up @@ -236,8 +235,8 @@ object ControlBarController {
private fun handleViewPortalCommand(editor: Editor, command: LiveControlCommand) {
val sourceMark = SourceMarkSearch.getClosestSourceMark(previousControlBar!!.sourceFileMarker, editor)
if (sourceMark != null) {
sourceMark.triggerEvent(SourceMarkEvent(sourceMark, UPDATE_PORTAL_CONFIG, command)) {
sourceMark.triggerEvent(SourceMarkEvent(sourceMark, PORTAL_OPENING))
sourceMark.triggerEvent(UPDATE_PORTAL_CONFIG, listOf(command)) {
sourceMark.triggerEvent(PORTAL_OPENING, listOf(PORTAL_OPENING))
}
} else {
log.warn("No source mark found for command: {}", command)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package spp.jetbrains.sourcemarker.portal
import com.fasterxml.jackson.databind.module.SimpleModule
import com.intellij.ide.ui.laf.IntelliJLaf
import com.intellij.openapi.application.ApplicationManager
import io.vertx.core.json.JsonObject
import io.vertx.core.json.jackson.DatabindCodec
import io.vertx.kotlin.coroutines.CoroutineVerticle
import io.vertx.kotlin.coroutines.await
Expand All @@ -31,6 +32,7 @@ import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode
import spp.jetbrains.marker.source.mark.guide.GuideMark
import spp.jetbrains.portal.SourcePortal
import spp.jetbrains.portal.backend.PortalServer
import spp.jetbrains.portal.protocol.ProtocolAddress.Global.RenderPage
import spp.jetbrains.portal.protocol.portal.PageType
import spp.jetbrains.sourcemarker.command.LiveControlCommand
import spp.jetbrains.sourcemarker.command.LiveControlCommand.*
Expand Down Expand Up @@ -71,27 +73,36 @@ class PortalController(private val markerConfig: SourceMarkerConfig) : Coroutine
val genUrl = "http://localhost:${portalServer.serverPort}?portalUuid=${portal.portalUuid}"
it.sourceMark.addEventListener {
if (it.eventCode == SourceMarkEventCode.UPDATE_PORTAL_CONFIG) {
when (val command = it.params.first() as LiveControlCommand) {
VIEW_OVERVIEW -> portal.configuration.config["currentPage"] = PageType.OVERVIEW
VIEW_ACTIVITY -> portal.configuration.config["currentPage"] = PageType.ACTIVITY
VIEW_TRACES -> portal.configuration.config["currentPage"] = PageType.TRACES
VIEW_LOGS -> portal.configuration.config["currentPage"] = PageType.LOGS
val newPage = when (val command = it.params.first() as LiveControlCommand) {
VIEW_OVERVIEW -> PageType.OVERVIEW
VIEW_ACTIVITY -> PageType.ACTIVITY
VIEW_TRACES -> PageType.TRACES
VIEW_LOGS -> PageType.LOGS
else -> throw UnsupportedOperationException("Command input: $command")
}

val jcefComponent = it.sourceMark.sourceMarkComponent as SourceMarkJcefComponent
jcefComponent.configuration.currentUrl = "#"
if (newPage != portal.configuration.config["currentPage"]) {
log.info("Setting portal page to $newPage")
portal.configuration.config["currentPage"] = newPage
}
} else if (it.eventCode == SourceMarkEventCode.PORTAL_OPENING) {
SourcePortal.getPortals().filter { it.portalUuid != portal.portalUuid }.forEach {
it.configuration.config["active"] = false
}
portal.configuration.config["active"] = true

val jcefComponent = it.sourceMark.sourceMarkComponent as SourceMarkJcefComponent
portal.configuration.darkMode = UIManager.getLookAndFeel() !is IntelliJLaf

if (jcefComponent.configuration.currentUrl != genUrl) {
if (jcefComponent.configuration.currentUrl == "about:blank") {
jcefComponent.configuration.initialUrl = genUrl
jcefComponent.configuration.currentUrl = genUrl
jcefComponent.getBrowser().cefBrowser.executeJavaScript(
"window.location.href = '$genUrl';", genUrl, 0
)
}
portal.configuration.config["portal_uuid"] = portal.portalUuid
vertx.eventBus().publish(RenderPage, JsonObject.mapFrom(portal.configuration))
ApplicationManager.getApplication().invokeLater(it.sourceMark::displayPopup)
}
}
Expand Down
Loading