Skip to content

Commit e4c474d

Browse files
author
Noam Kfir
committed
Add custom start time behavior
1 parent 89a1511 commit e4c474d

File tree

17 files changed

+305
-46
lines changed

17 files changed

+305
-46
lines changed

images/three-dots.svg

Lines changed: 16 additions & 0 deletions
Loading

package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
"moment": "^2.29.3",
149149
"node-fetch": "^2.6.6",
150150
"sass": "^1.54.4",
151+
"superfish": "^1.7.10",
151152
"vscode-languageclient": "^7.0.0"
152153
},
153154
"scripts": {

src/services/analyticsProvider.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,25 @@ export class AnalyticsProvider
452452
});
453453
return response;
454454
}
455+
456+
public async setInsightCustomStartTime(
457+
codeObjectId: string,
458+
insightType: string,
459+
time: Date,
460+
): Promise<any> {
461+
const response: any [] = await this.send<any>(
462+
'PUT',
463+
`/CodeAnalytics/insights/start-time`,
464+
undefined,
465+
{
466+
Environment: this.state.environment,
467+
CodeObjectId: codeObjectId,
468+
InsightType: insightType,
469+
Time: time,
470+
},
471+
);
472+
return response;
473+
}
455474

456475
public async getErrorSummary(codeObjectIds: string [], currentEnv:boolean): Promise<MethodCodeObjectSummary []>
457476
{

src/views-ui/codeAnalytics/contracts.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ export namespace UiMessage
5252
export class OverlayVisibilityChanged {
5353
constructor(public visible?: boolean, public id?:string){}
5454
}
55+
56+
export class SetInsightCustomStartTime {
57+
constructor(
58+
public codeObjectId?: string,
59+
public insightType?: string,
60+
public time?: Date,
61+
) {}
62+
}
5563
}
5664

5765
export namespace Get

src/views-ui/codeAnalytics/main.scss

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,39 @@ vscode-panel-view {
9191
}
9292
}
9393

94+
.list-item-menu {
95+
padding: 0;
96+
margin: 0;
97+
}
98+
99+
.sf-menu {
100+
li {
101+
right: 0;
102+
min-width: unset;
103+
font-family: var(--font-family);
104+
cursor: pointer;
105+
106+
&, &:hover, &.sfHover {
107+
background: transparent;
108+
}
109+
}
110+
111+
ul {
112+
left: unset;
113+
right: 0;
114+
min-width: unset;
115+
116+
li {
117+
color: var(--button-secondary-foreground);
118+
background: var(--button-secondary-background);
119+
}
120+
}
121+
}
122+
123+
.hidden {
124+
display: none;
125+
}
126+
94127
.summary-list-item {
95128
display: flex;
96129
background: var(--vscode-list-hoverBackground);

src/views-ui/codeAnalytics/main.ts

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,21 @@ window.addEventListener("load", () =>
120120
changePage($(this), 1);
121121
});
122122
}
123+
124+
function initListItemMenus(){
125+
const menus: any = $('.list-item-menu');
126+
menus.superfish();
127+
}
128+
123129
consume(UiMessage.Set.InsightsList, (event) => {
124130

125131
if (event.htmlContent !== undefined) {
126132
insightsTab.find("#insightList").html(event.htmlContent);
127133
}
128134
initPaginationLists();
135+
initListItemMenus();
129136
});
130137

