Skip to content

Commit 314ee12

Browse files
authored
Add metric for validation and deployment workflow (#334)
1 parent 676359c commit 314ee12

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

src/artifactexporter/ArtifactExporter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { DocumentType } from '../document/Document';
66
import { parseDocumentContent } from '../document/DocumentUtils';
77
import { S3Service } from '../services/S3Service';
88
import { Artifact } from '../stacks/actions/StackActionRequestType';
9+
import { Measure } from '../telemetry/TelemetryDecorator';
910
import { isS3Url, RESOURCE_EXPORTER_MAP } from './ResourceExporters';
1011

1112
export type ArtifactWithProperty = {
@@ -81,6 +82,7 @@ export class ArtifactExporter {
8182
return artifactMap;
8283
}
8384

85+
@Measure({ name: 'getTemplateArtifacts' })
8486
getTemplateArtifacts(): Artifact[] {
8587
const artifactMap = this.getResourceMapWithArtifact();
8688
const result: Artifact[] = [];
@@ -117,6 +119,7 @@ export class ArtifactExporter {
117119
return result;
118120
}
119121

122+
@Measure({ name: 'exportArtifact' })
120123
async export(bucketName: string, s3KeyPrefix: string = ''): Promise<unknown> {
121124
if (
122125
this.templateDict === undefined ||

src/services/CfnService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import {
6262
import { WaiterConfiguration, WaiterResult } from '@smithy/util-waiter';
6363
import { AwsClientSettings, DefaultSettings } from '../settings/Settings';
6464
import { DeploymentMode } from '../stacks/actions/StackActionRequestType';
65-
import { Count } from '../telemetry/TelemetryDecorator';
65+
import { Count, Measure } from '../telemetry/TelemetryDecorator';
6666
import { AwsClient } from './AwsClient';
6767

6868
export class CfnService {
@@ -174,6 +174,7 @@ export class CfnService {
174174
});
175175
}
176176

177+
@Count({ name: 'detectStackDrift' })
177178
public async detectStackDrift(params: {
178179
StackName: string;
179180
LogicalResourceIds?: string[];
@@ -256,6 +257,7 @@ export class CfnService {
256257
return await this.withClient((client) => client.send(new ListStackResourcesCommand(params)));
257258
}
258259

260+
@Count({ name: 'describeStackResourceDrifts' })
259261
public async describeStackResourceDrifts(params: {
260262
StackName: string;
261263
StackResourceDriftStatusFilters?: StackResourceDriftStatus[];
@@ -337,6 +339,7 @@ export class CfnService {
337339
return await this.withClient((client) => client.send(new DeleteStackCommand(params)));
338340
}
339341

342+
@Measure({ name: 'waitUntilChangeSetCreateComplete' })
340343
public async waitUntilChangeSetCreateComplete(params: DescribeChangeSetCommandInput): Promise<WaiterResult> {
341344
return await this.withClient(async (client) => {
342345
const settings = this.awsClientSettings;
@@ -350,6 +353,7 @@ export class CfnService {
350353
});
351354
}
352355

356+
@Measure({ name: 'waitUntilStackCreateComplete' })
353357
public async waitUntilStackCreateComplete(params: DescribeStacksCommandInput): Promise<WaiterResult> {
354358
return await this.withClient(async (client) => {
355359
const settings = this.awsClientSettings;
@@ -363,6 +367,7 @@ export class CfnService {
363367
});
364368
}
365369

370+
@Measure({ name: 'waitUntilStackUpdateComplete' })
366371
public async waitUntilStackUpdateComplete(params: DescribeStacksCommandInput): Promise<WaiterResult> {
367372
return await this.withClient(async (client) => {
368373
const settings = this.awsClientSettings;
@@ -376,6 +381,7 @@ export class CfnService {
376381
});
377382
}
378383

384+
@Measure({ name: 'waitUntilStackImportComplete' })
379385
public async waitUntilStackImportComplete(params: DescribeStacksCommandInput): Promise<WaiterResult> {
380386
return await this.withClient(async (client) => {
381387
const settings = this.awsClientSettings;
@@ -389,6 +395,7 @@ export class CfnService {
389395
});
390396
}
391397

398+
@Measure({ name: 'waitUntilStackDeleteComplete' })
392399
public async waitUntilStackDeleteComplete(params: DescribeStacksCommandInput): Promise<WaiterResult> {
393400
return await this.withClient(async (client) => {
394401
const settings = this.awsClientSettings;

src/stacks/actions/ChangeSetDeletionWorkflow.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { CfnExternal } from '../../server/CfnExternal';
55
import { CfnInfraCore } from '../../server/CfnInfraCore';
66
import { CfnService } from '../../services/CfnService';
77
import { LoggerFactory } from '../../telemetry/LoggerFactory';
8+
import { Measure } from '../../telemetry/TelemetryDecorator';
89
import { extractErrorMessage } from '../../utils/Errors';
910
import { processWorkflowUpdates, mapChangesToStackChanges, isStackInReview } from './StackActionOperations';
1011
import {
@@ -29,6 +30,7 @@ export class ChangeSetDeletionWorkflow
2930
protected readonly documentManager: DocumentManager,
3031
) {}
3132

33+
@Measure({ name: 'changeSetDeletionWorkflow' })
3234
async start(params: CreateDeploymentParams): Promise<CreateStackActionResult> {
3335
const describeChangeSetResult = await this.cfnService.describeChangeSet({
3436
StackName: params.stackName,

src/stacks/actions/DeploymentWorkflow.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { CfnExternal } from '../../server/CfnExternal';
66
import { CfnInfraCore } from '../../server/CfnInfraCore';
77
import { CfnService } from '../../services/CfnService';
88
import { LoggerFactory } from '../../telemetry/LoggerFactory';
9+
import { Measure } from '../../telemetry/TelemetryDecorator';
910
import { extractErrorMessage } from '../../utils/Errors';
1011
import {
1112
waitForDeployment,
@@ -33,6 +34,7 @@ export class DeploymentWorkflow implements StackActionWorkflow<CreateDeploymentP
3334
protected readonly documentManager: DocumentManager,
3435
) {}
3536

37+
@Measure({ name: 'deploymentWorkflow' })
3638
async start(params: CreateDeploymentParams): Promise<CreateStackActionResult> {
3739
const workflow = {
3840
id: params.id,

src/stacks/actions/ValidationWorkflow.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { CfnService } from '../../services/CfnService';
1010
import { DiagnosticCoordinator } from '../../services/DiagnosticCoordinator';
1111
import { S3Service } from '../../services/S3Service';
1212
import { LoggerFactory } from '../../telemetry/LoggerFactory';
13+
import { Measure } from '../../telemetry/TelemetryDecorator';
1314
import { extractErrorMessage } from '../../utils/Errors';
1415
import {
1516
cleanupReviewStack,
@@ -52,6 +53,7 @@ export class ValidationWorkflow implements StackActionWorkflow<CreateValidationP
5253
protected awsCredentials: AwsCredentials,
5354
) {}
5455

56+
@Measure({ name: 'validationWorkflow' })
5557
async start(params: CreateValidationParams): Promise<CreateStackActionResult> {
5658
// Determine ChangeSet type based on resourcesToImport and stack existence
5759
let changeSetType: ChangeSetType;

0 commit comments

Comments
 (0)