Skip to content

Commit 151ad70

Browse files
authored
remove some info from settings events
2 parents 16e4d0e + 15e388c commit 151ad70

File tree

3 files changed

+68
-41
lines changed

3 files changed

+68
-41
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,20 @@ public void apply() throws ConfigurationException {
9090
SettingsState settings = SettingsState.getInstance();
9191
try {
9292
Objects.requireNonNull(mySettingsComponent.getApiUrlText(), "api url can not be null");
93+
Objects.requireNonNull(mySettingsComponent.getRuntimeObservabilityBackendUrl(), "Runtime observability url can not be null");
9394
} catch (Exception e) {
9495
throw new ConfigurationException(e.getMessage(), e, e.getClass().getSimpleName());
9596
}
9697

98+
if (mySettingsComponent.getApiUrlText().isBlank()) {
99+
throw new ConfigurationException("Api url can not be empty");
100+
}
101+
102+
if (mySettingsComponent.getRuntimeObservabilityBackendUrl().isBlank()) {
103+
throw new ConfigurationException("Runtime observability url can not be empty");
104+
}
105+
106+
97107
if (!CommonUtils.isWelFormedUrl(mySettingsComponent.getApiUrlText())) {
98108
throw new ConfigurationException("Api url is not a well formed url");
99109
}
@@ -102,12 +112,17 @@ public void apply() throws ConfigurationException {
102112
throw new ConfigurationException("Api url schema must be https");
103113
}
104114

115+
if (!CommonUtils.isWelFormedUrl(mySettingsComponent.getRuntimeObservabilityBackendUrl())) {
116+
throw new ConfigurationException("Runtime observability is not a well formed url");
117+
}
118+
105119
if (mySettingsComponent.getJaegerUrl() != null &&
106120
!mySettingsComponent.getJaegerUrl().isBlank() &&
107121
!CommonUtils.isWelFormedUrl(mySettingsComponent.getJaegerUrl())) {
108122
throw new ConfigurationException("Jaeger url is not a well formed url");
109123
}
110124

125+
111126
if (mySettingsComponent.getJaegerLinkMode() == LinkMode.Embedded) {
112127
if (!CommonUtils.isWelFormedUrl(mySettingsComponent.getJaegerQueryUrl())) {
113128
throw new ConfigurationException("Jaeger query url must be well formed in Embedded mode");

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

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class SettingsComponent {
2727
private final ComboBox<LinkMode> myJaegerLinkModeComboBox = new ComboBox<>(new EnumComboBoxModel<>(LinkMode.class));
2828
private final JBLabel myEmbeddedJaegerMessage = new JBLabel("<html><body><span style=\"color:\"" + JBColor.BLUE + "\"\"><b>Jaeger embedded is only supported for deployment on a local environment.</b></span></body>");
2929
private final ComboBox<SpringBootObservabilityMode> mySpringBootObservabilityModeComboBox = new ComboBox<>(new EnumComboBoxModel<>(SpringBootObservabilityMode.class));
30+
private final JBLabel myRuntimeObservabilityBackendUrlLabel = new JBLabel("Runtime observability backend URL:");
3031
private final JBTextField myRuntimeObservabilityBackendUrlText = new JBTextField();
3132
private final JBTextField extendedObservabilityTextBox = new JBTextField();
3233

@@ -107,6 +108,23 @@ public boolean verify(JComponent input) {
107108
});
108109

109110

111+
myRuntimeObservabilityBackendUrlLabel.setToolTipText("Where should observability data be sent from the IDE? This would be the Digma collector URL typically listening to port 5050");
112+
113+
myRuntimeObservabilityBackendUrlText.setInputVerifier(new InputVerifier() {
114+
@Override
115+
public boolean verify(JComponent input) {
116+
try {
117+
new URL(myRuntimeObservabilityBackendUrlText.getText().trim());
118+
myRuntimeObservabilityBackendUrlLabel.setForeground(defaultLabelForeground);
119+
return true;
120+
} catch (MalformedURLException e) {
121+
myRuntimeObservabilityBackendUrlLabel.setForeground(JBColor.RED);
122+
return false;
123+
}
124+
}
125+
});
126+
127+
110128
myEmbeddedJaegerMessage.setForeground(JBColor.BLUE);
111129

112130
var myJaegerLinkModeLabel = new JBLabel("Jaeger link mode: ");
@@ -124,23 +142,6 @@ public boolean verify(JComponent input) {
124142
+ "Micrometer will use Micrometer tracing, including the annotation of 'Observed' "
125143
);
126144

127-
var myRuntimeObservabilityBackendUrlLabel = new JBLabel("Runtime observability backend URL:");
128-
myRuntimeObservabilityBackendUrlLabel.setToolTipText("Where should observability data be sent from the IDE? This would be the Digma collector URL typically listening to port 5050");
129-
JBLabel feedbackForRuntimeObservabilityBackendUrl = buildFeedbackNotValidUrl();
130-
myRuntimeObservabilityBackendUrlText.setInputVerifier(new InputVerifier() {
131-
@Override
132-
public boolean verify(JComponent input) {
133-
try {
134-
new URL(myRuntimeObservabilityBackendUrlText.getText().trim());
135-
feedbackForRuntimeObservabilityBackendUrl.setVisible(false);
136-
return true;
137-
} catch (MalformedURLException e) {
138-
feedbackForRuntimeObservabilityBackendUrl.setVisible(true);
139-
return false;
140-
}
141-
}
142-
});
143-
144145
var resetButton = new JButton("Reset to defaults");
145146
resetButton.addActionListener(e -> resetToDefaults());
146147

@@ -154,7 +155,6 @@ public boolean verify(JComponent input) {
154155
.addLabeledComponent(myJaegerQueryUrlLabel, myJaegerQueryUrlText, 1, false)
155156
.addLabeledComponent(mySpringBootObservabilityModeLabel, mySpringBootObservabilityModeComboBox, 1, false)
156157
.addLabeledComponent(myRuntimeObservabilityBackendUrlLabel, myRuntimeObservabilityBackendUrlText, 1, false)
157-
.addComponentToRightColumn(feedbackForRuntimeObservabilityBackendUrl, 1)
158158
.addLabeledComponent("Extended Observability (beta)", extendedObservabilityTextBox, 1, false)
159159
.addComponent(resetButton)
160160
.addComponentFillVertically(new JPanel(), 0)
@@ -185,19 +185,7 @@ private void linkModeSelected(Color defaultLabelForeground, LinkMode selected) {
185185
}
186186
}
187187

188-
@NotNull
189-
private static JBLabel buildFeedbackLabel(String text, String toolTip) {
190-
var feedbackLabel = new JBLabel(text);
191-
feedbackLabel.setToolTipText(toolTip);
192-
feedbackLabel.setForeground(JBColor.RED);
193-
feedbackLabel.setVisible(false);
194-
return feedbackLabel;
195-
}
196188

197-
@NotNull
198-
private static JBLabel buildFeedbackNotValidUrl() {
199-
return buildFeedbackLabel("Not a valid URL", "try to use value like http://somehost:8765");
200-
}
201189

202190
public JPanel getPanel() {
203191
return myMainPanel;

ide-common/src/main/kotlin/org/digma/intellij/plugin/posthog/SettingsChangeTracker.kt

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.digma.intellij.plugin.settings.SettingsState
55

66
class SettingsChangeTracker {
77

8-
private val myTrackedSettings = mutableMapOf<String,String>()
8+
private val myTrackedSettings = mutableMapOf<String, String>()
99

1010
init {
1111
updateTrackedSettings()
@@ -29,32 +29,56 @@ class SettingsChangeTracker {
2929
)
3030
}
3131

32-
private fun getDiff(oldSettings: MutableMap<String, String>, myTrackedSettings: MutableMap<String, String>): Map<String,String> {
32+
private fun getDiff(oldSettings: MutableMap<String, String>, myTrackedSettings: MutableMap<String, String>): Map<String, String> {
3333

34-
val diffMap = mutableMapOf<String,String>()
35-
oldSettings.forEach{
34+
val diffMap = mutableMapOf<String, String>()
35+
oldSettings.forEach {
3636
val key = it.key
3737
val value = it.value
38-
if (value != myTrackedSettings[key]){
38+
if (value != myTrackedSettings[key]) {
3939
diffMap[key] = "[new value ${myTrackedSettings[key]}] [old value $value]"
4040
}
4141
}
4242
return diffMap
4343
}
4444

4545

46-
private fun updateTrackedSettings(){
47-
myTrackedSettings["apiUrl"] = SettingsState.getInstance().apiUrl
48-
myTrackedSettings["jaegerQueryUrl"] = SettingsState.getInstance().jaegerQueryUrl
49-
myTrackedSettings["jaegerUrl"] = SettingsState.getInstance().jaegerUrl.toString()
46+
private fun updateTrackedSettings() {
47+
myTrackedSettings["apiUrl"] = SettingsState.getInstance().apiUrl.let {
48+
if (it.contains("localhost") || it.contains("127.0.0.1"))
49+
"localhost"
50+
else
51+
"non-localhost"
52+
}
53+
54+
55+
myTrackedSettings["jaegerQueryUrl"] = SettingsState.getInstance().jaegerQueryUrl.let {
56+
if (it.contains("localhost") || it.contains("127.0.0.1"))
57+
"localhost"
58+
else
59+
"non-localhost"
60+
}
61+
62+
myTrackedSettings["runtimeObservabilityBackendUrl"] = SettingsState.getInstance().runtimeObservabilityBackendUrl.let {
63+
if (it.contains("localhost") || it.contains("127.0.0.1"))
64+
"localhost"
65+
else
66+
"non-localhost"
67+
}
68+
69+
myTrackedSettings["jaegerUrl"] = SettingsState.getInstance().jaegerUrl?.takeIf { it.isNotBlank() }?.let {
70+
if (it.contains("localhost") || it.contains("127.0.0.1"))
71+
"localhost"
72+
else
73+
"non-localhost"
74+
} ?: ""
75+
5076
myTrackedSettings["jaegerLinkMode"] = SettingsState.getInstance().jaegerLinkMode.name
5177
myTrackedSettings["refreshDelay"] = SettingsState.getInstance().refreshDelay.toString()
5278
myTrackedSettings["springBootObservabilityMode"] = SettingsState.getInstance().springBootObservabilityMode.name
53-
myTrackedSettings["runtimeObservabilityBackendUrl"] = SettingsState.getInstance().runtimeObservabilityBackendUrl
5479
myTrackedSettings["extendedObservability"] = SettingsState.getInstance().extendedObservability.toString()
5580
}
5681

5782

58-
5983
}
6084

0 commit comments

Comments
 (0)