Skip to content

Commit

Permalink
Merge pull request #2536 from digma-ai/report-endpoints
Browse files Browse the repository at this point in the history
Report endpoints
  • Loading branch information
kshmidt-digma authored Sep 25, 2024
2 parents 220c55e + 0709930 commit 241c51c
Show file tree
Hide file tree
Showing 9 changed files with 321 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,18 @@ public interface AnalyticsProvider extends Closeable {

String getServices(String environment);

String getEndpoints(String service, Map<String, Object> queryParams);

String getEndpointIssues(String queryParams);

String getAssetsReportStats(Map<String, Object> queryParams);

String getIssuesReportStats(Map<String, Object> queryParams);

String getServiceReport(String queryParams);

String getEnvironmentsByService(String service);

String getNotifications(NotificationsRequest notificationsRequest);

void setReadNotificationsTime(SetReadNotificationsRequest setReadNotificationsRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,17 @@ public String getServices(String environment) {
return execute(() -> client.analyticsProvider.getServices(environment));
}

@Override
public String getEndpoints(String service, Map<String, Object> queryParams) {
return execute(() -> client.analyticsProvider.getEndpoints(service, queryParams));
}

@Override
public String getEndpointIssues(String queryParams) {
return execute(() -> client.analyticsProvider.getEndpointIssues(queryParams));
}


@Override
public String getIssuesReportStats(Map<String, Object> queryParams) {
return execute(() -> client.analyticsProvider.getIssuesReportStats(queryParams));
Expand All @@ -243,6 +254,11 @@ public String getServiceReport(String queryParams) {
return execute(() -> client.analyticsProvider.getServiceReport(queryParams));
}

@Override
public String getEnvironmentsByService(String service) {
return execute(() -> client.analyticsProvider.getEnvironmentsByService(service));
}

@Override
public String getAssetsReportStats(Map<String, Object> queryParams) {
return execute(() -> client.analyticsProvider.getAssetsReportStats(queryParams));
Expand Down Expand Up @@ -887,6 +903,13 @@ Call<Void> setInsightCustomStartTime(
@POST("reports/services/issues")
Call<String> getServiceReport(@Body String filters);

@Headers({
"Accept: application/+json",
"Content-Type:application/json"
})
@GET("services/{service}/environments")
Call<String> getEnvironmentsByService(@Path("service") String service);


@Headers({
"Accept: application/+json",
Expand All @@ -895,6 +918,19 @@ Call<Void> setInsightCustomStartTime(
@GET("reports/assets/statistics")
Call<String> getAssetsReportStats(@QueryMap Map<String, Object> fields);

@Headers({
"Accept: application/+json",
"Content-Type:application/json"
})
@GET("services/{service}/endpoints")
Call<String> getEndpoints(@Path("service") String service, @QueryMap Map<String, Object> fields);

@Headers({
"Accept: application/+json",
"Content-Type:application/json"
})
@POST("reports/endpoints/issues")
Call<String> getEndpointIssues(@Body String filters);

@GET("services/getServices")
Call<String> getServices(@Query("environment") String environment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,16 @@ public String getServices(String environment) throws AnalyticsServiceException {
analyticsProviderProxy.getServices(environment));
}

public String getEndpoints(String service, @NotNull Map<String, Object> queryParams) throws AnalyticsServiceException {
return executeCatching(() ->
analyticsProviderProxy.getEndpoints(service, queryParams));
}

public String getEndpointIssues(String queryParams) throws AnalyticsServiceException {
return executeCatching(() ->
analyticsProviderProxy.getEndpointIssues(queryParams));
}

public String getAssetsReportStats(@NotNull Map<String, Object> queryParams) throws AnalyticsServiceException {
return executeCatching(() ->
analyticsProviderProxy.getAssetsReportStats(queryParams));
Expand All @@ -335,14 +345,18 @@ public String getServiceReport(@NotNull String queryParams) throws AnalyticsSer
analyticsProviderProxy.getServiceReport(queryParams));
}

public String getEnvironmentsByService(String service) throws AnalyticsServiceException {
return executeCatching(() ->
analyticsProviderProxy.getEnvironmentsByService(service));
}

public void resetThrottlingStatus() throws AnalyticsServiceException {
executeCatching(() -> {
analyticsProviderProxy.resetThrottlingStatus();
return null;
});
}


// return JSON as string (type LatestTestsOfSpanResponse)
public String getLatestTestsOfSpan(TestsScopeRequest req, FilterForLatestTests filter, int pageSize) throws AnalyticsServiceException {
return executeCatching(() -> analyticsProviderProxy.getLatestTestsOfSpan(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ public boolean doOnQuery(@NotNull Project project, @NotNull CefBrowser browser,
case "DASHBOARD/GET_METRICS_REPORT_DATA" -> {
pushMetricsData(browser, requestJsonNode);
}
case "DASHBOARD/GET_SERVICE_ENDPOINTS" -> {
pushEndpoints(browser, requestJsonNode);
}
case "DASHBOARD/GET_ENDPOINTS_ISSUES" -> {
pushEndpointsIssues(browser, requestJsonNode);
}
case "DASHBOARD/GET_SERVICE_ENVIRONMENTS" -> {
pushEnvironmentsData(browser, requestJsonNode);
}
case "GLOBAL/GET_BACKEND_INFO" -> {
//do nothing, dashboard app sends that for some reason, but it's not necessary
}
Expand All @@ -82,10 +91,40 @@ private void pushServices(CefBrowser browser, JsonNode requestJsonNode) {
try {
var payload = AnalyticsService.getInstance(project).getServices(env);
var message = new SetServicesMessage(payload);
Log.log(logger::trace, project, "sending DASHBOARD/GET_SERVICES message");
Log.log(logger::trace, project, "sending DASHBOARD/SET_SERVICES message");
serializeAndExecuteWindowPostMessageJavaScript(browser, message);
} catch (AnalyticsServiceException ex) {
Log.log(logger::trace, getProject(), "sending DASHBOARD/SET_SERVICES message with error");
}
}

private void pushEndpoints(CefBrowser browser, JsonNode requestJsonNode) {
var project = getProject();
Log.log(logger::trace, project, "pushEndpoints called");
var requestPayload = getPayloadFromRequestNonNull(requestJsonNode);
var backendQueryParams = getMapFromNode(requestPayload, getObjectMapper());
var service = requestPayload.get("service").textValue();
try {
var payload = AnalyticsService.getInstance(project).getEndpoints(service, backendQueryParams);
var message = new SetEndpointsMessage(payload);
Log.log(logger::trace, project, "sending DASHBOARD/SET_SERVICE_ENDPOINTS message");
serializeAndExecuteWindowPostMessageJavaScript(browser, message);
} catch (AnalyticsServiceException ex) {
Log.log(logger::trace, getProject(), "sending DASHBOARD/SET_SERVICE_ENDPOINTS message with error");
}
}

private void pushEndpointsIssues(CefBrowser browser, JsonNode requestJsonNode) {
var project = getProject();
Log.log(logger::trace, project, "pushEndpointsIssues called");
var requestPayload = getPayloadFromRequestNonNull(requestJsonNode);
try {
var payload = AnalyticsService.getInstance(project).getEndpointIssues(requestPayload.toString());
var message = new SetEndpointIssuesMessage(payload);
Log.log(logger::trace, project, "sending DASHBOARD/SET_ENDPOINTS_ISSUES message");
serializeAndExecuteWindowPostMessageJavaScript(browser, message);
} catch (AnalyticsServiceException ex) {
Log.log(logger::trace, getProject(), "sending DASHBOARD/GET_SERVICES message with error");
Log.log(logger::trace, getProject(), "sending DASHBOARD/SET_ENDPOINTS_ISSUES message with error");
}
}

Expand All @@ -97,10 +136,10 @@ private void pushAssetsReportStats(CefBrowser browser, JsonNode requestJsonNode)
try {
var payload = AnalyticsService.getInstance(project).getAssetsReportStats(backendQueryParams);
var message = new SetAssetsReportStatsMessage(payload);
Log.log(logger::trace, project, "sending DASHBOARD/GET_REPORT_ASSETS_STATS message");
Log.log(logger::trace, project, "sending DASHBOARD/SET_REPORT_ASSETS_STATS message");
serializeAndExecuteWindowPostMessageJavaScript(browser, message);
} catch (AnalyticsServiceException ex) {
Log.log(logger::trace, getProject(), "sending DASHBOARD/GET_REPORT_ASSETS_STATS message with error");
Log.log(logger::trace, getProject(), "sending DASHBOARD/SET_REPORT_ASSETS_STATS message with error");
}
}

Expand All @@ -112,10 +151,10 @@ private void pushIssuesReportStats(CefBrowser browser, JsonNode requestJsonNode)
try {
var payload = AnalyticsService.getInstance(project).getIssuesReportStats(backendQueryParams);
var message = new SetIssuesReportStatsMessage(payload);
Log.log(logger::trace, project, "sending DASHBOARD/GET_REPORT_ISSUES_STATS message");
Log.log(logger::trace, project, "sending DASHBOARD/SET_REPORT_ISSUES_STATS message");
serializeAndExecuteWindowPostMessageJavaScript(browser, message);
} catch (AnalyticsServiceException ex) {
Log.log(logger::trace, getProject(), "sending DASHBOARD/GET_REPORT_ISSUES_STATS message with error");
Log.log(logger::trace, getProject(), "sending DASHBOARD/SET_REPORT_ISSUES_STATS message with error");
}
}

Expand All @@ -126,10 +165,25 @@ private void pushMetricsData(CefBrowser browser, JsonNode requestJsonNode) {
try {
var payload = AnalyticsService.getInstance(project).getServiceReport(requestPayload.toString());
var message = new SetMetricsReportMessage(payload);
Log.log(logger::trace, project, "sending DASHBOARD/GET_METRICS_REPORT_DATA message");
Log.log(logger::trace, project, "sending DASHBOARD/SET_METRICS_REPORT_DATA message");
serializeAndExecuteWindowPostMessageJavaScript(browser, message);
} catch (AnalyticsServiceException ex) {
Log.log(logger::trace, getProject(), "sending DASHBOARD/SET_METRICS_REPORT_DATA message with error");
}
}

private void pushEnvironmentsData(CefBrowser browser, JsonNode requestJsonNode) {
var project = getProject();
var requestPayload = getPayloadFromRequestNonNull(requestJsonNode);
var service = requestPayload.get("service").textValue();
Log.log(logger::trace, project, "pushEnvironmentsData called");
try {
var payload = AnalyticsService.getInstance(project).getEnvironmentsByService(service);
var message = new SetEnvironmentsMessage(payload);
Log.log(logger::trace, project, "sending DASHBOARD/SET_SERVICE_ENVIRONMENTS message");
serializeAndExecuteWindowPostMessageJavaScript(browser, message);
} catch (AnalyticsServiceException ex) {
Log.log(logger::trace, getProject(), "sending DASHBOARD/GET_METRICS_REPORT_DATA message with error");
Log.log(logger::trace, getProject(), "sending DASHBOARD/SET_SERVICE_ENVIRONMENTS message with error");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.digma.intellij.plugin.ui.dashboard.reports.model

import com.fasterxml.jackson.annotation.JsonRawValue
import org.digma.intellij.plugin.ui.jcef.JCEFGlobalConstants

data class SetEndpointIssuesMessage(@JsonRawValue val payload: String) {
val type = JCEFGlobalConstants.REQUEST_MESSAGE_TYPE
val action = "DASHBOARD/SET_ENDPOINTS_ISSUES"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.digma.intellij.plugin.ui.dashboard.reports.model

import com.fasterxml.jackson.annotation.JsonRawValue
import org.digma.intellij.plugin.ui.jcef.JCEFGlobalConstants

data class SetEndpointsMessage(@JsonRawValue val payload: String) {
val type = JCEFGlobalConstants.REQUEST_MESSAGE_TYPE
val action = "DASHBOARD/SET_SERVICE_ENDPOINTS"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.digma.intellij.plugin.ui.dashboard.reports.model

import com.fasterxml.jackson.annotation.JsonRawValue
import org.digma.intellij.plugin.ui.jcef.JCEFGlobalConstants

data class SetEnvironmentsMessage(@JsonRawValue val payload: String) {
val type = JCEFGlobalConstants.REQUEST_MESSAGE_TYPE
val action = "DASHBOARD/SET_SERVICE_ENVIRONMENTS"
}
234 changes: 169 additions & 65 deletions src/main/resources/webview/dashboard/index.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/main/resources/webview/main/index.js

Large diffs are not rendered by default.

0 comments on commit 241c51c

Please sign in to comment.