Skip to content

Commit a40253c

Browse files
authored
Merge pull request #402 from digma-ai/feat/add_links_on_insights
Add links to TopUsage/Bottleneck/ScalingRootCause insights
2 parents 19cad40 + 9cf8403 commit a40253c

File tree

16 files changed

+287
-29
lines changed

16 files changed

+287
-29
lines changed

ide-common/src/main/java/org/digma/intellij/plugin/insights/view/BuildersHolder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.digma.intellij.plugin.model.rest.insights.SpanSlowEndpointsInsight;
1818
import org.digma.intellij.plugin.model.rest.insights.SpanUsagesInsight;
1919
import org.digma.intellij.plugin.model.rest.insights.UnmappedInsight;
20+
import org.digma.intellij.plugin.model.rest.insights.SpanScalingRootCauseInsight;
2021
import org.digma.intellij.plugin.ui.model.insights.InsightGroupType;
2122
import org.digma.intellij.plugin.view.EmptyListViewItemBuilder;
2223
import org.digma.intellij.plugin.view.ListViewItemBuilder;
@@ -56,6 +57,8 @@ private ListViewItemBuilder<? extends CodeObjectInsight> newBuilder(InsightType
5657
return new GroupListViewItemBuilder<SpanDurationsInsight>(InsightGroupType.Span, null, spanDurationsInsight -> spanDurationsInsight.spanName());
5758
case SpanScaling:
5859
return new GroupListViewItemBuilder<SpanScalingInsight>(InsightGroupType.Span, null, SpanScalingInsight::spanName);
60+
case SpanScalingRootCause:
61+
return new GroupListViewItemBuilder<SpanScalingRootCauseInsight>(InsightGroupType.Span, null, SpanScalingRootCauseInsight::spanName);
5962
case SpanDurationBreakdown:
6063
return new GroupListViewItemBuilder<SpanDurationBreakdownInsight>(InsightGroupType.Span, null, SpanDurationBreakdownInsight::spanName);
6164
case SpanEndpointBottleneck:

ide-common/src/main/java/org/digma/intellij/plugin/insights/view/GroupListViewItemBuilder.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.digma.intellij.plugin.view.ListViewItemBuilder;
1313
import org.jetbrains.annotations.NotNull;
1414

15+
import java.util.ArrayList;
1516
import java.util.List;
1617
import java.util.function.Function;
1718
import java.util.stream.Collectors;
@@ -54,23 +55,60 @@ public List<ListViewItem<?>> build(Project project, @NotNull MethodInfo methodIn
5455
WorkspaceUrisHelper.findWorkspaceUrisForSpans(project,theListView, getSpanIds((SpanScalingInsight) insight), methodInfo);
5556
break;
5657
}
58+
case SpanEndpointBottleneck: {
59+
WorkspaceUrisHelper.findWorkspaceUrisForMethodCodeObjectIds(project, theListView, getCodeObjectIds((SpanSlowEndpointsInsight) insight), methodInfo);
60+
break;
61+
}
62+
case SpanUsages: {
63+
WorkspaceUrisHelper.findWorkspaceUrisForMethodCodeObjectIds(project, theListView, getCodeObjectIds((SpanUsagesInsight) insight), methodInfo);
64+
break;
65+
}
66+
case SpanScalingRootCause: {
67+
WorkspaceUrisHelper.findWorkspaceUrisForMethodCodeObjectIds(project, theListView, getCodeObjectIds((SpanScalingRootCauseInsight) insight), methodInfo);
68+
break;
69+
}
5770
}
5871

5972
theGroup.addItem(theListView);
6073

6174
return List.of();
6275
}
6376

77+
private List<String> getCodeObjectIds(SpanUsagesInsight insight) {
78+
var codeObjectIds = new ArrayList<String>();
79+
for (SpanFlow ins: insight.getFlows()) {
80+
var firstServiceId = ins.getFirstService();
81+
if (firstServiceId != null)
82+
codeObjectIds.add(firstServiceId.getCodeObjectId());
83+
var lastServiceId = ins.getLastService();
84+
if (lastServiceId != null)
85+
codeObjectIds.add(lastServiceId.getCodeObjectId());
86+
}
87+
return codeObjectIds;
88+
}
89+
90+
private List<String> getCodeObjectIds(SpanScalingRootCauseInsight insight) {
91+
return insight.getAffectedEndpoints().stream().filter(it -> it.getCodeObjectId() != null)
92+
.map(it -> it.getCodeObjectId())
93+
.toList();
94+
}
95+
96+
private List<String> getCodeObjectIds(SpanSlowEndpointsInsight insight) {
97+
return insight.getSlowEndpoints().stream().filter(it -> it.getEndpointInfo().getCodeObjectId() != null)
98+
.map(it -> it.getEndpointInfo().getCodeObjectId())
99+
.toList();
100+
}
101+
64102
private List<String> getSpanIds(SpanScalingInsight insight) {
65103
return insight.getRootCauseSpans().stream()
66104
.map(it -> CodeObjectsUtil.createSpanId(it.getInstrumentationLibrary(), it.getName()))
67-
.collect(Collectors.toList());
105+
.toList();
68106
}
69107

70108
private List<String> getSpanIds(SlowestSpansInsight insight) {
71109
return insight.getSpans().stream()
72110
.map(it -> CodeObjectsUtil.createSpanId(it.getSpanInfo().getInstrumentationLibrary(), it.getSpanInfo().getName()))
73-
.collect(Collectors.toList());
111+
.toList();
74112
}
75113

