Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/components/Insights/typeGuards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
CodeObjectErrorsInsight,
CodeObjectHotSpotInsight,
CodeObjectInsight,
EndpointBottleneckInsight,
EndpointBreakdownInsight,
EndpointDurationSlowdownInsight,
EndpointHighNumberOfQueriesInsight,
Expand All @@ -12,7 +13,9 @@ import {
EndpointLowUsageInsight,
EndpointNormalUsageInsight,
EndpointQueryOptimizationInsight,
EndpointSlowdownSourceInsight,
EndpointSlowestSpansInsight,
EndpointSpanNPlusOneInsight,
EndpointSuspectedNPlusOneInsight,
InsightScope,
QueryOptimizationInsight,
Expand Down Expand Up @@ -71,11 +74,17 @@ export const isEndpointHighUsageInsight = (
): insight is EndpointHighUsageInsight =>
insight.type === InsightType.HighUsage;

// obsolete
export const isEndpointSlowestSpansInsight = (
insight: CodeObjectInsight
): insight is EndpointSlowestSpansInsight =>
insight.type === InsightType.SlowestSpans;

export const isEndpointBottleneckInsight = (
insight: CodeObjectInsight
): insight is EndpointBottleneckInsight =>
insight.type === InsightType.EndpointBottleneck;

export const isSlowEndpointInsight = (
insight: CodeObjectInsight
): insight is SlowEndpointInsight => insight.type === InsightType.SlowEndpoint;
Expand All @@ -84,11 +93,17 @@ export const isSpanNPlusOneInsight = (
insight: CodeObjectInsight
): insight is SpanNPlusOneInsight => insight.type === InsightType.SpanNPlusOne;

// obsolete
export const isEndpointSuspectedNPlusOneInsight = (
insight: CodeObjectInsight
): insight is EndpointSuspectedNPlusOneInsight =>
insight.type === InsightType.EndpointSpanNPlusOne;

export const isEndpointSpanNPlusOneInsight = (
insight: CodeObjectInsight
): insight is EndpointSpanNPlusOneInsight =>
insight.type === InsightType.EndpointSpanNPlusOneV2;

export const isEndpointQueryOptimizationInsight = (
insight: CodeObjectInsight
): insight is EndpointQueryOptimizationInsight =>
Expand All @@ -107,6 +122,12 @@ export const isCodeObjectHotSpotInsight = (
insight: CodeObjectInsight
): insight is CodeObjectHotSpotInsight => insight.type === InsightType.HotSpot;

export const isEndpointSlowdownSourceInsight = (
insight: CodeObjectInsight
): insight is EndpointSlowdownSourceInsight =>
insight.type === InsightType.EndpointSlowdownSource;

// obsolete
export const isEndpointDurationSlowdownInsight = (
insight: CodeObjectInsight
): insight is EndpointDurationSlowdownInsight =>
Expand Down
74 changes: 74 additions & 0 deletions src/components/Insights/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type GenericCodeObjectInsight =
| CodeObjectHotSpotInsight
| CodeObjectErrorsInsight
| EndpointDurationSlowdownInsight
| EndpointSlowdownSourceInsight
| EndpointBreakdownInsight
| SpanScalingWellInsight
| SpanScalingInsufficientDataInsight
Expand Down Expand Up @@ -391,6 +392,7 @@ export interface EndpointHighUsageInsight extends EndpointInsight {
maxCallsIn1Min: number;
}

// obsolete
export interface EndpointSlowestSpansInsight extends EndpointInsight {
name: "Bottleneck Detected";
type: InsightType.SlowestSpans;
Expand Down Expand Up @@ -420,6 +422,35 @@ export interface EndpointSlowestSpansInsight extends EndpointInsight {
}[];
}

export interface EndpointBottleneckInsight extends EndpointInsight {
name: "Bottleneck Detected";
type: InsightType.EndpointBottleneck;
category: InsightCategory.Performance;
specifity: InsightSpecificity.TargetFound;
importance: InsightImportance.Critical;
isRecalculateEnabled: true;
spans: {
spanInfo: SpanInfo;
probabilityOfBeingBottleneck: number;
avgDurationWhenBeingBottleneck: Duration;
criticality: number;
ticketLink: string | null;

/**
* @deprecated
*/
p50: Percentile;
/**
* @deprecated
*/
p95: Percentile;
/**
* @deprecated
*/
p99: Percentile;
};
}

export interface SlowEndpointInsight extends EndpointInsight {
name: "Slow Endpoint";
type: InsightType.SlowEndpoint;
Expand Down Expand Up @@ -550,6 +581,27 @@ export interface EndpointSuspectedNPlusOneInsight extends EndpointInsight {
}[];
}

export interface EndpointSpanNPlusOneInsight extends EndpointInsight {
name: "Suspected N+1 Query";
type: InsightType.EndpointSpanNPlusOneV2;
category: InsightCategory.Performance;
specifity: InsightSpecificity.TargetAndReasonFound;
importance: InsightImportance.HighlyImportant;
isRecalculateEnabled: true;
spans: {
occurrences: number;
internalSpan: SpanInfo | null;
clientSpan: SpanInfo;
traceId: string;
duration: Duration;
fraction: number;
criticality: number;
impact: number;
severity: number;
ticketLink: string | null;
};
}

export interface CodeObjectHotSpotInsight extends CodeObjectInsight {
name: "Errors Hotspot";
type: InsightType.HotSpot;
Expand Down Expand Up @@ -579,6 +631,7 @@ export interface CodeObjectErrorsInsight extends CodeObjectInsight {
}[];
}

// obsolete
export interface DurationSlowdownSource {
percentile: string;
spanInfo: SpanInfo;
Expand All @@ -589,6 +642,17 @@ export interface DurationSlowdownSource {
changeVerified: boolean;
}

export interface EndpointSlowdownSources {
percentile: string;
spanInfo: SpanInfo;
level: number;
previousDuration: Duration;
currentDuration: Duration;
changeTime: string;
changeVerified: boolean;
}

// obsolete
export interface EndpointDurationSlowdownInsight extends EndpointInsight {
name: "Endpoint Duration Slowdown Source";
type: InsightType.EndpointDurationSlowdown;
Expand All @@ -599,6 +663,16 @@ export interface EndpointDurationSlowdownInsight extends EndpointInsight {
decorators: CodeObjectDecorator[];
}

export interface EndpointSlowdownSourceInsight extends EndpointInsight {
name: "Endpoint Slowdown Source";
type: InsightType.EndpointSlowdownSource;
category: InsightCategory.Performance;
specifity: InsightSpecificity.OwnInsight;
importance: InsightImportance.Critical;
endpointSlowdownSources: EndpointSlowdownSources[];
decorators: CodeObjectDecorator[];
}

export enum ComponentType {
Internal = "Internal",
DbQueries = "DB Queries",
Expand Down
5 changes: 4 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export enum InsightType {
NormalUsage = "NormalUsage",
HighUsage = "HighUsage",
SlowestSpans = "SlowestSpans",
EndpointBottleneck = "EndpointBottleneck",
EndpointSpanNPlusOne = "EndpointSpaNPlusOne",
EndpointSpanNPlusOneV2 = "EndpointSpanNPlusOne",
SpanUsages = "SpanUsages",
SpanNPlusOne = "SpaNPlusOne",
SpanEndpointBottleneck = "SpanEndpointBottleneck",
Expand All @@ -33,7 +35,8 @@ export enum InsightType {
EndpointHighNumberOfQueries = "EndpointHighNumberOfQueries",
SpanNexus = "SpanNexus",
SpanQueryOptimization = "SpanQueryOptimization",
EndpointQueryOptimization = "EndpointQueryOptimization"
EndpointQueryOptimization = "EndpointQueryOptimization",
EndpointSlowdownSource = "EndpointSlowdownSource"
}

export type PercentileKey = "p50" | "p95";
Expand Down