Skip to content

Commit b25e8c5

Browse files
authored
Span bottleneck stats (#92)
1 parent 7d97b77 commit b25e8c5

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

src/views-ui/codeAnalytics/main.scss

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ vscode-panel-view {
7070
display: flex;
7171
flex-direction: column;
7272
margin: 3px;
73-
justify-content: space-between;
73+
justify-content: flex-start;
7474
}
7575

7676
.score-box {
@@ -402,16 +402,12 @@ vscode-panel-view {
402402
}
403403
}
404404
.endpoint-bottleneck-insight{
405-
&.old{
406-
opacity: 0.6;
407-
}
408-
.span-percent{
409-
margin-right: 5px;
410-
}
405+
margin-top: 5px;
406+
411407
.span-name{
412408
margin-right: 5px;
413409
}
414-
.span-last-time{
410+
.span-description{
415411
opacity: 0.6;
416412
}
417413
}

src/views/codeAnalytics/InsightListView/EndpointInsight.ts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,15 @@ export interface SpanInfo {
173173
}
174174

175175
export 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-
181185
export 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+
//&#13;
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

Comments
 (0)