From e537c6b65113096d102d2ca2bc9e7f39daeaf920 Mon Sep 17 00:00:00 2001 From: Jonathan Brill Date: Mon, 11 Dec 2023 14:34:38 -0500 Subject: [PATCH] add disk metrics to honeycomb metrics link --- src/constants/externalResources.test.ts | 16 ++++++++++++++++ src/constants/externalResources.ts | 16 +++++++++++++++- src/gql/generated/types.ts | 2 ++ src/gql/queries/task.graphql | 1 + src/pages/task/metadata/index.tsx | 8 +++++++- 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/constants/externalResources.test.ts b/src/constants/externalResources.test.ts index 2beef1584b..eba7eb762f 100644 --- a/src/constants/externalResources.test.ts +++ b/src/constants/externalResources.test.ts @@ -70,6 +70,7 @@ describe("getTaskSystemMetricsUrl", () => { expect( getHoneycombSystemMetricsUrl( "task_12345", + null, new Date("2023-07-07T19:08:41"), new Date("2023-07-07T20:00:00") ) @@ -78,3 +79,18 @@ describe("getTaskSystemMetricsUrl", () => { ); }); }); + +describe("getTaskSystemMetricsUrlWithDisks", () => { + it("generates the correct url", () => { + 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.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` + ); + }); +}); diff --git a/src/constants/externalResources.ts b/src/constants/externalResources.ts index d4b6e97e9a..d5e85d32db 100644 --- a/src/constants/externalResources.ts +++ b/src/constants/externalResources.ts @@ -114,6 +114,7 @@ export const getHoneycombTraceUrl = ( export const getHoneycombSystemMetricsUrl = ( taskId: string, + diskDevices: string[], startTs: Date, endTs: Date ): string => { @@ -123,7 +124,20 @@ 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 + .map((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}` }, + ]) + .flat() + ), filters: [{ op: "=", column: "evergreen.task.id", value: taskId }], start_time: getUnixTime(new Date(startTs)), end_time: getUnixTime(new Date(endTs)), diff --git a/src/gql/generated/types.ts b/src/gql/generated/types.ts index a884f8bd7f..18287d697e 100644 --- a/src/gql/generated/types.ts +++ b/src/gql/generated/types.ts @@ -2567,6 +2567,7 @@ export type TaskContainerCreationOpts = { export type TaskEndDetail = { __typename?: "TaskEndDetail"; description?: Maybe; + diskDevices?: Maybe>>; oomTracker: OomTrackerInfo; status: Scalars["String"]["output"]; timedOut?: Maybe; @@ -8510,6 +8511,7 @@ export type TaskQuery = { details?: { __typename?: "TaskEndDetail"; description?: string | null; + diskDevices?: Array | null; status: string; timedOut?: boolean | null; timeoutType?: string | null; diff --git a/src/gql/queries/task.graphql b/src/gql/queries/task.graphql index e8931efb59..742884fa45 100644 --- a/src/gql/queries/task.graphql +++ b/src/gql/queries/task.graphql @@ -46,6 +46,7 @@ query Task($taskId: String!, $execution: Int) { } details { description + diskDevices oomTracker { detected pids diff --git a/src/pages/task/metadata/index.tsx b/src/pages/task/metadata/index.tsx index b2cc51f6e0..ddb1bdebcb 100644 --- a/src/pages/task/metadata/index.tsx +++ b/src/pages/task/metadata/index.tsx @@ -93,6 +93,7 @@ export const Metadata: React.FC = ({ 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 ?? {}; @@ -382,7 +383,12 @@ export const Metadata: React.FC = ({ error, loading, task, taskId }) => { { onHideCue(); taskAnalytics.sendEvent({ name: "Click Trace Metrics Link" });