Skip to content

Commit e5bced6

Browse files
authored
Merge pull request #2157 from digma-ai/feature/span-info
Added span info endpoint
2 parents a628b86 + 4a8e7eb commit e5bced6

File tree

7 files changed

+207
-63
lines changed

7 files changed

+207
-63
lines changed

analytics-provider/src/main/java/org/digma/intellij/plugin/analytics/AnalyticsProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,7 @@ public interface AnalyticsProvider extends Closeable {
133133

134134
String getHighlightsScaling(HighlightsRequest request);
135135

136+
String getSpanInfo(String spanCodeObjectId);
137+
136138
String getHighlightsImpact(HighlightsRequest request);
137139
}

analytics-provider/src/main/java/org/digma/intellij/plugin/analytics/RestAnalyticsProvider.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,11 @@ public String getHighlightsScaling(HighlightsRequest request) {
340340
return execute(() -> client.analyticsProvider.getHighlightsScaling(request));
341341
}
342342

343+
@Override
344+
public String getSpanInfo(String spanCodeObjectId) {
345+
return execute(() -> client.analyticsProvider.getSpanInfo(spanCodeObjectId));
346+
}
347+
343348
@Override
344349
public HttpResponse lowLevelCall(HttpRequest request) {
345350

@@ -965,5 +970,12 @@ Call<ResponseBody> setInsightCustomStartTime(
965970
})
966971
@POST("/highlights/scaling")
967972
Call<String> getHighlightsScaling(@Body HighlightsRequest request);
973+
974+
@Headers({
975+
"Accept: application/+json",
976+
"Content-Type:application/json"
977+
})
978+
@GET("/spans/info")
979+
Call<String> getSpanInfo(@Query("SpanCodeObjectId") String spanCodeObjectId);
968980
}
969981
}

ide-common/src/main/java/org/digma/intellij/plugin/analytics/AnalyticsService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ public String getHighlightsScaling(HighlightsRequest request) throws AnalyticsSe
405405
return executeCatching(() -> analyticsProviderProxy.getHighlightsScaling(request));
406406
}
407407

408+
public String getSpanInfo(String spanCodeObjectId) throws AnalyticsServiceException {
409+
return executeCatching(() -> analyticsProviderProxy.getSpanInfo(spanCodeObjectId));
410+
}
408411

409412
public String getHighlightsImpact(HighlightsRequest request) throws AnalyticsServiceException {
410413
return executeCatching(() -> analyticsProviderProxy.getHighlightsImpact(request));

src/main/kotlin/org/digma/intellij/plugin/ui/highlights/HighlightsMessageRouterHandler.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class HighlightsMessageRouterHandler(project: Project) : BaseCommonMessageRouter
2525
"MAIN/GET_HIGHLIGHTS_TOP_ISSUES_DATA" -> getHighlightsTopInsightsV2(browser, requestJsonNode)
2626
"MAIN/GET_HIGHLIGHTS_IMPACT_DATA" -> getHighlightsImpact(browser, requestJsonNode)
2727
"MAIN/GET_HIGHLIGHTS_SCALING_DATA" -> getHighlightsScaling(browser, requestJsonNode)
28+
"MAIN/GET_SPAN_INFO_DATA" -> getSpanInfo(browser, requestJsonNode)
2829

2930
else -> {
3031
return false
@@ -138,6 +139,24 @@ class HighlightsMessageRouterHandler(project: Project) : BaseCommonMessageRouter
138139
}
139140
}
140141

142+
@Synchronized
143+
@Throws(JsonProcessingException::class)
144+
private fun getSpanInfo(browser: CefBrowser, requestJsonNode: JsonNode) {
145+
146+
Log.log(logger::trace, project, "getSpanInfo called")
147+
148+
val payloadQuery = getPayloadQuery(requestJsonNode)
149+
if (payloadQuery is ObjectNode) {
150+
151+
val request = payloadQuery.get("spanCodeObjectId").asText()
152+
val payload = HighlightsService.getInstance(project).getSpanInfo(request)
153+
154+
val message = SetSpanInfoMessage(payload)
155+
Log.log(logger::trace, project, "sending MAIN/SET_SPAN_INFO_DATA message")
156+
serializeAndExecuteWindowPostMessageJavaScript(browser, message)
157+
}
158+
}
159+
141160

142161
private fun getHighlightsTopInsightsV2(browser: CefBrowser, requestJsonNode: JsonNode) {
143162
Log.log(logger::trace, project, "getHighlightsTopInsights called")

src/main/kotlin/org/digma/intellij/plugin/ui/highlights/HighlightsService.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,16 @@ class HighlightsService(val project: Project) : InsightsServiceImpl(project) {
9595
null
9696
}
9797
}
98+
99+
fun getSpanInfo(spanCodeObjectId: String): String? {
100+
EDT.assertNonDispatchThread()
101+
102+
return try {
103+
val spanInfo = AnalyticsService.getInstance(project).getSpanInfo(spanCodeObjectId)
104+
spanInfo
105+
} catch (e: AnalyticsServiceException) {
106+
Log.warnWithException(logger, project, e, "Error loading highlights top insights {}", e.message)
107+
null
108+
}
109+
}
98110
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.digma.intellij.plugin.ui.highlights.model
2+
3+
import com.fasterxml.jackson.annotation.JsonRawValue
4+
import org.digma.intellij.plugin.ui.jcef.JCEFGlobalConstants
5+
6+
data class SetSpanInfoMessage(@JsonRawValue val payload: String?) {
7+
val type = JCEFGlobalConstants.REQUEST_MESSAGE_TYPE
8+
val action = "MAIN/SET_SPAN_INFO_DATA"
9+
}

src/main/resources/webview/main/index.js

Lines changed: 150 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)