Skip to content

Conversation

@aki-kii
Copy link
Contributor

@aki-kii aki-kii commented Aug 25, 2025

Issue # (if applicable)

Closes #29933 .

Reason for this change

A property in L1 construct was not in L2 construct.

Description of changes

Add enhancedMetricsConfig property to GraphqlApiProps and set in the CfnGraphQLApi constructor.

  • The enhanced Metrics Config now includes the operationLevelMetricsEnabled property, which has changed from an enum of "ENABLED" and "DISABLED" to a boolean.
  • The properties of EnhancedMetricsConfig are not flattened because they interact with each other.
    For example, if operationLevelMetricsConfig is enabled, dataSourceLevelMetricsBehavior will default to PER_DATA_SOURCE_METRICS.

Describe any new or updated permissions being added

Description of how you validated changes

Added both unit and integration tests.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Aug 25, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team August 25, 2025 17:00
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Aug 25, 2025
@aki-kii aki-kii force-pushed the appsync-graphqlapi-enhanced-metrics branch from 6566b24 to d62f669 Compare August 26, 2025 00:31
Copy link
Contributor

@mazyu36 mazyu36 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution.
Before reviewing the details, let me confirm.
Don’t we need to add the metricConfig property to Resolver and DataSource?
If the API’s config is set to per-resolver metrics, I think the resolver’s config is also needed.

https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-appsync-datasource.html#cfn-appsync-datasource-metricsconfig

https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-appsync-resolver.html#cfn-appsync-resolver-metricsconfig

@mazyu36
Copy link
Contributor

mazyu36 commented Aug 26, 2025

There’s an existing issue, please associate it.

#29933

Copy link
Contributor

@badmintoncryer badmintoncryer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for you contribution! I've added some minor comments.

});

api.addNoneDataSource('NoneDS', {
name: cdk.Lazy.string({ produce(): string { return 'NoneDS'; } }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it necessary to use Lazy here? 

Copy link
Contributor Author

@aki-kii aki-kii Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@badmintoncryer
Thanks.
Thinking it over again, I found I didn't need to use Lazy.

new appsync.GraphqlApi(stack, 'minimal-enhanced-metrics', {
name: 'enhanced-metrics',
schema: appsync.SchemaFile.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
enhancedMetricsConfig: {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do other constructs also have arguments where we can pass {} like this?
Personally, I feel that having settings activated as a result of passing {} is not very intuitive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that the appsync.GraphqlApi.logConfig property was passing {}, but I think also passing {} is not very intuitive.

Suggest requiring the dataSourceLevelMetricsBehavior and resolverLevelMetricsBehavior property, because after setting those property the behavior changes.

ex)

EnhancedMetricsConfig {
  readonly dataSourceLevelMetricsBehavior: DataSourceLevelMetricsBehavior;
  readonly operationLevelMetricsEnabled?: boolean;
  readonly resolverLevelMetricsBehavior: ResolverLevelMetricsBehavior;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the existing arguments can also accept empty objects! In that case, I don’t think it’s a big issue, so please feel free to implement it in whichever way you prefer!

Copy link
Contributor Author

@aki-kii aki-kii Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@badmintoncryer
Implemented dataSourceLevelMetricsBehavior and resolverLevelMetricsBehavior as required properties.

@aki-kii
Copy link
Contributor Author

aki-kii commented Aug 26, 2025

Thank you for the contribution. Before reviewing the details, let me confirm. Don’t we need to add the metricConfig property to Resolver and DataSource? If the API’s config is set to per-resolver metrics, I think the resolver’s config is also needed.

https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-appsync-datasource.html#cfn-appsync-datasource-metricsconfig

https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-appsync-resolver.html#cfn-appsync-resolver-metricsconfig

@mazyu36
Thinking it over again, I believe metricConfig property of DataSource and Resolver are necessary.
I’ll go implement those properties.

@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. labels Aug 26, 2025
@aki-kii aki-kii changed the title feat(appsync): add EnhancedMetricsConfigProperty for graphql api feat(appsync): add EnhancedMetricsConfigProperty for graphql api #29933 Aug 26, 2025
@aki-kii aki-kii changed the title feat(appsync): add EnhancedMetricsConfigProperty for graphql api #29933 feat(appsync): add EnhancedMetricsConfigProperty for graphql api Aug 26, 2025
@aki-kii
Copy link
Contributor Author

aki-kii commented Aug 26, 2025

There’s an existing issue, please associate it.

#29933

@mazyu36
Sorry. I've associated the issue.

@aki-kii aki-kii force-pushed the appsync-graphqlapi-enhanced-metrics branch from a2a41a7 to d8b65ca Compare August 30, 2025 12:44
@aki-kii aki-kii force-pushed the appsync-graphqlapi-enhanced-metrics branch from d8b65ca to af5940a Compare September 2, 2025 01:35
@aki-kii aki-kii force-pushed the appsync-graphqlapi-enhanced-metrics branch from af5940a to 4b19182 Compare September 2, 2025 01:38
@aki-kii aki-kii force-pushed the appsync-graphqlapi-enhanced-metrics branch from 02248fb to 3f4abf1 Compare September 4, 2025 17:07
@aki-kii aki-kii changed the title feat(appsync): add EnhancedMetricsConfigProperty for graphql api feat(appsync): add EnhancedMetricsConfigProperty for GraphQL api Sep 12, 2025
Copy link
Contributor

@badmintoncryer badmintoncryer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've added some minor comments.

@aki-kii
Copy link
Contributor Author

aki-kii commented Sep 23, 2025

Thanks! I've added some minor comments.

Thanks!
I understand and accept your suggestion.

Copy link
Contributor

@badmintoncryer badmintoncryer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 23, 2025
@kumsmrit kumsmrit self-assigned this Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-appsync): Add Enhanced Metrics configuration to CDK

5 participants