Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding remote resources upgrading mysql #190

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sample-apps/springboot/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies {
implementation("io.opentelemetry:opentelemetry-api:1.34.1")
implementation("software.amazon.awssdk:s3")
implementation("software.amazon.awssdk:sts")
implementation("com.mysql:mysql-connector-j:8.0.33")
implementation("com.mysql:mysql-connector-j:8.4.0")
}

jib {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ public void validate() throws Exception {
String operation = (String) expectedAttributes.get("Operation");
String remoteService = (String) expectedAttributes.get("RemoteService");
String remoteOperation = (String) expectedAttributes.get("RemoteOperation");
String remoteResourceType = (String) expectedAttributes.get("RemoteResourceType");
String remoteResourceIdentifier = (String) expectedAttributes.get("RemoteResourceIdentifier");

Map<String, Object> actualLog =
this.getActualLog(operation, remoteService, remoteOperation);
this.getActualLog(operation, remoteService, remoteOperation, remoteResourceType, remoteResourceIdentifier);
log.info("Value of an actual log: {}", actualLog);

if (actualLog == null) throw new BaseException(ExceptionCode.EXPECTED_LOG_NOT_FOUND);
Expand Down Expand Up @@ -126,7 +128,7 @@ private JsonifyArrayList<Map<String, Object>> getExpectedAttributes() throws Exc
}

private Map<String, Object> getActualLog(
String operation, String remoteService, String remoteOperation) throws Exception {
String operation, String remoteService, String remoteOperation, String remoteResourceType, String remoteResourceIdentifier) throws Exception {
String dependencyFilter = null;

// Dependency calls will have the remoteService and remoteOperation attribute, but service calls
Expand All @@ -139,6 +141,10 @@ private Map<String, Object> getActualLog(
dependencyFilter = String.format("&& ($.RemoteService = \"%s\") && ($.RemoteOperation = \"%s\")", remoteService, remoteOperation);
}

if (remoteResourceType != null && remoteResourceIdentifier != null) {
dependencyFilter += String.format(" && ($.RemoteResourceType = %%%s%%) && ($.RemoteResourceIdentifier = %%%s%%)", remoteResourceType, remoteResourceIdentifier);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we expect to be searching with the value directly, we can likely just remove the ^...$ RegEx symbols in the validation templates and remove the need for RegEx here altogether. Not a 100% necessary change but doing so will improve the search time by filtering for the exact string instead of a RegEx pattern.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey Mahad, we shouldn't expect the same value for either remoteResourceType or remoteResourceIdentifier. You can verify this in the following run: GitHub Workflow Run.

  1. The /aws-sdk-call API shows different values.
  2. The /mysql API also has different values.

I believe these values can't be static since some of them are concatenated into a string only during runtime. Let me know if I've missed anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @ektabj

I think Mahad suggests to not use regex here.

As you can see, we are not using regex for RemoteResourceType in the template.
For RemoteResourceIdentifier, we can change the value from ^{{remoteResourceIdentifier}}$ to {{remoteResourceIdentifier}} in the template.

Template: https://github.com/aws-observability/aws-application-signals-test-framework/blob/main/validator/src/main/resources/expected-data-template/java/eks/rds-mysql-log.mustache#L34-L35

}

String filterPattern = String.format("{ ($.Service = %s) && ($.Operation = \"%s\") %s }", context.getServiceName(), operation, dependencyFilter);
log.info("Filter Pattern for Log Search: " + filterPattern);

Expand Down