Skip to content

Commit

Permalink
Merge pull request #1021 from JupiterOne/int-10291-add-step-start-end…
Browse files Browse the repository at this point in the history
…-times

Enhance step summary with start, end, and duration metrics
  • Loading branch information
Nick-NCSU authored Feb 1, 2024
2 parents 6c33f45 + c8c5895 commit 0621c9f
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 6 deletions.
42 changes: 42 additions & 0 deletions packages/integration-sdk-cli/src/__tests__/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: ['test_account'],
status: StepResultStatus.CACHED,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'fetch-groups',
Expand All @@ -134,6 +137,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'fetch-users',
Expand Down Expand Up @@ -166,6 +172,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'fetch-groups',
Expand All @@ -175,6 +184,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'fetch-users',
Expand All @@ -183,6 +195,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
],
metadata: {
Expand Down Expand Up @@ -212,6 +227,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.FAILURE,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
],
metadata: {
Expand Down Expand Up @@ -240,6 +258,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: ['my_user'],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
],
metadata: {
Expand Down Expand Up @@ -288,6 +309,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
],
metadata: {
Expand Down Expand Up @@ -319,6 +343,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'fetch-groups',
Expand All @@ -336,6 +363,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
],
metadata: {
Expand Down Expand Up @@ -369,6 +399,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'fetch-groups',
Expand All @@ -386,6 +419,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
],
metadata: {
Expand Down Expand Up @@ -416,6 +452,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'fetch-groups',
Expand All @@ -425,6 +464,9 @@ describe('collect', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'fetch-users',
Expand Down
15 changes: 15 additions & 0 deletions packages/integration-sdk-core/src/types/step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,21 @@ export type IntegrationStepResult = Omit<
* Entity or relationship types encountered during step execution.
*/
encounteredTypes: string[];

/**
* Start time of the step in milliseconds since the Unix epoch.
*/
startTime?: number;

/**
* End time of the step in milliseconds since the Unix epoch.
*/
endTime?: number;

/**
* Duration of the step in milliseconds, calculated as endTime - startTime.
*/
duration?: number;
};

export type IntegrationStep<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ describe('executeStepDependencyGraph', () => {
partialTypes: [],
encounteredTypes: ['my_type_b'],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
]);

Expand Down Expand Up @@ -605,6 +608,9 @@ describe('executeStepDependencyGraph', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'b',
Expand All @@ -614,6 +620,9 @@ describe('executeStepDependencyGraph', () => {
encounteredTypes: [],
dependsOn: ['a'],
status: StepResultStatus.FAILURE,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'c',
Expand All @@ -623,6 +632,9 @@ describe('executeStepDependencyGraph', () => {
encounteredTypes: [],
dependsOn: ['b'],
status: StepResultStatus.PARTIAL_SUCCESS_DUE_TO_DEPENDENCY_FAILURE,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
]);

Expand Down Expand Up @@ -755,6 +767,9 @@ describe('executeStepDependencyGraph', () => {
partialTypes: [],
encounteredTypes: [eA._type],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'b',
Expand All @@ -764,6 +779,9 @@ describe('executeStepDependencyGraph', () => {
encounteredTypes: [eB._type],
dependsOn: ['a'],
status: StepResultStatus.FAILURE,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'c',
Expand All @@ -773,6 +791,9 @@ describe('executeStepDependencyGraph', () => {
encounteredTypes: [eC._type],
dependsOn: ['b'],
status: StepResultStatus.PARTIAL_SUCCESS_DUE_TO_DEPENDENCY_FAILURE,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
]);

Expand Down Expand Up @@ -870,6 +891,9 @@ describe('executeStepDependencyGraph', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.FAILURE,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'b',
Expand All @@ -879,6 +903,9 @@ describe('executeStepDependencyGraph', () => {
encounteredTypes: [],
dependsOn: ['a'],
status: StepResultStatus.PARTIAL_SUCCESS_DUE_TO_DEPENDENCY_FAILURE,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'c',
Expand All @@ -888,6 +915,9 @@ describe('executeStepDependencyGraph', () => {
encounteredTypes: [],
dependsOn: ['b'],
status: StepResultStatus.PARTIAL_SUCCESS_DUE_TO_DEPENDENCY_FAILURE,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
]);

Expand Down Expand Up @@ -1256,6 +1286,9 @@ describe('executeStepDependencyGraph', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'b',
Expand All @@ -1273,6 +1306,9 @@ describe('executeStepDependencyGraph', () => {
encounteredTypes: [],
dependsOn: ['a'],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'd',
Expand All @@ -1290,6 +1326,9 @@ describe('executeStepDependencyGraph', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
]),
);
Expand Down Expand Up @@ -1391,6 +1430,9 @@ describe('executeStepDependencyGraph', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'b',
Expand All @@ -1408,6 +1450,9 @@ describe('executeStepDependencyGraph', () => {
encounteredTypes: [],
dependsOn: ['a'],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
{
id: 'd',
Expand All @@ -1425,6 +1470,9 @@ describe('executeStepDependencyGraph', () => {
partialTypes: [],
encounteredTypes: [],
status: StepResultStatus.SUCCESS,
startTime: expect.any(Number),
endTime: expect.any(Number),
duration: expect.any(Number),
},
]),
);
Expand Down
Loading

0 comments on commit 0621c9f

Please sign in to comment.