Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private createCallGraphWidget(opts?: WatchedOperation, alarmThreshold?: number) {
const leftAnnotations: HorizontalAnnotation[] = alarmThreshold
? [{ value: alarmThreshold, color: '#ff0000', label: '5XX Errors Alarm' }]
: [];
return new GraphWidget({
title: `${opts ? `${opts.httpMethod} ${opts.resourcePath}` : 'Overall'} Calls/min`,
width: 12,
stacked: false,
left: [
this.createApiGatewayMetric(ApiGatewayMetric.Count, opts, { label: 'Calls', statistic: 'sum', color: '#1f77b4' }),
this.createApiGatewayMetric(ApiGatewayMetric.FourHundredError, opts, { label: 'HTTP 4XX', statistic: 'sum', color: '#ff7f0e' }),
this.createApiGatewayMetric(ApiGatewayMetric.FiveHundredError, opts, { label: 'HTTP 5XX', statistic: 'sum', color: '#d62728' }),
],
leftAnnotations
});
}
private createLatencyGraphWidget(metric: ApiGatewayMetric, opts?: WatchedOperation) {
return new GraphWidget({
title: `${opts ? `${opts.httpMethod} ${opts.resourcePath}` : 'Overall'} ${metric} (1-minute periods)`,
width: 12,
stacked: false,
left: ['min', 'avg', 'p90', 'p99', 'max'].map(statistic =>
this.createApiGatewayMetric(metric, opts, { label: statistic, statistic })),
});
}
private createCacheGraphWidget(opts?: WatchedOperation) {
return new GraphWidget({
title: `${opts ? `${opts.httpMethod} ${opts.resourcePath}` : 'Overall'} Cache/min`,
width: 12,
stacked: false,
left: [
this.createApiGatewayMetric(ApiGatewayMetric.Count, opts, { label: 'Calls', statistic: 'sum', color: '#1f77b4' }),
this.createApiGatewayMetric(ApiGatewayMetric.CacheHitCount, opts, { label: 'Cache Hit', statistic: 'sum', color: '#2ca02c' }),
this.createApiGatewayMetric(ApiGatewayMetric.CacheMissCount, opts, { label: 'Cache Miss', statistic: 'sum', color: '#d62728' }),
],
});
}