Skip to content

Commit dd993cf

Browse files
authored
Feature/link to Jaeger (compare traces) (#107)
1 parent 3b0054c commit dd993cf

File tree

9 files changed

+168
-31
lines changed

9 files changed

+168
-31
lines changed

ide-common/src/main/java/org/digma/intellij/plugin/settings/ProjectSettings.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public JComponent getPreferredFocusedComponent() {
4141
@Override
4242
public boolean isModified() {
4343
SettingsState settings = SettingsState.getInstance(project);
44-
return isUrlChanged(settings) || isApiTokenChanged(settings) || isRefreshDelayChanged(settings);
44+
return isUrlChanged(settings) || isApiTokenChanged(settings) || isRefreshDelayChanged(settings) || isJaegerUrlChanged(settings);
4545
}
4646

4747
private boolean isRefreshDelayChanged(SettingsState settings) {
@@ -56,6 +56,10 @@ private boolean isApiTokenChanged(SettingsState settings){
5656
return !Objects.equals(settings.apiToken,mySettingsComponent.getApiToken());
5757
}
5858

59+
private boolean isJaegerUrlChanged(SettingsState settings) {
60+
return !Objects.equals(settings.jaegerUrl, mySettingsComponent.getJaegerUrl());
61+
}
62+
5963
@Override
6064
public void apply() throws ConfigurationException {
6165
SettingsState settings = SettingsState.getInstance(project);
@@ -79,6 +83,7 @@ public void apply() throws ConfigurationException {
7983
settings.apiUrl = mySettingsComponent.getApiUrlText();
8084
settings.apiToken = theApiToken;
8185
settings.refreshDelay = Integer.parseInt(mySettingsComponent.getRefreshDelayText());
86+
settings.jaegerUrl = mySettingsComponent.getJaegerUrl();
8287
settings.fireChanged();
8388
}
8489

@@ -88,6 +93,7 @@ public void reset() {
8893
mySettingsComponent.setApiUrlText(settings.apiUrl);
8994
mySettingsComponent.setApiToken(settings.apiToken);
9095
mySettingsComponent.setRefreshDelayText(String.valueOf(settings.refreshDelay));
96+
mySettingsComponent.setJaegerUrl(settings.jaegerUrl);
9197
}
9298

9399
@Override

ide-common/src/main/java/org/digma/intellij/plugin/settings/SettingsComponent.java

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2-
31
package org.digma.intellij.plugin.settings;
42

53
import com.intellij.openapi.project.Project;
@@ -19,10 +17,11 @@
1917
*/
2018
public class SettingsComponent {
2119

22-
private JPanel myMainPanel;
20+
private final JPanel myMainPanel;
2321
private final JBTextField myApiUrlText = new JBTextField();
2422
private final JBTextField myApiToken = new JBTextField();
2523
private final JBTextField myRefreshDelay = new JBTextField();
24+
private final JBTextField myJaegerUrlText = new JBTextField();
2625

2726
public SettingsComponent(Project project) {
2827

@@ -32,7 +31,7 @@ public SettingsComponent(Project project) {
3231
@Override
3332
public boolean verify(JComponent input) {
3433
try {
35-
new URL(myApiUrlText.getText());
34+
new URL(myApiUrlText.getText().trim());
3635
myUrlLabel.setForeground(myUrlLabelForeground);
3736
return true;
3837
} catch (MalformedURLException e) {
@@ -48,7 +47,7 @@ public boolean verify(JComponent input) {
4847
@Override
4948
public boolean verify(JComponent input) {
5049
try {
51-
Integer.parseInt(myRefreshDelay.getText());
50+
Integer.parseInt(myRefreshDelay.getText().trim());
5251
myRefreshLabel.setForeground(myRefreshLabelForeground);
5352
return true;
5453
} catch (NumberFormatException e) {
@@ -58,6 +57,25 @@ public boolean verify(JComponent input) {
5857
}
5958
});
6059

60+
var myJaegerUrlLabel = new JBLabel("Jaeger URL: ");
61+
var myJaegerUrlForeground = myUrlLabel.getForeground();
62+
myJaegerUrlText.setInputVerifier(new InputVerifier() {
63+
@Override
64+
public boolean verify(JComponent input) {
65+
if (myJaegerUrlText.getText().isBlank()) {
66+
myJaegerUrlLabel.setForeground(myJaegerUrlForeground);
67+
return true;
68+
}
69+
try {
70+
new URL(myJaegerUrlText.getText().trim());
71+
myJaegerUrlLabel.setForeground(myJaegerUrlForeground);
72+
return true;
73+
} catch (MalformedURLException e) {
74+
myJaegerUrlLabel.setForeground(JBColor.RED);
75+
return false;
76+
}
77+
}
78+
});
6179

6280

6381
var resetButton = new JButton("Reset to defaults");
@@ -67,6 +85,7 @@ public boolean verify(JComponent input) {
6785
.addLabeledComponent(myUrlLabel, myApiUrlText, 1, false)
6886
.addLabeledComponent(new JBLabel("Api token:"), myApiToken, 1, false)
6987
.addLabeledComponent(myRefreshLabel, myRefreshDelay, 1, false)
88+
.addLabeledComponent(myJaegerUrlLabel, myJaegerUrlText, 1, false)
7089
.addComponent(resetButton)
7190
.addComponentFillVertically(new JPanel(), 0)
7291
.getPanel();
@@ -82,34 +101,47 @@ public JComponent getPreferredFocusedComponent() {
82101

83102
@NotNull
84103
public String getApiUrlText() {
85-
return myApiUrlText.getText();
104+
return myApiUrlText.getText().trim();
86105
}
87106

88107
public void setApiUrlText(@NotNull String newText) {
89-
myApiUrlText.setText(newText);
108+
myApiUrlText.setText(newText.trim());
90109
}
91110

92111
@Nullable
93112
public String getApiToken() {
94-
return myApiToken.getText();
113+
return myApiToken.getText().trim();
95114
}
96115

97116
public void setApiToken(@Nullable String newText) {
98-
myApiToken.setText(newText);
117+
if (newText == null) {
118+
myApiToken.setText("");
119+
} else {
120+
myApiToken.setText(newText.trim());
121+
}
122+
}
123+
124+
public String getJaegerUrl() {
125+
return myJaegerUrlText.getText().trim();
126+
}
127+
128+
public void setJaegerUrl(String newText) {
129+
myJaegerUrlText.setText(newText.trim());
99130
}
100131

101132
@NotNull
102133
public String getRefreshDelayText() {
103-
return myRefreshDelay.getText();
134+
return myRefreshDelay.getText().trim();
104135
}
105136

106137
public void setRefreshDelayText(@NotNull String newText) {
107-
myRefreshDelay.setText(newText);
138+
myRefreshDelay.setText(newText.trim());
108139
}
109140

110141
private void resetToDefaults(){
111142
this.setApiUrlText(SettingsState.DEFAULT_API_URL);
112143
this.setApiToken(null);
113144
this.setRefreshDelayText(String.valueOf(SettingsState.DEFAULT_REFRESH_DELAY));
145+
this.setJaegerUrl(SettingsState.DEFAULT_JAEGER_URL);
114146
}
115147
}

ide-common/src/main/java/org/digma/intellij/plugin/settings/SettingsState.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2-
31
package org.digma.intellij.plugin.settings;
42

53
import com.intellij.openapi.Disposable;
@@ -27,11 +25,13 @@ public class SettingsState implements PersistentStateComponent<SettingsState> ,
2725

2826
public static final String DEFAULT_API_URL = "https://localhost:5051";
2927
public static final int DEFAULT_REFRESH_DELAY = 30;
28+
public static final String DEFAULT_JAEGER_URL = "http://localhost:16686";
3029
public String apiUrl = DEFAULT_API_URL;
31-
3230
public int refreshDelay = DEFAULT_REFRESH_DELAY;
3331
@Nullable
3432
public String apiToken = null;
33+
@Nullable
34+
public String jaegerUrl = DEFAULT_API_URL;
3535
private final List<SettingsChangeListener> listeners = new ArrayList<>();
3636

3737
public static SettingsState getInstance(Project project) {

model/src/main/kotlin/org/digma/intellij/plugin/model/rest/insights/SpanDurationsPercentile.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import java.sql.Timestamp
88
@JsonIgnoreProperties(ignoreUnknown = true)
99
data class SpanDurationsPercentile
1010
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
11-
@ConstructorProperties("percentile", "currentDuration","previousDuration","changeTime","changeVerified")
12-
constructor(val percentile: Float,
13-
val currentDuration: Duration,
14-
val previousDuration: Duration?,
15-
val changeTime: Timestamp?,
16-
val changeVerified: Boolean?)
11+
@ConstructorProperties("percentile", "currentDuration", "previousDuration", "changeTime", "changeVerified", "traceIds")
12+
constructor(
13+
val percentile: Float,
14+
val currentDuration: Duration,
15+
val previousDuration: Duration?,
16+
val changeTime: Timestamp?,
17+
val changeVerified: Boolean?,
18+
val traceIds: List<String>,
19+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.digma.intellij.plugin.ui.model
2+
3+
data class TraceSample(val traceName: String, val traceId: String?) {
4+
5+
fun hasTraceId(): Boolean {
6+
return !traceId.isNullOrBlank()
7+
}
8+
}

src/main/kotlin/org/digma/intellij/plugin/ui/common/Laf.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ object Laf {
9191
@JvmStatic val SLOW = loadAndScaleInsightIcon("/icons/slow.png")
9292
@JvmStatic val WAITING_DATA = loadAndScaleInsightIcon("/icons/waiting-data.png")
9393
@JvmStatic val HOTSPOT = loadAndScaleInsightIcon("/icons/target.png")
94+
@JvmStatic val HISTOGRAM = loadAndScaleInsightIcon("/icons/histogram.png")
9495
@JvmStatic val SPAN_DURATION_DROPPED = loadAndScaleIconByWidth("/icons/dropped.png", 8)
9596
@JvmStatic val SPAN_DURATION_ROSE = loadAndScaleIconByWidth("/icons/rose.png", 8)
9697
}

src/main/kotlin/org/digma/intellij/plugin/ui/list/insights/InsightsListCellRenderer.kt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,23 @@ import com.intellij.openapi.project.Project
44
import com.intellij.ui.dsl.builder.RightGap
55
import com.intellij.ui.dsl.builder.panel
66
import com.intellij.ui.dsl.gridLayout.HorizontalAlign
7-
import org.digma.intellij.plugin.model.rest.insights.*
8-
import org.digma.intellij.plugin.ui.common.*
7+
import org.digma.intellij.plugin.model.rest.insights.EndpointSchema
8+
import org.digma.intellij.plugin.model.rest.insights.ErrorInsight
9+
import org.digma.intellij.plugin.model.rest.insights.HighUsageInsight
10+
import org.digma.intellij.plugin.model.rest.insights.HotspotInsight
11+
import org.digma.intellij.plugin.model.rest.insights.LowUsageInsight
12+
import org.digma.intellij.plugin.model.rest.insights.NormalUsageInsight
13+
import org.digma.intellij.plugin.model.rest.insights.SlowEndpointInsight
14+
import org.digma.intellij.plugin.model.rest.insights.SlowestSpansInsight
15+
import org.digma.intellij.plugin.model.rest.insights.SpanDurationsInsight
16+
import org.digma.intellij.plugin.model.rest.insights.SpanInsight
17+
import org.digma.intellij.plugin.model.rest.insights.UnmappedInsight
18+
import org.digma.intellij.plugin.ui.common.CopyableLabelHtml
19+
import org.digma.intellij.plugin.ui.common.Laf
20+
import org.digma.intellij.plugin.ui.common.asHtml
21+
import org.digma.intellij.plugin.ui.common.span
22+
import org.digma.intellij.plugin.ui.common.spanBold
23+
import org.digma.intellij.plugin.ui.common.spanGrayed
924
import org.digma.intellij.plugin.ui.list.AbstractPanelListCellRenderer
1025
import org.digma.intellij.plugin.ui.list.PanelsLayoutHelper
1126
import org.digma.intellij.plugin.ui.model.insights.InsightGroupType.HttpEndpoint
@@ -44,7 +59,7 @@ class InsightsListCellRenderer : AbstractPanelListCellRenderer() {
4459
is SlowestSpansInsight -> slowestSpansPanel(project,
4560
value.modelObject as SlowestSpansInsight, value.moreData, panelsLayoutHelper)
4661
is SpanInsight -> spanPanel(value.modelObject as SpanInsight)
47-
is SpanDurationsInsight -> spanDurationPanel(value.modelObject as SpanDurationsInsight,
62+
is SpanDurationsInsight -> spanDurationPanel(project, value.modelObject as SpanDurationsInsight,
4863
panelsLayoutHelper)
4964
is UnmappedInsight -> unmappedInsightPanel(value.modelObject as UnmappedInsight,
5065
panelsLayoutHelper)

0 commit comments

Comments
 (0)