Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

DEVPROD-1661 add disk metrics to honeycomb metrics link #2183

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/constants/externalResources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,28 @@ describe("getTaskTraceUrl", () => {
});
});

describe("getTaskSystemMetricsUrl", () => {
describe("getHoneycombSystemMetricsUrl", () => {
it("generates the correct url", () => {
expect(
getHoneycombSystemMetricsUrl(
"task_12345",
[],
new Date("2023-07-07T19:08:41"),
new Date("2023-07-07T20:00:00")
)
).toBe(
`/datasets/evergreen?query={"calculations":[{"op":"AVG","column":"system.memory.usage.used"},{"op":"AVG","column":"system.cpu.utilization"},{"op":"RATE_AVG","column":"system.network.io.transmit"},{"op":"RATE_AVG","column":"system.network.io.receive"}],"filters":[{"op":"=","column":"evergreen.task.id","value":"task_12345"}],"start_time":1688756921,"end_time":1688760000}&omitMissingValues`
);

expect(
getHoneycombSystemMetricsUrl(
"task_12345",
["disk1", "disk2"],
new Date("2023-07-07T19:08:41"),
new Date("2023-07-07T20:00:00")
)
).toBe(
`/datasets/evergreen?query={"calculations":[{"op":"AVG","column":"system.memory.usage.used"},{"op":"AVG","column":"system.cpu.utilization"},{"op":"RATE_AVG","column":"system.network.io.transmit"},{"op":"RATE_AVG","column":"system.network.io.receive"},{"op":"RATE_AVG","column":"system.disk.io.disk1.read"},{"op":"RATE_AVG","column":"system.disk.io.disk1.write"},{"op":"RATE_AVG","column":"system.disk.operations.disk1.read"},{"op":"RATE_AVG","column":"system.disk.operations.disk1.write"},{"op":"RATE_AVG","column":"system.disk.io_time.disk1"},{"op":"RATE_AVG","column":"system.disk.io.disk2.read"},{"op":"RATE_AVG","column":"system.disk.io.disk2.write"},{"op":"RATE_AVG","column":"system.disk.operations.disk2.read"},{"op":"RATE_AVG","column":"system.disk.operations.disk2.write"},{"op":"RATE_AVG","column":"system.disk.io_time.disk2"}],"filters":[{"op":"=","column":"evergreen.task.id","value":"task_12345"}],"start_time":1688756921,"end_time":1688760000}&omitMissingValues`
);
});
});
14 changes: 13 additions & 1 deletion src/constants/externalResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export const getHoneycombTraceUrl = (

export const getHoneycombSystemMetricsUrl = (
taskId: string,
diskDevices: string[],
startTs: Date,
endTs: Date
): string => {
Expand All @@ -123,7 +124,18 @@ export const getHoneycombSystemMetricsUrl = (
{ op: "AVG", column: "system.cpu.utilization" },
{ op: "RATE_AVG", column: "system.network.io.transmit" },
{ op: "RATE_AVG", column: "system.network.io.receive" },
],
].concat(
diskDevices.flatMap((device) => [
{ op: "RATE_AVG", column: `system.disk.io.${device}.read` },
{ op: "RATE_AVG", column: `system.disk.io.${device}.write` },
{ op: "RATE_AVG", column: `system.disk.operations.${device}.read` },
{
op: "RATE_AVG",
column: `system.disk.operations.${device}.write`,
},
{ op: "RATE_AVG", column: `system.disk.io_time.${device}` },
])
),
filters: [{ op: "=", column: "evergreen.task.id", value: taskId }],
start_time: getUnixTime(new Date(startTs)),
end_time: getUnixTime(new Date(endTs)),
Expand Down
2 changes: 2 additions & 0 deletions src/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2567,6 +2567,7 @@ export type TaskContainerCreationOpts = {
export type TaskEndDetail = {
__typename?: "TaskEndDetail";
description?: Maybe<Scalars["String"]["output"]>;
diskDevices: Array<Scalars["String"]["output"]>;
oomTracker: OomTrackerInfo;
status: Scalars["String"]["output"];
timedOut?: Maybe<Scalars["Boolean"]["output"]>;
Expand Down Expand Up @@ -8510,6 +8511,7 @@ export type TaskQuery = {
details?: {
__typename?: "TaskEndDetail";
description?: string | null;
diskDevices: Array<string>;
status: string;
timedOut?: boolean | null;
timeoutType?: string | null;
Expand Down
1 change: 1 addition & 0 deletions src/gql/queries/task.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ query Task($taskId: String!, $execution: Int) {
}
details {
description
diskDevices
oomTracker {
detected
pids
Expand Down
1 change: 1 addition & 0 deletions src/pages/task/metadata/Metadata.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const taskSucceeded = {
oomTracker: {
detected: false,
},
diskDevices: [],
},
},
};
8 changes: 7 additions & 1 deletion src/pages/task/metadata/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const Metadata: React.FC<Props> = ({ error, loading, task, taskId }) => {
const { author, id: versionID } = versionMetadata ?? {};
const oomTracker = details?.oomTracker;
const taskTrace = details?.traceID;
const diskDevices = details?.diskDevices;
const { id: podId } = pod ?? {};
const isContainerTask = !!podId;
const { metadataLinks } = annotation ?? {};
Expand Down Expand Up @@ -382,7 +383,12 @@ export const Metadata: React.FC<Props> = ({ error, loading, task, taskId }) => {
</StyledLink>
<StyledLink
data-cy="task-metrics-link"
href={getHoneycombSystemMetricsUrl(taskId, startTime, finishTime)}
href={getHoneycombSystemMetricsUrl(
taskId,
diskDevices,
startTime,
finishTime
)}
onClick={() => {
onHideCue();
taskAnalytics.sendEvent({ name: "Click Trace Metrics Link" });
Expand Down