76114
private List<String> getSpanIds(SpanDurationBreakdownInsight insight) {

ide-common/src/main/java/org/digma/intellij/plugin/insights/view/WorkspaceUrisHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,18 @@ public static void findWorkspaceUrisForSpans(@NotNull Project project, ListViewI
2323
findWorkspaceUrisForSpans(theListView, spanIds, languageService);
2424
}
2525

26+
public static void findWorkspaceUrisForMethodCodeObjectIds(@NotNull Project project, ListViewItem<?> theListView, @NotNull List<String> codeObjectIds, @NotNull MethodInfo methodInfo) {
27+
var languageService = LanguageService.findLanguageServiceByMethodInfo(project, methodInfo);
28+
findWorkspaceUrisMethodCodeObjectIds(theListView, codeObjectIds, languageService);
29+
}
2630

2731
private static void findWorkspaceUrisForSpans(ListViewItem<?> theListView, @NotNull List<String> spanIds, @NotNull LanguageService languageService) {
2832
var workspaceUris = languageService.findWorkspaceUrisForSpanIds(spanIds);
2933
workspaceUris.forEach((k, v) -> theListView.getMoreData().put(k, v));
3034
}
35+
36+
private static void findWorkspaceUrisMethodCodeObjectIds(ListViewItem<?> theListView, @NotNull List<String> codeObjectIds, @NotNull LanguageService languageService) {
37+
var workspaceUris = languageService.findWorkspaceUrisForMethodCodeObjectIds(codeObjectIds);
38+
workspaceUris.forEach((k, v) -> theListView.getMoreData().put(k, v));
39+
}
3140
}

model/src/main/kotlin/org/digma/intellij/plugin/model/model.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ enum class InsightType {
3535
SpanEndpointBottleneck,
3636
SpanDurationBreakdown,
3737
SpanScaling,
38+
SpanScalingRootCause,
3839
;
3940
}
4041

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import java.util.*
2727
JsonSubTypes.Type(value = SpanNPlusOneInsight::class, name = "SpaNPlusOne"),
2828
JsonSubTypes.Type(value = SlowEndpointInsight::class, name = "SlowEndpoint"),
2929
JsonSubTypes.Type(value = SpanScalingInsight::class, name = "SpanScaling"),
30+
JsonSubTypes.Type(value = SpanScalingRootCauseInsight::class, name = "SpanScalingRootCause"),
3031
JsonSubTypes.Type(value = SpanDurationsInsight::class, name = "SpanDurations"),
3132
JsonSubTypes.Type(value = SpanSlowEndpointsInsight::class, name = "SpanEndpointBottleneck"),
3233
JsonSubTypes.Type(value = SpanDurationBreakdownInsight::class, name = "SpanDurationBreakdown"),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import java.beans.ConstructorProperties
77
@JsonIgnoreProperties(ignoreUnknown = true)
88
data class EndpointInfo
99
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
10-
@ConstructorProperties("route", "serviceName", "instrumentationLibrary")
10+
@ConstructorProperties("route", "serviceName", "instrumentationLibrary", "codeObjectId")
1111
constructor(
1212
val route: String,
1313
val serviceName: String,
1414
val instrumentationLibrary: String,
15+
val codeObjectId: String?,
1516
)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ constructor(
1919

2020
data class Service
2121
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
22-
@ConstructorProperties("service", "span")
22+
@ConstructorProperties("service", "span", "codeObjectId")
2323
constructor(
2424
val service: String,
2525
val span: String,
26+
val codeObjectId: String,
2627
)
2728

2829
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ constructor(
2222
val spanCodeObjectId: String?, //TODO: should be not null, somehow the backend returns nulls on endpoints
2323
val displayName: String,
2424
val methodCodeObjectId: String?,
25-
val kind: String,
25+
val kind: String?,
2626
)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.digma.intellij.plugin.model.rest.insights
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator
4+
import org.digma.intellij.plugin.model.InsightType
5+
import java.beans.ConstructorProperties
6+
import java.util.Date
7+
import kotlin.collections.ArrayList
8+
9+
10+
data class SpanScalingRootCauseInsight
11+
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
12+
@ConstructorProperties(
13+
"codeObjectId",
14+
"environment",
15+
"scope",
16+
"importance",
17+
"decorators",
18+
"actualStartTime",
19+
"customStartTime",
20+
"prefixedCodeObjectId",
21+
"shortDisplayInfo",
22+
"spanInfo",
23+
"affectedEndpoints",
24+
)
25+
constructor(
26+
override val codeObjectId: String,
27+
override val environment: String,
28+
override val scope: String,
29+
override val importance: Int,
30+
override val decorators: List<CodeObjectDecorator>?,
31+
override val actualStartTime: Date?,
32+
override val customStartTime: Date?,
33+
override val prefixedCodeObjectId: String?,
34+
override val shortDisplayInfo: ShortDisplayInfo?,
35+
override val spanInfo: SpanInfo,
36+
val affectedEndpoints: List<EndpointInfo> = ArrayList()
37+
) : SpanInsight {
38+
39+
override val type: InsightType = InsightType.SpanScalingRootCause
40+
}

model/src/main/kotlin/org/digma/intellij/plugin/ui/model/insights/InsightListViewItem.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ open class InsightListViewItem<INSIGHT : CodeObjectInsight>(insight: INSIGHT) :
1717
// Span
1818
InsightType.SpanDurations -> 60
1919
InsightType.SpanUsages -> 61
20+
InsightType.SpanScalingRootCause -> 62
2021
InsightType.SpanScaling -> 63
2122
InsightType.SpaNPlusOne -> 65
2223
InsightType.SpanDurationChange -> 66

0 commit comments

Comments
 (0)