@@ -18,11 +18,27 @@ import {
1818 INLINE_CUSTOM_RESOURCE_CONTEXT ,
1919} from 'aws-cdk-lib/core' ;
2020import { StringSpecializer } from 'aws-cdk-lib/core/lib/helpers-internal' ;
21+ import * as cxapi from 'aws-cdk-lib/cx-api' ;
22+ import { Construct } from 'constructs' ;
2123import { BootstrapRole } from './bootstrap-roles' ;
2224import { FileStagingLocation , IStagingResources , IStagingResourcesFactory , ImageStagingLocation } from './staging-stack' ;
2325
2426export const DEPLOY_TIME_PREFIX = 'deploy-time/' ;
2527
28+ /**
29+ * This is a dummy construct meant to signify that a stack is utilizing
30+ * the AppStagingSynthesizer. It does not do anything, and is not meant
31+ * to be created on its own. This construct will be a part of the
32+ * construct tree only and not the Cfn template. The construct tree is
33+ * then encoded in the AWS::CDK::Metadata resource of the stack and
34+ * injested in our metrics like every other construct.
35+ */
36+ export class UsingAppStagingSynthesizer extends Construct {
37+ constructor ( scope : Construct , id : string ) {
38+ super ( scope , id ) ;
39+ }
40+ }
41+
2642/**
2743 * User configurable options to the DefaultStagingStack.
2844 */
@@ -137,6 +153,12 @@ export class DefaultStagingStack extends Stack implements IStagingResources {
137153 throw new Error ( `Stack ${ stack . stackName } must be part of an App` ) ;
138154 }
139155
156+ // Because we do not keep metrics in the DefaultStagingStack, we will inject
157+ // a dummy construct into the stack using the DefaultStagingStack instead.
158+ if ( cxapi . ANALYTICS_REPORTING_ENABLED_CONTEXT ) {
159+ new UsingAppStagingSynthesizer ( stack , `UsingAppStagingSynthesizer/${ stack . stackName } ` ) ;
160+ }
161+
140162 const stackId = `StagingStack-${ appId } -${ context . environmentString } ` ;
141163 return new DefaultStagingStack ( app , stackId , {
142164 ...options ,
@@ -209,7 +231,10 @@ export class DefaultStagingStack extends Stack implements IStagingResources {
209231 super ( scope , id , {
210232 ...props ,
211233 synthesizer : new BootstraplessSynthesizer ( ) ,
234+ analyticsReporting : false , // removing AWS::CDK::Metadata construct saves ~3KB
212235 } ) ;
236+ // removing path metadata saves ~2KB
237+ this . node . setContext ( cxapi . PATH_METADATA_ENABLE_CONTEXT , false ) ;
213238
214239 // For all resources under the default staging stack, we want to inline custom
215240 // resources because the staging bucket necessary for custom resource assets
0 commit comments