131-
132-
133138
consume(UiMessage.Set.GlobalInsightsList, (event) => {
134139
if (event.htmlContent !== undefined) {
135140
globalInsightsTab.find("#insightList").html(event.htmlContent);
@@ -154,6 +159,12 @@ window.addEventListener("load", () =>
154159
}
155160
});
156161

162+
consume(UiMessage.Set.SpanObjectLabel, (event) => {
163+
if (event.htmlContent !== undefined) {
164+
$("#spanScope").html(event.htmlContent);
165+
}
166+
});
167+
157168
/*error-view*/
158169
$(document).on("click", ".error-view-close", function () {
159170
hideOverlay();
@@ -197,6 +208,25 @@ window.addEventListener("load", () =>
197208
publish(new UiMessage.Notify.OpenHistogramPanel(spanName,spanInstrumentationLibrary));
198209
});
199210

211+
$(document).on("click", ".custom-start-date-recalculate-link", function () {
212+
const $this = $(this);
213+
const codeObjectId = $this.data("code-object-id");
214+
const insightType = $this.data("insight-type");
215+
216+
const $timeInfo = $this
217+
.closest('.list-item.insight')
218+
.find('.list-item-time-info');
219+
$timeInfo
220+
.find('.list-item-time-info-message')
221+
.text('Applying the new filter. Wait a few minutes and then refresh.');
222+
$timeInfo.show();
223+
publish(new UiMessage.Notify.SetInsightCustomStartTime(codeObjectId, insightType, new Date()));
224+
});
225+
226+
$(document).on("click", ".custom-start-date-refresh-link", function () {
227+
publish(new UiMessage.Notify.TabRefreshRequested());
228+
});
229+
200230
$(document).on("click", ".trace-link", function () {
201231
const traceIds = $(this).data("trace-id").split(",");
202232
const traceLabels = $(this).data("trace-label")?.split(",");
@@ -207,6 +237,16 @@ window.addEventListener("load", () =>
207237
publish(new UiMessage.Notify.OpenTracePanel(traceIds,traceLabels,span, jaeger));
208238
});
209239

240+
$(document).on("click", ".reset-link", function () {
241+
const traceIds = $(this).data("trace-id").split(",");
242+
const traceLabels = $(this).data("trace-label")?.split(",");
243+
244+
const span = $(this).data("span-name");
245+
const jaeger = $(this).data("jaeger-address");
246+
247+
publish(new UiMessage.Notify.OpenTracePanel(traceIds,traceLabels,span, jaeger));
248+
});
249+
210250
$(document).on("click",".pagination-nav .prev", function(){
211251
var paginationListElement = $(this).closest('.pagination-list');
212252
prevPage(paginationListElement);

src/views/codeAnalytics/AdminInsights/adminInsights.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export class UnknownInsightInsight implements IListViewItemBase {
1111
return new InsightTemplateHtml({
1212
title: "The Digma Plugin probably requires an update",
1313
description: "We're getting wicked new insights but this plugin just ain't up to date. Please update the plugin via your vscode Settings.",
14-
icon: this.viewUris.image("update-required.png")
15-
}).renderHtml();
14+
icon: this.viewUris.image("update-required.png"),
15+
}, this.viewUris).renderHtml();
1616
}
1717
groupId: string | undefined;
1818
}
@@ -26,8 +26,8 @@ export class DuplicateSpanInsight implements IListViewItemBase {
2626
return new InsightTemplateHtml({
2727
title: "Duplicate span detected",
2828
description: "Two spans have the exact same identifier, please change the name to avoid getting the wires crossed...",
29-
icon: this.viewUris.image("update-required.png")
30-
}).renderHtml();
29+
icon: this.viewUris.image("update-required.png"),
30+
}, this.viewUris).renderHtml();
3131
}
3232
groupId: string | undefined = this.span.name;
3333
}

src/views/codeAnalytics/InsightListView/EndpointInsight.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,18 @@ export class UsageViewItemsTemplate {
6161
) { }
6262

6363
public generateHtml(
64-
maxCallsIn1Min: number,
64+
insight: LowUsageInsight,
6565
header: string,
6666
description: string,
6767
image: string) {
68-
const value = new DecimalRounder().getRoundedString(maxCallsIn1Min);
68+
const value = new DecimalRounder().getRoundedString(insight.maxCallsIn1Min);
6969
const template = new InsightTemplateHtml({
7070
title: header,
7171
description: description,
7272
icon: this.viewUris.image(image),
73-
body: `<span title="Maximum of ${value} requests per minute">${value}/min</span>`
74-
})
73+
body: `<span title="Maximum of ${value} requests per minute">${value}/min</span>`,
74+
insight,
75+
}, this.viewUris);
7576
return template.renderHtml();
7677
}
7778
}
@@ -88,7 +89,7 @@ export class LowUsageListViewItemsCreator implements IInsightListViewItemsCreato
8889

