(
+ [
+
+ The following {dbStatement} query is abnormally slow. Please
+ consider optimizing or adding indexes.
+
,
+ {queryString}
,
+
+ Typical duration for {dbStatement} queries in this DB:{" "}
+ {getDurationString(props.data.insight.typicalDuration)}
+ {"\n"}
+ This query: {getDurationString(props.data.insight.duration)}
+
,
+ ,
+
+ ],
+ (i: number) => (
+
+ )
+ )}
+ >
+ );
+
+ const traceId = props.data.insight.traceId;
+ const attachment = traceId
+ ? {
+ url: `${config.jaegerURL}/api/traces/${traceId}?prettyPrint=true`,
+ fileName: `trace-${traceId}.json`
+ }
+ : undefined;
+
+ useEffect(() => {
+ setIsInitialLoading(true);
+
+ const commits = getInsightCommits(props.data.insight);
+
+ if (commits.length > 0) {
+ window.sendMessageToDigma({
+ action: actions.GET_COMMIT_INFO,
+ payload: {
+ commits
+ }
+ });
+ }
+
+ const handleCommitInfosData = (data: unknown) => {
+ const commitInfosData = data as CommitInfosData;
+ setCommitInfos(commitInfosData);
+ setIsInitialLoading(false);
+ };
+
+ dispatcher.addActionListener(
+ actions.SET_COMMIT_INFO,
+ handleCommitInfosData
+ );
+
+ return () => {
+ dispatcher.removeActionListener(
+ actions.SET_COMMIT_INFO,
+ handleCommitInfosData
+ );
+ };
+ }, []);
+
+ return (
+
+ );
+};
diff --git a/src/components/Insights/typeGuards.ts b/src/components/Insights/typeGuards.ts
index 7209e0e1f..7edffc869 100644
--- a/src/components/Insights/typeGuards.ts
+++ b/src/components/Insights/typeGuards.ts
@@ -14,6 +14,7 @@ import {
EndpointSlowestSpansInsight,
EndpointSuspectedNPlusOneInsight,
InsightScope,
+ QueryOptimizationInsight,
SessionInViewEndpointInsight,
SlowEndpointInsight,
SpanDurationBreakdownInsight,
@@ -138,3 +139,8 @@ export const isEndpointHighNumberOfQueriesInsight = (
export const isSpanNexusInsight = (
insight: CodeObjectInsight
): insight is SpanNexusInsight => insight.type === InsightType.SpanNexus;
+
+export const isSpanQueryOptimizationInsight = (
+ insight: CodeObjectInsight
+): insight is QueryOptimizationInsight =>
+ insight.type === InsightType.SpanQueryOptimization;
diff --git a/src/components/Insights/types.ts b/src/components/Insights/types.ts
index e3cafe43f..57bb28908 100644
--- a/src/components/Insights/types.ts
+++ b/src/components/Insights/types.ts
@@ -690,3 +690,14 @@ export interface SpanNexusInsight extends SpanInsight {
flows: number;
usage: string | null;
}
+
+export interface QueryOptimizationInsight extends SpanInsight {
+ type: InsightType.SpanQueryOptimization;
+ duration: Duration;
+ typicalDuration: Duration;
+ dbStatement: string;
+ traceId: string | null;
+ span: SpanInfo;
+ serviceName: string;
+ dbName: string;
+}
diff --git a/src/types.ts b/src/types.ts
index 26988fc9b..16dff3355 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -32,7 +32,8 @@ export enum InsightType {
EndpointSessionInView = "EndpointSessionInView",
EndpointChattyApi = "EndpointChattyApi",
EndpointHighNumberOfQueries = "EndpointHighNumberOfQueries",
- SpanNexus = "SpanNexus"
+ SpanNexus = "SpanNexus",
+ SpanQueryOptimization = "SpanQueryOptimization"
}
export type PercentileKey = "p50" | "p95";
diff --git a/src/utils/getInsightTypeInfo.ts b/src/utils/getInsightTypeInfo.ts
index 973512de0..943bfae69 100644
--- a/src/utils/getInsightTypeInfo.ts
+++ b/src/utils/getInsightTypeInfo.ts
@@ -117,6 +117,10 @@ export const getInsightTypeInfo = (
[InsightType.SpanNexus]: {
icon: BottleneckIcon, // todo changes
label: "Code Nexus Point"
+ },
+ [InsightType.SpanQueryOptimization]: {
+ icon: SQLDatabaseIcon,
+ label: "Query Optimization Suggested"
}
};
diff --git a/src/utils/getInsightTypeOrderPriority.ts b/src/utils/getInsightTypeOrderPriority.ts
index fcd23bfa1..a504e5f59 100644
--- a/src/utils/getInsightTypeOrderPriority.ts
+++ b/src/utils/getInsightTypeOrderPriority.ts
@@ -13,6 +13,8 @@ export const getInsightTypeOrderPriority = (type: string): number => {
[InsightType.SpanDurationChange]: 66,
[InsightType.SpanEndpointBottleneck]: 67,
[InsightType.SpanDurationBreakdown]: 68,
+ [InsightType.SpanNexus]: 69,
+ [InsightType.SpanQueryOptimization]: 70,
[InsightType.EndpointSpanNPlusOne]: 55,
[InsightType.EndpointSessionInView]: 56,