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

Commit

Permalink
add disk metrics to honeycomb metrics link
Browse files Browse the repository at this point in the history
  • Loading branch information
ybrill committed Dec 11, 2023
1 parent 0ea2b7b commit e537c6b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/constants/externalResources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
Expand All @@ -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`
);
});
});
16 changes: 15 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,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)),
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?: Maybe<Array<Maybe<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 | null> | null;
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
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

0 comments on commit e537c6b

Please sign in to comment.