Skip to content

Commit e6eb528

Browse files
authored
v0.4.7 (#724)
* archive media * should be only place that needs null check * revert to dynamic * fixes #701 * use readme for unreleased * verify oldest version * bump vertx * determine locale * translate * bump * impl guide marks * #610 * url can be censored * fix modified check * dev id will always be system * ability to get sw version * #695 * sw 9 uses endpoint_resp_time instead of endpoint_avg * basic py coding for LCP * basic py coding for LCP * formatting * correct defaults * sw 9 compatability * use guide marks * fix isModified (handles override=true) * sw 9 compatability * use guide marks * override can't be modified * single page portals preload views * remove spp-skywalking-reroute header add spp-platform-request header changed port 5445 to 12800 for live-platform * fix isModified * changed port 5445 to 12800 for live-platform * impl failing endpoint indicator for SW oap * live platform supports endpoint id and endpoint name subs * send events directly to subs * bump * bump * bump * bump * /graphql/spp endpoint * bump
1 parent 75f0115 commit e6eb528

File tree

20 files changed

+162
-101
lines changed

20 files changed

+162
-101
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kotlin.code.style=official
44

55
pluginGroup = spp.jetbrains
66
pluginName = Source++
7-
projectVersion=0.4.6
7+
projectVersion=0.4.7
88
pluginSinceBuild = 202.4357
99
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
1010
# See https://jb.gg/intellij-platform-builds-list for available build versions

monitor/src/main/graphql/.graphqlconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
}
1313
}
1414
}
15-
}
15+
}

monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingClient.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ class SkywalkingClient(
127127
serviceId = Optional.presentIfNotNull(request.serviceId),
128128
serviceInstanceId = Optional.presentIfNotNull(request.serviceInstanceId),
129129
endpointId = Optional.presentIfNotNull(request.endpointId),
130-
endpointName = Optional.presentIfNotNull(request.endpointName),
131130
queryDuration = Optional.Present(request.zonedDuration.toDuration(this)),
132131
queryOrder = request.orderType.toQueryOrder(),
133132
traceState = request.orderType.toTraceState(),

monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/SkywalkingMonitor.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,6 @@ class SkywalkingMonitor(
6464
private suspend fun setup() {
6565
log.debug("Apache SkyWalking server: $serverUrl")
6666
val httpBuilder = OkHttpClient().newBuilder()
67-
.addInterceptor { chain ->
68-
chain.proceed(
69-
chain.request().newBuilder()
70-
.addHeader("spp-skywalking-reroute", "true")
71-
.build()
72-
)
73-
}
7467
.hostnameVerifier { _, _ -> true }
7568
if (!jwtToken.isNullOrEmpty()) {
7669
httpBuilder.addInterceptor { chain ->

monitor/src/main/kotlin/spp/jetbrains/monitor/skywalking/service/SWLiveViewService.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ class SWLiveViewService : CoroutineVerticle(), LiveViewService {
7575
subscriptionMap.forEach { (_, subscription) ->
7676
launch(vertx.dispatcher()) {
7777
when (subscription.subscription.liveViewConfig.viewName) {
78-
"ACTIVITY" -> sendActivitySubscriptionUpdate(subscription)
7978
"LOGS" -> pullLatestLogs(subscription)
8079
"TRACES" -> sendTracesSubscriptionUpdate(subscription)
81-
else -> TODO("not implemented")
80+
else -> sendEndpointMetricSubscriptionUpdate(subscription)
8281
}
8382
}
8483
}
@@ -92,7 +91,7 @@ class SWLiveViewService : CoroutineVerticle(), LiveViewService {
9291

9392
private suspend fun sendTracesSubscriptionUpdate(swSubscription: SWLiveViewSubscription) {
9493
val subscription = swSubscription.subscription
95-
val endpointId = subscription.artifactQualifiedName.operationName!! //todo: PortalEventListener sets temp
94+
val endpointId = subscription.entityIds.first()
9695
val traceResult = EndpointTracesBridge.getTraces(
9796
GetEndpointTraces(
9897
artifactQualifiedName = subscription.artifactQualifiedName,
@@ -167,15 +166,14 @@ class SWLiveViewService : CoroutineVerticle(), LiveViewService {
167166
}
168167
}
169168

170-
private suspend fun sendActivitySubscriptionUpdate(swSubscription: SWLiveViewSubscription) {
169+
private suspend fun sendEndpointMetricSubscriptionUpdate(swSubscription: SWLiveViewSubscription) {
171170
val subscription = swSubscription.subscription
172-
val endpointId = subscription.artifactQualifiedName.operationName!! //todo: PortalEventListener & ActivityQuickStatsIndicator sets temp
173171
val lastMetricsByTimeBucket = swSubscription.lastMetricsByTimeBucket
174172
val endTime = ZonedDateTime.now().plusMinutes(1).truncatedTo(ChronoUnit.MINUTES) //exclusive
175173
val startTime = endTime.minusMinutes(3)
176174
val metricsRequest = GetEndpointMetrics(
177175
subscription.liveViewConfig.viewMetrics,
178-
endpointId, //subscription.entityIds.first(),
176+
subscription.entityIds.first(),
179177
ZonedDuration(startTime, endTime, SkywalkingClient.DurationStep.MINUTE)
180178
)
181179

@@ -216,8 +214,7 @@ class SWLiveViewService : CoroutineVerticle(), LiveViewService {
216214
value: Any
217215
): JsonObject {
218216
return JsonObject()
219-
.put("entityId", subscription.artifactQualifiedName.operationName) //todo: PortalEventListener sets temp
220-
.put("entityName", subscription.entityIds.first())
217+
.put("entityId", subscription.entityIds.first())
221218
.put("serviceId", "todo")
222219
.put("value", value)
223220
.put("total", value)

plugin/src/main/java/spp/jetbrains/sourcemarker/ControlBar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private void initComponents() {
201201
textField1 = new AutocompleteField(
202202
message("location") + ": " + location + "#" + inlayMark.getLineNumber(),
203203
availableCommands, lookup, inlayMark.getArtifactQualifiedName(), true, true, SELECT_COLOR_RED);
204-
textField1.setCellRenderer(new ControlBarCellRenderer(textField1));
204+
textField1.setCellRenderer(new ControlBarCellRenderer(textField1, (ExpressionSourceMark) inlayMark));
205205
label2 = new JLabel();
206206

207207
//======== this ========

plugin/src/main/java/spp/jetbrains/sourcemarker/settings/PluginConfigurationPanel.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ public JComponent getContentPane() {
9393
}
9494

9595
boolean isModified() {
96-
if (!Arrays.equals(rootSourcePackageTextField.getText().split(","), config.getRootSourcePackages().toArray())) {
96+
if (config.getOverride()) return false;
97+
98+
if (!Arrays.equals(Arrays.stream(rootSourcePackageTextField.getText().split(",")).filter(s -> !s.isEmpty()).toArray(), config.getRootSourcePackages().toArray())) {
9799
return true;
98100
}
99101
if (!Objects.equals(autoResolveEndpointNamesCheckBox.isSelected(), config.getAutoResolveEndpointNames())) {
@@ -102,7 +104,7 @@ boolean isModified() {
102104
if (!Objects.equals(debugConsoleCheckBox.isSelected(), config.getPluginConsoleEnabled())) {
103105
return true;
104106
}
105-
if (!Objects.equals(serviceHostTextField.getText(), config.getServiceHost())) {
107+
if (!Objects.equals(serviceHostTextField.getText(), config.getServiceHost() != null ? config.getServiceHost() : "")) {
106108
return true;
107109
}
108110
if (!Objects.equals(accessTokenTextField.getText(), config.getAccessToken() != null ? config.getAccessToken() : "")) {

plugin/src/main/java/spp/jetbrains/sourcemarker/status/BreakpointStatusBar.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@
5757
import static spp.jetbrains.sourcemarker.PluginBundle.message;
5858
import static spp.jetbrains.sourcemarker.PluginUI.*;
5959
import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener;
60-
import static spp.protocol.marshall.ProtocolMarshaller.deserializeLiveInstrumentRemoved;
6160
import static spp.protocol.SourceServices.Instance.INSTANCE;
6261
import static spp.protocol.instrument.event.LiveInstrumentEventType.BREAKPOINT_HIT;
6362
import static spp.protocol.instrument.event.LiveInstrumentEventType.BREAKPOINT_REMOVED;
63+
import static spp.protocol.marshall.ProtocolMarshaller.deserializeLiveInstrumentRemoved;
6464

65-
public class BreakpointStatusBar extends JPanel implements StatusBar, InstrumentEventListener, VisibleAreaListener {
65+
public class BreakpointStatusBar extends JPanel implements StatusBar, InstrumentEventListener, VisibleAreaListener {
6666

6767
private final InlayMark inlayMark;
6868
private final LiveSourceLocation sourceLocation;
@@ -146,7 +146,7 @@ public void setWrapperPanel(JPanel wrapperPanel) {
146146
@Override
147147
public void visibleAreaChanged(VisibleAreaEvent e) {
148148
breakpointConditionField.hideAutocompletePopup();
149-
if(popup != null) {
149+
if (popup != null) {
150150
popup.dispose();
151151
popup = null;
152152
}

plugin/src/main/kotlin/spp/jetbrains/sourcemarker/SourceMarkerPlugin.kt

Lines changed: 67 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent
3636
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
3737
import eu.geekplace.javapinning.JavaPinning
3838
import eu.geekplace.javapinning.pin.Pin
39+
import io.vertx.core.MultiMap
3940
import io.vertx.core.Vertx
4041
import io.vertx.core.VertxOptions
4142
import io.vertx.core.http.HttpClientOptions
@@ -44,7 +45,6 @@ import io.vertx.core.json.DecodeException
4445
import io.vertx.core.json.Json
4546
import io.vertx.core.json.JsonObject
4647
import io.vertx.core.net.TrustOptions
47-
import io.vertx.ext.auth.impl.jose.JWT
4848
import io.vertx.kotlin.coroutines.await
4949
import io.vertx.kotlin.coroutines.dispatcher
5050
import io.vertx.servicediscovery.ServiceDiscovery
@@ -88,6 +88,7 @@ import spp.protocol.service.LiveService
8888
import spp.protocol.service.LiveViewService
8989
import java.awt.Dimension
9090
import java.io.File
91+
import javax.net.ssl.SSLHandshakeException
9192

9293
/**
9394
* Sets up the SourceMarker plugin by configuring and initializing the various plugin modules.
@@ -304,7 +305,7 @@ object SourceMarkerPlugin {
304305
if (persistedConfig == null && fileConfig != null) {
305306
fileConfig
306307
} else {
307-
SourceMarkerConfig(override = true)
308+
persistedConfig ?: SourceMarkerConfig()
308309
}
309310
}
310311
return config
@@ -413,7 +414,7 @@ object SourceMarkerPlugin {
413414

414415
private suspend fun initServices(project: Project, config: SourceMarkerConfig) {
415416
if (!config.serviceHost.isNullOrBlank()) {
416-
val servicePort = config.getServicePortNormalized()!!
417+
val servicePort = config.getServicePortNormalized()
417418
val certificatePins = mutableListOf<String>()
418419
certificatePins.addAll(config.certificatePins)
419420
val httpClientOptions = if (certificatePins.isNotEmpty()) {
@@ -437,8 +438,9 @@ object SourceMarkerPlugin {
437438
val tokenUri = "/api/new-token?access_token=" + config.accessToken
438439
val req = vertx.createHttpClient(httpClientOptions).request(
439440
RequestOptions()
441+
.setHeaders(MultiMap.caseInsensitiveMultiMap().add("spp-platform-request", "true"))
440442
.setSsl(config.isSsl())
441-
.setHost(config.serviceHostNormalized!!)
443+
.setHost(config.serviceHostNormalized)
442444
.setPort(servicePort)
443445
.setURI(tokenUri)
444446
).await()
@@ -456,38 +458,73 @@ object SourceMarkerPlugin {
456458
}
457459
} else {
458460
//try default local access
459-
val defaultAccessToken = "change-me"
460-
val tokenUri = "/api/new-token?access_token=$defaultAccessToken"
461-
val req = vertx.createHttpClient(HttpClientOptions().setSsl(true).setVerifyHost(false).setTrustAll(true))
462-
.request(
463-
RequestOptions()
464-
.setHost("localhost")
465-
.setPort(SourceMarkerConfig.DEFAULT_SERVICE_PORT)
466-
.setURI(tokenUri)
467-
).await()
468-
req.end().await()
469-
val resp = req.response().await()
470-
if (resp.statusCode() in 200..299) {
471-
val body = resp.body().await().toString()
472-
config.serviceToken = body
461+
try {
462+
tryDefaultAccess(true, config, project)
463+
} catch (e: SSLHandshakeException) {
464+
tryDefaultAccess(false, config, project)
465+
} catch (e: Exception) {
466+
log.warn("Unable to find local live platform", e)
467+
}
468+
}
469+
}
470+
471+
private suspend fun tryDefaultAccess(ssl: Boolean, config: SourceMarkerConfig, project: Project) {
472+
val defaultAccessToken = "change-me"
473+
val tokenUri = "/api/new-token?access_token=$defaultAccessToken"
474+
val req = vertx.createHttpClient(HttpClientOptions().setSsl(ssl).setVerifyHost(false).setTrustAll(true))
475+
.request(
476+
RequestOptions()
477+
.setHeaders(MultiMap.caseInsensitiveMultiMap().add("spp-platform-request", "true"))
478+
.setHost("localhost")
479+
.setPort(SourceMarkerConfig.DEFAULT_SERVICE_PORT)
480+
.setURI(tokenUri)
481+
).await()
482+
req.end().await()
483+
484+
val resp = req.response().await()
485+
if (resp.statusCode() in 200..299) {
486+
val body = resp.body().await().toString()
487+
config.serviceToken = body
488+
if (ssl) {
473489
config.serviceHost = "https://localhost:" + SourceMarkerConfig.DEFAULT_SERVICE_PORT
474-
config.accessToken = defaultAccessToken
475-
config.verifyHost = false
490+
} else {
491+
config.serviceHost = "http://localhost:" + SourceMarkerConfig.DEFAULT_SERVICE_PORT
492+
}
493+
config.accessToken = defaultAccessToken
494+
config.verifyHost = false
476495

477-
val projectSettings = PropertiesComponent.getInstance(project)
478-
projectSettings.setValue("sourcemarker_plugin_config", Json.encode(config))
496+
val projectSettings = PropertiesComponent.getInstance(project)
497+
projectSettings.setValue("sourcemarker_plugin_config", Json.encode(config))
479498

480-
discoverAvailableServices(config, project)
499+
discoverAvailableServices(config, project)
481500

482-
//auto-established notification
483-
Notifications.Bus.notify(
484-
Notification(
485-
message("plugin_name"), "Connection auto-established",
486-
"You have successfully auto-connected. ${message("plugin_name")} is now fully activated.",
487-
NotificationType.INFORMATION
488-
)
501+
//auto-established notification
502+
Notifications.Bus.notify(
503+
Notification(
504+
message("plugin_name"), "Connection auto-established",
505+
"You have successfully auto-connected to Live Platform. ${message("plugin_name")} is now fully activated.",
506+
NotificationType.INFORMATION
489507
)
508+
)
509+
} else if (resp.statusCode() == 405) {
510+
//found skywalking OAP server
511+
if (ssl) {
512+
config.serviceHost = "https://localhost:" + SourceMarkerConfig.DEFAULT_SERVICE_PORT
513+
} else {
514+
config.serviceHost = "http://localhost:" + SourceMarkerConfig.DEFAULT_SERVICE_PORT
515+
config.verifyHost = false
490516
}
517+
val projectSettings = PropertiesComponent.getInstance(project)
518+
projectSettings.setValue("sourcemarker_plugin_config", Json.encode(config))
519+
520+
//auto-established notification
521+
Notifications.Bus.notify(
522+
Notification(
523+
message("plugin_name"), "Connection auto-established",
524+
"You have successfully auto-connected to Apache SkyWalking. ${message("plugin_name")} is now fully activated.",
525+
NotificationType.INFORMATION
526+
)
527+
)
491528
}
492529
}
493530

plugin/src/main/kotlin/spp/jetbrains/sourcemarker/command/ControlBarController.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import spp.jetbrains.marker.source.SourceFileMarker
2929
import spp.jetbrains.marker.source.mark.api.MethodSourceMark
3030
import spp.jetbrains.marker.source.mark.api.SourceMark
3131
import spp.jetbrains.marker.source.mark.api.component.swing.SwingSourceMarkComponentProvider
32-
import spp.jetbrains.marker.source.mark.api.event.SourceMarkEvent
3332
import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode.*
3433
import spp.jetbrains.marker.source.mark.inlay.ExpressionInlayMark
3534
import spp.jetbrains.marker.source.mark.inlay.InlayMark
@@ -236,8 +235,8 @@ object ControlBarController {
236235
private fun handleViewPortalCommand(editor: Editor, command: LiveControlCommand) {
237236
val sourceMark = SourceMarkSearch.getClosestSourceMark(previousControlBar!!.sourceFileMarker, editor)
238237
if (sourceMark != null) {
239-
sourceMark.triggerEvent(SourceMarkEvent(sourceMark, UPDATE_PORTAL_CONFIG, command)) {
240-
sourceMark.triggerEvent(SourceMarkEvent(sourceMark, PORTAL_OPENING))
238+
sourceMark.triggerEvent(UPDATE_PORTAL_CONFIG, listOf(command)) {
239+
sourceMark.triggerEvent(PORTAL_OPENING, listOf(PORTAL_OPENING))
241240
}
242241
} else {
243242
log.warn("No source mark found for command: {}", command)

plugin/src/main/kotlin/spp/jetbrains/sourcemarker/portal/PortalController.kt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package spp.jetbrains.sourcemarker.portal
2020
import com.fasterxml.jackson.databind.module.SimpleModule
2121
import com.intellij.ide.ui.laf.IntelliJLaf
2222
import com.intellij.openapi.application.ApplicationManager
23+
import io.vertx.core.json.JsonObject
2324
import io.vertx.core.json.jackson.DatabindCodec
2425
import io.vertx.kotlin.coroutines.CoroutineVerticle
2526
import io.vertx.kotlin.coroutines.await
@@ -31,6 +32,7 @@ import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode
3132
import spp.jetbrains.marker.source.mark.guide.GuideMark
3233
import spp.jetbrains.portal.SourcePortal
3334
import spp.jetbrains.portal.backend.PortalServer
35+
import spp.jetbrains.portal.protocol.ProtocolAddress.Global.RenderPage
3436
import spp.jetbrains.portal.protocol.portal.PageType
3537
import spp.jetbrains.sourcemarker.command.LiveControlCommand
3638
import spp.jetbrains.sourcemarker.command.LiveControlCommand.*
@@ -71,27 +73,36 @@ class PortalController(private val markerConfig: SourceMarkerConfig) : Coroutine
7173
val genUrl = "http://localhost:${portalServer.serverPort}?portalUuid=${portal.portalUuid}"
7274
it.sourceMark.addEventListener {
7375
if (it.eventCode == SourceMarkEventCode.UPDATE_PORTAL_CONFIG) {
74-
when (val command = it.params.first() as LiveControlCommand) {
75-
VIEW_OVERVIEW -> portal.configuration.config["currentPage"] = PageType.OVERVIEW
76-
VIEW_ACTIVITY -> portal.configuration.config["currentPage"] = PageType.ACTIVITY
77-
VIEW_TRACES -> portal.configuration.config["currentPage"] = PageType.TRACES
78-
VIEW_LOGS -> portal.configuration.config["currentPage"] = PageType.LOGS
76+
val newPage = when (val command = it.params.first() as LiveControlCommand) {
77+
VIEW_OVERVIEW -> PageType.OVERVIEW
78+
VIEW_ACTIVITY -> PageType.ACTIVITY
79+
VIEW_TRACES -> PageType.TRACES
80+
VIEW_LOGS -> PageType.LOGS
7981
else -> throw UnsupportedOperationException("Command input: $command")
8082
}
8183

82-
val jcefComponent = it.sourceMark.sourceMarkComponent as SourceMarkJcefComponent
83-
jcefComponent.configuration.currentUrl = "#"
84+
if (newPage != portal.configuration.config["currentPage"]) {
85+
log.info("Setting portal page to $newPage")
86+
portal.configuration.config["currentPage"] = newPage
87+
}
8488
} else if (it.eventCode == SourceMarkEventCode.PORTAL_OPENING) {
89+
SourcePortal.getPortals().filter { it.portalUuid != portal.portalUuid }.forEach {
90+
it.configuration.config["active"] = false
91+
}
92+
portal.configuration.config["active"] = true
93+
8594
val jcefComponent = it.sourceMark.sourceMarkComponent as SourceMarkJcefComponent
8695
portal.configuration.darkMode = UIManager.getLookAndFeel() !is IntelliJLaf
8796

88-
if (jcefComponent.configuration.currentUrl != genUrl) {
97+
if (jcefComponent.configuration.currentUrl == "about:blank") {
8998
jcefComponent.configuration.initialUrl = genUrl
9099
jcefComponent.configuration.currentUrl = genUrl
91100
jcefComponent.getBrowser().cefBrowser.executeJavaScript(
92101
"window.location.href = '$genUrl';", genUrl, 0
93102
)
94103
}
104+
portal.configuration.config["portal_uuid"] = portal.portalUuid
105+
vertx.eventBus().publish(RenderPage, JsonObject.mapFrom(portal.configuration))
95106
ApplicationManager.getApplication().invokeLater(it.sourceMark::displayPopup)
96107
}
97108
}

0 commit comments

Comments
 (0)