11import { IListViewItem , ListViewGroupItem } from "../../ListView/IListViewItem" ;
22import { CodeObjectInfo } from "../codeAnalyticsView" ;
33import { CodeObjectInsight , IInsightListViewItemsCreator } from "./IInsightListViewItemsCreator" ;
4+ import { EndpointType , EndpointSchema } from '../../../services/analyticsProvider' ;
45import { WebviewChannel , WebViewUris } from "../../webViewUtils" ;
56import { DecimalRounder } from "../../utils/valueFormatting" ;
67import { EditorHelper } from "../../../services/EditorHelper" ;
@@ -10,8 +11,12 @@ import { Uri } from "vscode";
1011import path = require( "path" ) ;
1112import moment = require( "moment" ) ;
1213
13- export interface LowUsageInsight extends CodeObjectInsight {
14+
15+ export interface EndpointInsight extends CodeObjectInsight {
1416 route : string ;
17+ }
18+
19+ export interface LowUsageInsight extends EndpointInsight {
1520 maxCallsIn1Min : number ;
1621}
1722
@@ -73,8 +78,7 @@ export class LowUsageListViewItemsCreator implements IInsightListViewItemsCreato
7378
7479}
7580
76- export interface NormalUsageInsight extends CodeObjectInsight {
77- route : string ;
81+ export interface NormalUsageInsight extends EndpointInsight {
7882 maxCallsIn1Min : number ;
7983}
8084
@@ -108,8 +112,7 @@ export class NormalUsageListViewItemsCreator implements IInsightListViewItemsCre
108112
109113}
110114
111- export interface HighUsageInsight extends CodeObjectInsight {
112- route : string ;
115+ export interface HighUsageInsight extends EndpointInsight {
113116 maxCallsIn1Min : number ;
114117}
115118
@@ -120,8 +123,7 @@ export interface Duration {
120123}
121124
122125
123- export interface SlowEndpointInsight extends CodeObjectInsight {
124- route : string ;
126+ export interface SlowEndpointInsight extends EndpointInsight {
125127 endpointsMedian : Duration ;
126128 endpointsMedianOfMedians : Duration ;
127129 endpointsMedianOfP75 : Duration ;
@@ -182,9 +184,8 @@ export interface Percentile {
182184 fraction : number ,
183185 maxDuration : Duration ,
184186}
185- export interface SlowestSpansInsight extends CodeObjectInsight {
187+ export interface SlowestSpansInsight extends EndpointInsight {
186188 spans : SlowSpanInfo [ ] ;
187- route : string ;
188189}
189190
190191export class SlowestSpansListViewItemsCreator implements IInsightListViewItemsCreator {
@@ -357,21 +358,32 @@ export class SlowEndpointListViewItemsCreator implements IInsightListViewItemsCr
357358}
358359
359360
360-
361+ export function adjustHttpRouteIfNeeded ( endpointInsight : EndpointInsight ) : void {
362+ const origValue = endpointInsight . route ;
363+ if ( origValue . startsWith ( EndpointSchema . HTTP ) ) {
364+ return ;
365+ }
366+ if ( origValue . startsWith ( EndpointSchema . RPC ) ) {
367+ return ;
368+ }
369+ // default behaviour, to be backword compatible, where did not have the scheme part of the route, so adding it as HTTP one
370+ endpointInsight . route = EndpointSchema . HTTP + origValue ;
371+ }
361372
362373export class HttpEndpointListViewGroupItem extends ListViewGroupItem {
363374 constructor ( private route : string ) {
364375 super ( `HTTP ${ route } ` , 10 ) ;
365376 }
366377
367378 public getGroupHtml ( itemsHtml : string ) : string {
368- const parts = this . route . split ( ' ' ) ;
379+ const shortRouteName = EndpointSchema . getShortRouteName ( this . route ) ;
380+ const parts = shortRouteName . split ( ' ' ) ;
369381 return /*html*/ `
370382 <div class="group-item">
371383 <span class="scope">REST: </span>
372384 <span class="codicon codicon-symbol-interface" title="Endpoint"></span>
373385 <span class="uppercase">
374- <strong>HTTP </strong>${ parts [ 0 ] } </span>
386+ <strong>HTTP </strong>${ parts [ 0 ] } </span>
375387 <span>${ parts [ 1 ] } </span>
376388 </div>
377389
0 commit comments