33import com .fasterxml .jackson .core .JsonProcessingException ;
44import com .fasterxml .jackson .databind .exc .MismatchedInputException ;
55import okhttp3 .mockwebserver .MockResponse ;
6- import org .digma .intellij .plugin .model .rest .insights .*;
6+ import org .digma .intellij .plugin .model .rest .insights .CodeObjectInsight ;
7+ import org .digma .intellij .plugin .model .rest .insights .CodeObjectInsightsStatusResponse ;
8+ import org .digma .intellij .plugin .model .rest .insights .Duration ;
9+ import org .digma .intellij .plugin .model .rest .insights .ErrorInsight ;
10+ import org .digma .intellij .plugin .model .rest .insights .ErrorInsightNamedError ;
11+ import org .digma .intellij .plugin .model .rest .insights .HighUsageInsight ;
12+ import org .digma .intellij .plugin .model .rest .insights .HotspotInsight ;
13+ import org .digma .intellij .plugin .model .rest .insights .InsightOfMethodsRequest ;
14+ import org .digma .intellij .plugin .model .rest .insights .InsightsRequest ;
15+ import org .digma .intellij .plugin .model .rest .insights .LowUsageInsight ;
16+ import org .digma .intellij .plugin .model .rest .insights .MethodWithCodeObjects ;
17+ import org .digma .intellij .plugin .model .rest .insights .NormalUsageInsight ;
18+ import org .digma .intellij .plugin .model .rest .insights .Percentile ;
19+ import org .digma .intellij .plugin .model .rest .insights .SlowEndpointInsight ;
20+ import org .digma .intellij .plugin .model .rest .insights .SlowSpanInfo ;
21+ import org .digma .intellij .plugin .model .rest .insights .SlowestSpansInsight ;
22+ import org .digma .intellij .plugin .model .rest .insights .SpanHistogramQuery ;
23+ import org .digma .intellij .plugin .model .rest .insights .SpanInfo ;
724import org .junit .jupiter .api .Test ;
825
926import java .time .temporal .ChronoUnit ;
@@ -61,7 +78,7 @@ public void actualgetHtmlGraphForSpanPercentiles() {
6178 System .out .println ("htmlBody:" + htmlBody );
6279 }
6380
64- // @Test
81+ // @Test
6582 public void actualGetCodeObjectInsightStatus () {
6683 final InsightOfMethodsRequest request = new InsightOfMethodsRequest (
6784 "ARIKS-MACBOOK-PRO.LOCAL[LOCAL]" ,
@@ -81,6 +98,7 @@ public void actualGetCodeObjectInsightStatus() {
8198 void getInsights () throws JsonProcessingException {
8299
83100 final String ROUTE = "post transfer/transferfunds" ;
101+ final String SERVICE = "MyService" ;
84102 final String ENDPOINT_SPAN = "HTTP POST transfer/transferfunds" ;
85103 final String ENV_1 = "Env1" ;
86104 final String SCOPE_1 = "Scope1" ;
@@ -105,29 +123,37 @@ void getInsights() throws JsonProcessingException {
105123
106124 String expectedNormalUsageInsightCodeObjectId = "Sample.MoneyTransfer.API.Domain.Services.MoneyTransferDomainService$_$TransferFunds" ;
107125 NormalUsageInsight expectedNormalUsageInsight = new NormalUsageInsight (expectedNormalUsageInsightCodeObjectId , ENV_1 , SCOPE_1 , IMPORTANCE_3 , null ,
108- ROUTE , ENDPOINT_SPAN , actualStartTimeNow , customStartTimeFiveDaysBefore , addPrefixToCodeObjectId (expectedNormalUsageInsightCodeObjectId ), null , 40 );
126+ actualStartTimeNow , customStartTimeFiveDaysBefore , addPrefixToCodeObjectId (expectedNormalUsageInsightCodeObjectId ), null ,
127+ createSpanInfo (ENDPOINT_SPAN , expectedNormalUsageInsightCodeObjectId ), ROUTE , SERVICE ,
128+ 40 );
109129 expectedCodeObjectInsights .add (expectedNormalUsageInsight );
110130
111131 String expectedLowUsageInsightCodeObjectId = "Sample.MoneyTransfer.API.Domain.Services.MoneyTransferDomainService$_$Abc" ;
112132 LowUsageInsight expectedLowUsageInsight = new LowUsageInsight (expectedLowUsageInsightCodeObjectId , ENV_1 , SCOPE_1 , IMPORTANCE_3 , null ,
113- ROUTE , ENDPOINT_SPAN , actualStartTimeNow , customStartTimeFiveDaysBefore , addPrefixToCodeObjectId (expectedLowUsageInsightCodeObjectId ), null , 13 );
133+ actualStartTimeNow , customStartTimeFiveDaysBefore , addPrefixToCodeObjectId (expectedLowUsageInsightCodeObjectId ), null ,
134+ createSpanInfo (ENDPOINT_SPAN , expectedLowUsageInsightCodeObjectId ), ROUTE , SERVICE ,
135+ 13 );
114136 expectedCodeObjectInsights .add (expectedLowUsageInsight );
115137
116138 String expectedHighUsageInsightCodeObjectId = "Sample.MoneyTransfer.API.Domain.Services.MoneyTransferDomainService$_$Defg" ;
117139 HighUsageInsight expectedHighUsageInsight = new HighUsageInsight (expectedHighUsageInsightCodeObjectId , ENV_1 , SCOPE_1 , IMPORTANCE_3 , null ,
118- ROUTE , ENDPOINT_SPAN , actualStartTimeNow , customStartTimeFiveDaysBefore , addPrefixToCodeObjectId (expectedHighUsageInsightCodeObjectId ), null , 98 );
140+ actualStartTimeNow , customStartTimeFiveDaysBefore , addPrefixToCodeObjectId (expectedHighUsageInsightCodeObjectId ), null ,
141+ createSpanInfo (ENDPOINT_SPAN , expectedHighUsageInsightCodeObjectId ), ROUTE , SERVICE ,
142+ 98 );
119143 expectedCodeObjectInsights .add (expectedHighUsageInsight );
120144
121- SpanInfo spanInfo = new SpanInfo ( "Retrieving account" , "Retrieving account" , "MoneyTransferDomainService" , "Sample.MoneyTransfer.API" , "Sample.MoneyTransfer.API.MoneyTransferDomainService$_$Error" );
122- SlowSpanInfo slowSpanInfo = new SlowSpanInfo ( spanInfo ,
145+ SlowSpanInfo slowSpanInfo = new SlowSpanInfo (
146+ createSpanInfo ( "SomeSpan" , "Sample.MoneyTransfer.API.MoneyTransferDomainService$_$Error" ) ,
123147 new Percentile (0.10970134022722634D , new Duration (3.44D , "ms" , 3441700L )),
124148 new Percentile (0.2566821090980162D , new Duration (3.44D , "ms" , 3441700L )),
125149 new Percentile (0.4407383382867023D , new Duration (5.64D , "ms" , 5643900L )),
126150 null , null );
127151
128152 String expectedSlowestSpansInsightCodeObjectId = "Sample.MoneyTransfer.API.Domain.Services.MoneyTransferDomainService$_$TransferFunds" ;
129153 SlowestSpansInsight expectedSlowestSpansInsight = new SlowestSpansInsight (expectedSlowestSpansInsightCodeObjectId , ENV_1 , SCOPE_1 , IMPORTANCE_3 , null ,
130- ROUTE , ENDPOINT_SPAN , actualStartTimeNow , customStartTimeFiveDaysBefore , addPrefixToCodeObjectId (expectedSlowestSpansInsightCodeObjectId ), null , Collections .singletonList (slowSpanInfo ));
154+ actualStartTimeNow , customStartTimeFiveDaysBefore , addPrefixToCodeObjectId (expectedSlowestSpansInsightCodeObjectId ), null ,
155+ createSpanInfo (ENDPOINT_SPAN , expectedSlowestSpansInsightCodeObjectId ), ROUTE , SERVICE ,
156+ Collections .singletonList (slowSpanInfo ));
131157 expectedCodeObjectInsights .add (expectedSlowestSpansInsight );
132158
133159 String expectedSlowEndpointInsightCodeObjectId = "Sample.MoneyTransfer.API.Domain.Services.MoneyTransferDomainService$_$TransferFunds" ;
@@ -137,12 +163,13 @@ void getInsights() throws JsonProcessingException {
137163 , SCOPE_1
138164 , IMPORTANCE_3
139165 , null
140- , ROUTE
141- , ENDPOINT_SPAN
142166 , actualStartTimeNow
143167 , customStartTimeFiveDaysBefore
144168 , addPrefixToCodeObjectId (expectedSlowEndpointInsightCodeObjectId )
145169 , null
170+ , createSpanInfo (ENDPOINT_SPAN , expectedSlowEndpointInsightCodeObjectId )
171+ , ROUTE
172+ , SERVICE
146173 , new Duration (0.11D , "ms" , 11000 )
147174 , new Duration (0.12D , "ms" , 12000 )
148175 , new Duration (0.13D , "ms" , 13000 )
@@ -197,6 +224,11 @@ void getInsights() throws JsonProcessingException {
197224
198225 }
199226
227+ private SpanInfo createSpanInfo (String spanName , String methodCodeObjectId ) {
228+ String instLib = "il" ;
229+ return new SpanInfo (instLib , spanName , "span:$instLib$_$" + spanName , "disp_" + spanName ,
230+ methodCodeObjectId , "Internal" );
231+ }
200232
201233 @ Test
202234 void getInsightsEmptyResultTest () throws JsonProcessingException {
0 commit comments