Skip to content

Commit

Permalink
Move metrics away
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Apr 27, 2019
1 parent 55a15e1 commit b3cd0bc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 206 deletions.
46 changes: 23 additions & 23 deletions packages/@aws-cdk/aws-stepfunctions-tasks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aws-cdk/aws-stepfunctions-tasks",
"version": "0.28.0",
"version": "0.29.0",
"description": "Task integrations for AWS StepFunctions",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -70,34 +70,34 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@aws-cdk/assert": "^0.28.0",
"cdk-build-tools": "^0.28.0",
"cdk-integ-tools": "^0.28.0",
"pkglint": "^0.28.0",
"@aws-cdk/assert": "^0.29.0",
"cdk-build-tools": "^0.29.0",
"cdk-integ-tools": "^0.29.0",
"pkglint": "^0.29.0",
"jest": "^24.7.1"
},
"dependencies": {
"@aws-cdk/aws-cloudwatch": "^0.28.0",
"@aws-cdk/aws-ec2": "^0.28.0",
"@aws-cdk/aws-ecs": "^0.28.0",
"@aws-cdk/aws-stepfunctions": "^0.28.0",
"@aws-cdk/cdk": "^0.28.0",
"@aws-cdk/aws-iam": "^0.28.0",
"@aws-cdk/aws-lambda": "^0.28.0",
"@aws-cdk/aws-sns": "^0.28.0",
"@aws-cdk/aws-sqs": "^0.28.0"
"@aws-cdk/aws-cloudwatch": "^0.29.0",
"@aws-cdk/aws-ec2": "^0.29.0",
"@aws-cdk/aws-ecs": "^0.29.0",
"@aws-cdk/aws-stepfunctions": "^0.29.0",
"@aws-cdk/cdk": "^0.29.0",
"@aws-cdk/aws-iam": "^0.29.0",
"@aws-cdk/aws-lambda": "^0.29.0",
"@aws-cdk/aws-sns": "^0.29.0",
"@aws-cdk/aws-sqs": "^0.29.0"
},
"homepage": "https://github.com/awslabs/aws-cdk",
"peerDependencies": {
"@aws-cdk/aws-cloudwatch": "^0.28.0",
"@aws-cdk/aws-ec2": "^0.28.0",
"@aws-cdk/aws-ecs": "^0.28.0",
"@aws-cdk/aws-stepfunctions": "^0.28.0",
"@aws-cdk/cdk": "^0.28.0",
"@aws-cdk/aws-iam": "^0.28.0",
"@aws-cdk/aws-lambda": "^0.28.0",
"@aws-cdk/aws-sns": "^0.28.0",
"@aws-cdk/aws-sqs": "^0.28.0"
"@aws-cdk/aws-cloudwatch": "^0.29.0",
"@aws-cdk/aws-ec2": "^0.29.0",
"@aws-cdk/aws-ecs": "^0.29.0",
"@aws-cdk/aws-stepfunctions": "^0.29.0",
"@aws-cdk/cdk": "^0.29.0",
"@aws-cdk/aws-iam": "^0.29.0",
"@aws-cdk/aws-lambda": "^0.29.0",
"@aws-cdk/aws-sns": "^0.29.0",
"@aws-cdk/aws-sqs": "^0.29.0"
},
"engines": {
"node": ">= 8.10.0"
Expand Down
154 changes: 1 addition & 153 deletions packages/@aws-cdk/aws-stepfunctions/lib/states/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,162 +175,10 @@ export class Task extends State implements INextable {
};
}

/**
* Return the given named metric for this Task
*
* @default sum over 5 minutes
*/
public metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return new cloudwatch.Metric({
namespace: 'AWS/States',
metricName,
dimensions: this.resourceProps.metricDimensions,
statistic: 'sum',
...props
});
}

/**
* The interval, in milliseconds, between the time the Task starts and the time it closes.
*
* @default average over 5 minutes
*/
public metricRunTime(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.taskMetric(this.resourceProps.metricPrefixSingular, 'RunTime', { statistic: 'avg', ...props });
}

/**
* The interval, in milliseconds, for which the activity stays in the schedule state.
*
* @default average over 5 minutes
*/
public metricScheduleTime(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.taskMetric(this.resourceProps.metricPrefixSingular, 'ScheduleTime', { statistic: 'avg', ...props });
}

/**
* The interval, in milliseconds, between the time the activity is scheduled and the time it closes.
*
* @default average over 5 minutes
*/
public metricTime(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.taskMetric(this.resourceProps.metricPrefixSingular, 'Time', { statistic: 'avg', ...props });
}

/**
* Metric for the number of times this activity is scheduled
*
* @default sum over 5 minutes
*/
public metricScheduled(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.taskMetric(this.resourceProps.metricPrefixPlural, 'Scheduled', props);
}

/**
* Metric for the number of times this activity times out
*
* @default sum over 5 minutes
*/
public metricTimedOut(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.taskMetric(this.resourceProps.metricPrefixPlural, 'TimedOut', props);
}

/**
* Metric for the number of times this activity is started
*
* @default sum over 5 minutes
*/
public metricStarted(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.taskMetric(this.resourceProps.metricPrefixPlural, 'Started', props);
}

/**
* Metric for the number of times this activity succeeds
*
* @default sum over 5 minutes
*/
public metricSucceeded(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.taskMetric(this.resourceProps.metricPrefixPlural, 'Succeeded', props);
}

/**
* Metric for the number of times this activity fails
*
* @default sum over 5 minutes
*/
public metricFailed(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.taskMetric(this.resourceProps.metricPrefixPlural, 'Failed', props);
}

/**
* Metric for the number of times the heartbeat times out for this activity
*
* @default sum over 5 minutes
*/
public metricHeartbeatTimedOut(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
return this.taskMetric(this.resourceProps.metricPrefixPlural, 'HeartbeatTimedOut', props);
}

protected onBindToGraph(graph: StateGraph) {
super.onBindToGraph(graph);
for (const policyStatement of this.policyStatements || []) {
graph.registerPolicyStatement(policyStatement);
}
}

private taskMetric(prefix: string | undefined, suffix: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
if (prefix === undefined) {
throw new Error('This Task Resource does not expose metrics');
}
return this.metric(prefix + suffix, props);
}
}

/**
* Interface for objects that can be invoked in a Task state
*/
export interface IStepFunctionsTaskResource {
/**
* Return the properties required for using this object as a Task resource
*/
asStepFunctionsTaskResource(callingTask: Task): StepFunctionsTaskResourceProps;
}

/**
* Properties that define how to refer to a TaskResource
*/
export interface StepFunctionsTaskResourceProps {
/**
* The ARN of the resource
*/
readonly resourceArn: string;

/**
* Additional policy statements to add to the execution role
*
* @default No policy roles
*/
readonly policyStatements?: iam.PolicyStatement[];

/**
* Prefix for singular metric names of activity actions
*
* @default No such metrics
*/
readonly metricPrefixSingular?: string;

/**
* Prefix for plural metric names of activity actions
*
* @default No such metrics
*/
readonly metricPrefixPlural?: string;

/**
* The dimensions to attach to metrics
*
* @default No metrics
*/
readonly metricDimensions?: cloudwatch.DimensionHash;
}
>>>>>>> origin/master
}
41 changes: 11 additions & 30 deletions tools/cdk-build-tools/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b3cd0bc

Please sign in to comment.