@@ -173,11 +173,15 @@ export interface SpanInfo {
173173}
174174
175175export interface SlowSpanInfo {
176- value : number ;
177176 spanInfo : SpanInfo ;
178- lastOccurredAt : moment . Moment ;
177+ p50 : Percentile ;
178+ p95 : Percentile ;
179+ p99 : Percentile ;
180+ }
181+ export interface Percentile {
182+ fraction : number ,
183+ maxDuration : Duration ,
179184}
180-
181185export interface SlowestSpansInsight extends CodeObjectInsight {
182186 spans : SlowSpanInfo [ ] ;
183187 route : string ;
@@ -222,12 +226,14 @@ export class SlowestSpansListViewItemsCreator implements IInsightListViewItemsCr
222226 for ( let i = 0 ; i < spansLocations . length ; i ++ ) {
223227 let result = await spansLocations [ i ] . spanSearchResult ;
224228 const slowSpan = spansLocations [ i ] . slowspaninfo ;
225- const old = moment ( ) . diff ( slowSpan . lastOccurredAt , 'hours' ) > 48 ? "old" : "" ;
226- items . push ( `<div class="flex-row endpoint-bottleneck-insight ${ old } ">
227- <span class="span-percent negative-value">${ ( slowSpan . value * 100 ) . toFixed ( 1 ) } %</span>
228- <span class="span-name ${ result ? "link" : "" } ellipsis" data-code-uri="${ result ?. documentUri } " data-code-line="${ result ?. range . end . line ! + 1 } ">${ slowSpan . spanInfo . displayName } </span>
229- <span class="span-last-time" title="Last time this span took more than 50% of the endpoint duration: ${ slowSpan . lastOccurredAt } ">${ slowSpan . lastOccurredAt . fromNow ( ) } </span>
230- </div>` ) ;
229+
230+ items . push ( `
231+ <div class="endpoint-bottleneck-insight" title="${ this . getTooltip ( slowSpan ) } ">
232+ <div class="span-name flex-row ${ result ? "link" : "" } " data-code-uri="${ result ?. documentUri } " data-code-line="${ result ?. range . end . line ! + 1 } ">
233+ <span class="left-ellipsis">${ slowSpan . spanInfo . displayName } </span>
234+ </div>
235+ <div class="span-description">${ this . getDescription ( slowSpan ) } </div>
236+ </div>` ) ;
231237 }
232238
233239 const html = `
@@ -255,6 +261,23 @@ export class SlowestSpansListViewItemsCreator implements IInsightListViewItemsCr
255261 } ;
256262 }
257263
264+ private getDescription ( span : SlowSpanInfo ) {
265+ if ( span . p50 . fraction > 0.4 )
266+ return `50% of the users by up to ${ span . p50 . maxDuration . value } ${ span . p50 . maxDuration . unit } ` ;
267+ if ( span . p95 . fraction > 0.4 )
268+ return `5% of the users by up to ${ span . p95 . maxDuration . value } ${ span . p95 . maxDuration . unit } ` ;
269+ return `1% of the users by up to ${ span . p99 . maxDuration . value } ${ span . p99 . maxDuration . unit } ` ;
270+ }
271+
272+ private getTooltip ( span : SlowSpanInfo ) {
273+ //
274+ return `${ span . spanInfo . displayName }
275+
276+ Percentage of time spent in span:
277+ Median: ${ ( span . p50 . fraction * 100 ) . toFixed ( 0 ) } % ~${ span . p50 . maxDuration . value } ${ span . p50 . maxDuration . unit }
278+ P95: ${ ( span . p95 . fraction * 100 ) . toFixed ( 0 ) } % ~${ span . p95 . maxDuration . value } ${ span . p95 . maxDuration . unit }
279+ P99: ${ ( span . p99 . fraction * 100 ) . toFixed ( 0 ) } % ~${ span . p99 . maxDuration . value } ${ span . p99 . maxDuration . unit } `
280+ }
258281 public async create ( scope : CodeObjectInfo , codeObjectsInsight : SlowestSpansInsight [ ] ) : Promise < IListViewItem [ ] > {
259282 const groupedByRoute = codeObjectsInsight . groupBy ( o => o . route ) ;
260283 const listViewItems : IListViewItem [ ] = [ ] ;
0 commit comments