Skip to content

Commit

Permalink
[Java/Log] Update log validation + bump mysql version (aws-observabil…
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry-shao authored Sep 23, 2024
1 parent 47f57f2 commit aef00ab
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
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);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"default": {
"EC2.AutoScalingGroup": "^eks-.+",
"EKS.Cluster": "^{{platformInfo}}$",
"K8s.Namespace": "^{{appNamespace}}",
"otel.resource.K8s.Workload": "^sample-app-deployment-{{testingId}}",
"K8s.Namespace": "^{{appNamespace}}$",
"otel.resource.K8s.Workload": "^sample-app-deployment-{{testingId}}$",
"otel.resource.K8s.Node": "^i-[A-Za-z0-9]{17}$",
"otel.resource.K8s.Pod": "^sample-app-deployment-{{testingId}}(-[A-Za-z0-9]*)*$",
"otel.resource.host.name": "^ip(-[0-9]{1,3}){4}.*$",
Expand All @@ -50,6 +50,12 @@
"aws.local.operation": "^GET /mysql$"
},
"subsegments": [
{
"name": "^mysql$",
"sql": {
"url": "^Create connection$"
}
},
{
"name": "^mysql$",
"sql": {
Expand All @@ -61,7 +67,7 @@
"aws.remote.operation": "^SELECT$",
"aws.local.operation": "^GET /mysql$",
"aws.remote.resource.type": "^DB::Connection$",
"aws.remote.resource.identifier": "{{remoteResourceIdentifier}}",
"aws.remote.resource.identifier": "^{{remoteResourceIdentifier}}$",
"aws.remote.service": "^mysql$",
"aws.local.service": "^{{serviceName}}$",
"aws.local.environment": "^eks:{{platformInfo}}/{{appNamespace}}$"
Expand All @@ -83,4 +89,4 @@
}
]
}
]
]

0 comments on commit aef00ab

Please sign in to comment.