8990
public createListViewItem(codeObjectsInsight: LowUsageInsight): IListViewItem {
9091
return {
91-
getHtml: () => this.template.generateHtml(codeObjectsInsight.maxCallsIn1Min, "Endpoint low traffic", "Servicing a low number of requests", "traffic-low.svg"),
92+
getHtml: () => this.template.generateHtml(codeObjectsInsight, "Endpoint low traffic", "Servicing a low number of requests", "traffic-low.svg"),
9293
sortIndex: 0,
9394
groupId: codeObjectsInsight.endpointSpan
9495
};
@@ -114,7 +115,7 @@ export class NormalUsageListViewItemsCreator implements IInsightListViewItemsCre
114115

115116
public createListViewItem(codeObjectsInsight: NormalUsageInsight): IListViewItem {
116117
return {
117-
getHtml: () => this.template.generateHtml(codeObjectsInsight.maxCallsIn1Min, "Endpoint normal level of traffic", "Servicing an average number of requests", "traffic-normal.svg"),
118+
getHtml: () => this.template.generateHtml(codeObjectsInsight, "Endpoint normal level of traffic", "Servicing an average number of requests", "traffic-normal.svg"),
118119
sortIndex: 0,
119120
groupId: codeObjectsInsight.endpointSpan
120121
};
@@ -149,7 +150,7 @@ export class HighUsageListViewItemsCreator implements IInsightListViewItemsCreat
149150

150151
public createListViewItem(codeObjectsInsight: HighUsageInsight): IListViewItem {
151152
return {
152-
getHtml: () => this.template.generateHtml(codeObjectsInsight.maxCallsIn1Min, "Endpoint high traffic", "Servicing a high number of requests", "traffic-high.svg"),
153+
getHtml: () => this.template.generateHtml(codeObjectsInsight, "Endpoint high traffic", "Servicing a high number of requests", "traffic-high.svg"),
153154
sortIndex: 0,
154155
groupId: codeObjectsInsight.endpointSpan
155156
};
@@ -207,8 +208,9 @@ export class SlowestSpansListViewItemsCreator implements IInsightListViewItemsCr
207208
},
208209
description: "The following spans are slowing request handling",
209210
icon: this._viewUris.image("bottleneck.svg"),
210-
body: items.join('')
211-
});
211+
body: items.join(''),
212+
insight: codeObjectsInsight,
213+
}, this._viewUris);
212214

213215
return {
214216
getHtml: () => template.renderHtml(),
@@ -326,8 +328,9 @@ export class EPNPlusSpansListViewItemsCreator implements IInsightListViewItemsCr
326328
${items.join('')}
327329
</div>
328330
${statsHtml}`,
329-
buttons: [traceHtml]
330-
});
331+
buttons: [traceHtml],
332+
insight: codeObjectsInsight,
333+
}, this._viewUris);
331334

332335
return {
333336
getHtml: () => template.renderHtml(),
@@ -378,8 +381,9 @@ export class SlowEndpointListViewItemsCreator implements IInsightListViewItemsCr
378381
description: `<span>On average requests are slower than other endpoints by</span>
379382
<span class="negative-value">${this.computePercentageDiff(codeObjectsInsight.median.raw, codeObjectsInsight.endpointsMedianOfMedians.raw)}</span>`,
380383
icon: this.viewUris.image("snail.svg"),
381-
body: this.duration(codeObjectsInsight.median)
382-
});
384+
body: this.duration(codeObjectsInsight.median),
385+
insight: codeObjectsInsight,
386+
}, this.viewUris);
383387

384388
return {
385389
getHtml: () => template.renderHtml(),

src/views/codeAnalytics/InsightListView/ErrorsInsight.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export class ErrorsListViewItemsCreator
5555
buttons: [
5656
`<div class="expand list-item-button" tab-id="tab-errors">Expand</div>`,
5757
],
58-
});
58+
insight: o,
59+
}, this._viewUris);
5960

6061
return {
6162
getHtml: () => template.renderHtml(),

0 commit comments

Comments
 (0)