From 58ed75661faf553a8350809e6c587bb58074b313 Mon Sep 17 00:00:00 2001 From: Alexander Krause Date: Mon, 8 Apr 2024 15:06:27 +0200 Subject: [PATCH 01/27] update to new LTS --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index ce97b22..174722c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,10 @@ #Gradle properties #Thu Apr 20 09:07:19 CEST 2023 #quarkusPluginVersion=3.2.9.Final -quarkusPluginVersion=3.6.4 +quarkusPluginVersion=3.8.3 quarkusPlatformArtifactId=quarkus-bom quarkusPluginId=io.quarkus quarkusPlatformGroupId=io.quarkus.platform #quarkusPlatformVersion=3.2.9.Final -quarkusPlatformVersion=3.6.4 +quarkusPlatformVersion=3.8.3 confluentAvroSerdeVersion=7.3.3 From 43df6c43b6e95a2e1593f82fe7fc548bed950df9 Mon Sep 17 00:00:00 2001 From: Alexander Krause Date: Tue, 9 Apr 2024 11:10:39 +0200 Subject: [PATCH 02/27] insert git_commit_checksum in database and payload + testing --- .../span/api/LandscapeResourceIt.java | 70 ++++++++++++++++--- .../span/api/TimestampResourceIt.java | 10 +-- .../span/persistence/TraceLoaderIt.java | 9 ++- src/main/avro/ExplorvizProtocol.avdl | 1 + .../explorviz/span/api/LandscapeResource.java | 1 + .../span/persistence/PersistenceSpan.java | 1 + .../persistence/PersistenceSpanProcessor.java | 6 +- .../span/persistence/SpanConverter.java | 3 +- .../java/net/explorviz/span/trace/Trace.java | 4 +- src/main/resources/init_script.cql | 1 + 10 files changed, 86 insertions(+), 20 deletions(-) diff --git a/src/integrationTest/java/net/explorviz/span/api/LandscapeResourceIt.java b/src/integrationTest/java/net/explorviz/span/api/LandscapeResourceIt.java index 92e8ad1..45898c9 100644 --- a/src/integrationTest/java/net/explorviz/span/api/LandscapeResourceIt.java +++ b/src/integrationTest/java/net/explorviz/span/api/LandscapeResourceIt.java @@ -7,6 +7,7 @@ import io.quarkus.test.junit.QuarkusTest; import io.restassured.response.Response; import jakarta.inject.Inject; +import java.util.Arrays; import java.util.List; import java.util.UUID; import net.explorviz.span.kafka.KafkaTestResource; @@ -14,6 +15,7 @@ import net.explorviz.span.landscape.Method; import net.explorviz.span.persistence.PersistenceSpan; import net.explorviz.span.persistence.PersistenceSpanProcessor; +import net.explorviz.span.trace.Trace; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -25,6 +27,8 @@ public class LandscapeResourceIt { @Inject PersistenceSpanProcessor spanProcessor; + final String gitCommitChecksum = "testGitCommitChecksum"; + @Test void testLoadAllStructureSpans() { final long startEarly = 1701081827000L; @@ -37,21 +41,21 @@ void testLoadAllStructureSpans() { final UUID uuidExpected = UUID.randomUUID(); final PersistenceSpan differentTokenSpan = new PersistenceSpan( - UUID.randomUUID(), "123L", "", "1L", startEarly, + UUID.randomUUID(), gitCommitChecksum, "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); final String duplicateMethodName = "myMethodName()"; final String otherMethodName = "myOtherMethodName()"; - final PersistenceSpan firstOccurenceSpan = new PersistenceSpan(uuidExpected, + final PersistenceSpan firstOccurenceSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); - final PersistenceSpan secondOccurenceSpan = new PersistenceSpan(uuidExpected, + final PersistenceSpan secondOccurenceSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, "789L", "", "3L", startLate, endLate, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); - final PersistenceSpan otherSpan = new PersistenceSpan(uuidExpected, "456L", + final PersistenceSpan otherSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, "456L", "0L", "", startExpected, endExpected, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + otherMethodName, "321"); @@ -85,21 +89,21 @@ void testLoadStructureSpansByTimeRange() { final UUID uuidExpected = UUID.randomUUID(); final PersistenceSpan differentTokenSpan = new PersistenceSpan( - UUID.randomUUID(), "123L", "", "1L", startEarly, + UUID.randomUUID(), gitCommitChecksum, "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); final String duplicateMethodName = "myMethodName()"; final String otherMethodName = "myOtherMethodName()"; - final PersistenceSpan firstOccurenceSpan = new PersistenceSpan(uuidExpected, + final PersistenceSpan firstOccurenceSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); - final PersistenceSpan secondOccurenceSpan = new PersistenceSpan(uuidExpected, + final PersistenceSpan secondOccurenceSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, "789L", "", "3L", startLate, endLate, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); - final PersistenceSpan otherSpan = new PersistenceSpan(uuidExpected, "456L", + final PersistenceSpan otherSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, "456L", "", "2L", startExpected, endExpected, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + otherMethodName, "321"); @@ -124,4 +128,54 @@ void testLoadStructureSpansByTimeRange() { Assertions.assertEquals(otherMethodName, resultMethodList.get(0).name()); } + @Test + void testLoadTracesByTimeRange() { + final long startEarly = 1701081837000L; + final long endEarly = 1701081838000L; + final long startExpected = 1701081840000L; + final long endExpected = 1701081841000L; + final long startLate = 1701081843000L; + final long endLate = 1701081844000L; + + final UUID uuidExpected = UUID.randomUUID(); + + final PersistenceSpan differentTokenSpan = new PersistenceSpan( + UUID.randomUUID(), gitCommitChecksum, "123L", "", "1L", startEarly, + endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); + + final String duplicateMethodName = "myMethodName()"; + final String otherMethodName = "myOtherMethodName()"; + + final PersistenceSpan firstOccurenceSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, + "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, + "net.explorviz.Class." + duplicateMethodName, "847"); + + final PersistenceSpan secondOccurenceSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, + "789L", "", "3L", startLate, endLate, "nodeIp", "app-name", "java", 0, + "net.explorviz.Class." + duplicateMethodName, "847"); + + final PersistenceSpan otherSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, "456L", + "", "2L", startExpected, endExpected, "nodeIp", "app-name", "java", 0, + "net.explorviz.Class." + otherMethodName, "321"); + + spanProcessor.accept(differentTokenSpan); + spanProcessor.accept(firstOccurenceSpan); + spanProcessor.accept(secondOccurenceSpan); + spanProcessor.accept(otherSpan); + + final long from = startExpected; + final long to = endExpected; + + final Response response = given().pathParam("token", uuidExpected) + .queryParam("from", from).queryParam("to", to).when() + .get("/v2/landscapes/{token}/dynamic"); + + final Trace[] result = response.getBody().as(Trace[].class); + + + // ATTENTION: For the moment, we only filter based on the starting point of traces + Assertions.assertEquals(2, result.length); + Assertions.assertEquals(gitCommitChecksum, result[0].gitCommitChecksum()); + } + } diff --git a/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java b/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java index d26ffe7..0dc1c22 100644 --- a/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java +++ b/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java @@ -26,6 +26,8 @@ public class TimestampResourceIt { @Inject PersistenceSpanProcessor spanProcessor; + final String gitCommitChecksum = "testGitCommitChecksum"; + @Test void testLoadAllTimestampsForToken() { final long startEarly = 1702545564404L; @@ -38,7 +40,7 @@ void testLoadAllTimestampsForToken() { final UUID uuidExpected = UUID.randomUUID(); final PersistenceSpan differentTokenSpan = - new PersistenceSpan(UUID.randomUUID(), "123L", "", + new PersistenceSpan(UUID.randomUUID(), gitCommitChecksum, "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); @@ -46,15 +48,15 @@ void testLoadAllTimestampsForToken() { final String otherMethodName = "myOtherMethodName()"; final PersistenceSpan firstOccurenceSpan = - new PersistenceSpan(uuidExpected, "123L", "", "1L", startEarly, endEarly, + new PersistenceSpan(uuidExpected, gitCommitChecksum, "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan secondOccurenceSpan = - new PersistenceSpan(uuidExpected, "789L", "", "3L", startLate, endLate, + new PersistenceSpan(uuidExpected, gitCommitChecksum, "789L", "", "3L", startLate, endLate, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan otherSpan = - new PersistenceSpan(uuidExpected, "456L", "0L", "", startExpected, + new PersistenceSpan(uuidExpected, gitCommitChecksum, "456L", "0L", "", startExpected, endExpected, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + otherMethodName, "321"); diff --git a/src/integrationTest/java/net/explorviz/span/persistence/TraceLoaderIt.java b/src/integrationTest/java/net/explorviz/span/persistence/TraceLoaderIt.java index 5922cf9..fc67546 100644 --- a/src/integrationTest/java/net/explorviz/span/persistence/TraceLoaderIt.java +++ b/src/integrationTest/java/net/explorviz/span/persistence/TraceLoaderIt.java @@ -41,18 +41,20 @@ void testLoadTracesByTimeRange() { final UUID landscapeToken = UUID.randomUUID(); + final String gitCommitChecksum = "testGitCommitChecksum"; + final PersistenceSpan earlySpan = - new PersistenceSpan(landscapeToken, "123L", "", "1L", startEarly, + new PersistenceSpan(landscapeToken, gitCommitChecksum, "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); final PersistenceSpan expectedSpan = - new PersistenceSpan(landscapeToken, "456L", "", "2L", startExpected, + new PersistenceSpan(landscapeToken, gitCommitChecksum,"456L", "", "2L", startExpected, endExpected, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); final PersistenceSpan lateSpan = - new PersistenceSpan(landscapeToken, "789L", "", "3L", startLate, + new PersistenceSpan(landscapeToken, gitCommitChecksum,"789L", "", "3L", startLate, endLate, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); @@ -65,6 +67,7 @@ void testLoadTracesByTimeRange() { .await().indefinitely(); Assertions.assertEquals(1, result.size(), "List of traces has wrong size."); + Assertions.assertEquals(9, result.get(0).getClass().getDeclaredFields().length, "Trace has wrong number of fields."); Assertions.assertEquals(1, result.get(0).spanList().size(), "List of spans has wrong size."); Assertions.assertEquals(convertPersistenceSpanToSpan(expectedSpan), result.get(0).spanList().get(0), "Wrong span in trace."); diff --git a/src/main/avro/ExplorvizProtocol.avdl b/src/main/avro/ExplorvizProtocol.avdl index 4626924..d9d4d5d 100644 --- a/src/main/avro/ExplorvizProtocol.avdl +++ b/src/main/avro/ExplorvizProtocol.avdl @@ -24,6 +24,7 @@ protocol ExplorvizProtocol { record Span { string landscapeToken; + string gitCommitChecksum; string spanId; string parentSpanId; string traceId; diff --git a/src/main/java/net/explorviz/span/api/LandscapeResource.java b/src/main/java/net/explorviz/span/api/LandscapeResource.java index f10c62a..d933a85 100644 --- a/src/main/java/net/explorviz/span/api/LandscapeResource.java +++ b/src/main/java/net/explorviz/span/api/LandscapeResource.java @@ -91,6 +91,7 @@ public Multi getDynamic(@PathParam("token") final String token, return traceLoader.loadAllTraces(parseUuid(token)); } + // ATTENTION: For the moment, we only filter based on the starting point of traces return traceLoader.loadTracesStartingInRange(parseUuid(token), from); } diff --git a/src/main/java/net/explorviz/span/persistence/PersistenceSpan.java b/src/main/java/net/explorviz/span/persistence/PersistenceSpan.java index 305fe1c..8fab018 100644 --- a/src/main/java/net/explorviz/span/persistence/PersistenceSpan.java +++ b/src/main/java/net/explorviz/span/persistence/PersistenceSpan.java @@ -4,6 +4,7 @@ public record PersistenceSpan( UUID landscapeToken, + String gitCommitChecksum, String spanId, String parentSpanId, String traceId, diff --git a/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java b/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java index 6e35a36..30cef63 100644 --- a/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java +++ b/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java @@ -55,8 +55,8 @@ public PersistenceSpanProcessor(final QuarkusCqlSession session) { + "(landscape_token, method_hash, time_bucket, trace_id) " + "VALUES (?, ?, ?, ?)");*/ this.insertTraceByTimeStatement = session.prepare("INSERT INTO trace_by_time " - + "(landscape_token, tenth_second_epoch, start_time, end_time, trace_id) " - + "VALUES (?, ?, ?, ?, ?)"); + + "(landscape_token, git_commit_checksum, tenth_second_epoch, start_time, end_time, trace_id) " + + "VALUES (?, ?, ?, ?, ?, ?)"); this.insertSpanStructureStatement = session.prepare("INSERT INTO span_structure " + "(landscape_token, method_hash, node_ip_address, application_name, application_language, " + "application_instance, method_fqn, time_seen) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?) " @@ -168,7 +168,7 @@ private void insertTrace(final PersistenceSpan span) { final long tenSecondBucket = span.startTime() - (span.startTime() % 10_000); final BoundStatement stmtByTime = - insertTraceByTimeStatement.bind(span.landscapeToken(), tenSecondBucket, + insertTraceByTimeStatement.bind(span.landscapeToken(), span.gitCommitChecksum(), tenSecondBucket, span.startTime(), span.endTime(), span.traceId()); session.executeAsync(stmtByTime).whenComplete((result, failure) -> { diff --git a/src/main/java/net/explorviz/span/persistence/SpanConverter.java b/src/main/java/net/explorviz/span/persistence/SpanConverter.java index 00e924e..1ac2cc6 100644 --- a/src/main/java/net/explorviz/span/persistence/SpanConverter.java +++ b/src/main/java/net/explorviz/span/persistence/SpanConverter.java @@ -12,6 +12,7 @@ public class SpanConverter implements ValueMapper { @Override public PersistenceSpan apply(final Span span) { final String landscapeTokenRaw = span.getLandscapeToken(); + final String gitCommitChecksum = span.getGitCommitChecksum(); // TODO: Remove invalid UUID hotfix UUID landscapeToken = PersistenceSpan.DEFAULT_UUID; if (!"mytokenvalue".equals(landscapeTokenRaw)) { @@ -30,7 +31,7 @@ public PersistenceSpan apply(final Span span) { HashHelper.calculateSpanHash(landscapeToken, nodeIpAddress, applicationName, applicationInstance, methodFqn); - return new PersistenceSpan(landscapeToken, span.getSpanId(), span.getParentSpanId(), + return new PersistenceSpan(landscapeToken, gitCommitChecksum, span.getSpanId(), span.getParentSpanId(), span.getTraceId(), startTime, endTime, nodeIpAddress, applicationName, applicationLanguage, applicationInstance, methodFqn, methodHashCode); diff --git a/src/main/java/net/explorviz/span/trace/Trace.java b/src/main/java/net/explorviz/span/trace/Trace.java index 5cfbe94..edc6f7e 100644 --- a/src/main/java/net/explorviz/span/trace/Trace.java +++ b/src/main/java/net/explorviz/span/trace/Trace.java @@ -10,6 +10,7 @@ public record Trace( UUID landscapeToken, String traceId, + String gitCommitChecksum, long startTime, long endTime, long duration, // TODO: Pointless? @@ -21,6 +22,7 @@ public record Trace( public static Trace fromRow(final Row row) { final UUID landscapeToken = row.getUuid("landscape_token"); final String traceId = row.getString("trace_id"); + final String gitCommitChecksum = row.getString("git_commit_checksum"); // TODO: Remove millisecond/nanosecond mismatch hotfix final long startTime = row.getLong("start_time"); final long endTime = row.getLong("end_time"); @@ -29,7 +31,7 @@ public static Trace fromRow(final Row row) { final int traceCount = 1; final List spanList = new ArrayList<>(); - return new Trace(landscapeToken, traceId, startTime, endTime, duration, overallRequestCount, + return new Trace(landscapeToken, traceId, gitCommitChecksum, startTime, endTime, duration, overallRequestCount, traceCount, spanList); } diff --git a/src/main/resources/init_script.cql b/src/main/resources/init_script.cql index e22e8f0..da8d8ca 100644 --- a/src/main/resources/init_script.cql +++ b/src/main/resources/init_script.cql @@ -55,6 +55,7 @@ CREATE TABLE IF NOT EXISTS explorviz.trace_by_hash CREATE TABLE IF NOT EXISTS explorviz.trace_by_time ( landscape_token uuid, + git_commit_checksum text, tenth_second_epoch bigint, start_time bigint, end_time bigint, From f24edc9d827ddea6abe21fb94d39f78af826bf91 Mon Sep 17 00:00:00 2001 From: Alexander Krause Date: Tue, 9 Apr 2024 11:57:35 +0200 Subject: [PATCH 03/27] qa --- .../span/persistence/PersistenceSpanProcessor.java | 10 ++++++---- .../net/explorviz/span/persistence/SpanConverter.java | 3 ++- src/main/java/net/explorviz/span/trace/Trace.java | 5 ++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java b/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java index 30cef63..60d62da 100644 --- a/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java +++ b/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java @@ -55,14 +55,15 @@ public PersistenceSpanProcessor(final QuarkusCqlSession session) { + "(landscape_token, method_hash, time_bucket, trace_id) " + "VALUES (?, ?, ?, ?)");*/ this.insertTraceByTimeStatement = session.prepare("INSERT INTO trace_by_time " - + "(landscape_token, git_commit_checksum, tenth_second_epoch, start_time, end_time, trace_id) " + + "(landscape_token, git_commit_checksum, tenth_second_epoch, " + + "start_time, end_time, trace_id) " + "VALUES (?, ?, ?, ?, ?, ?)"); this.insertSpanStructureStatement = session.prepare("INSERT INTO span_structure " + "(landscape_token, method_hash, node_ip_address, application_name, application_language, " + "application_instance, method_fqn, time_seen) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?) " + "USING TIMESTAMP ?"); - this.updateSpanBucketCounter = session.prepare("UPDATE span_count_per_time_bucket_and_token " - + "SET span_count = span_count + 1 " + this.updateSpanBucketCounter = session.prepare("UPDATE " + + "span_count_per_time_bucket_and_token SET span_count = span_count + 1 " + "WHERE landscape_token = ? AND tenth_second_epoch = ?"); } @@ -168,7 +169,8 @@ private void insertTrace(final PersistenceSpan span) { final long tenSecondBucket = span.startTime() - (span.startTime() % 10_000); final BoundStatement stmtByTime = - insertTraceByTimeStatement.bind(span.landscapeToken(), span.gitCommitChecksum(), tenSecondBucket, + insertTraceByTimeStatement.bind(span.landscapeToken(), span.gitCommitChecksum(), + tenSecondBucket, span.startTime(), span.endTime(), span.traceId()); session.executeAsync(stmtByTime).whenComplete((result, failure) -> { diff --git a/src/main/java/net/explorviz/span/persistence/SpanConverter.java b/src/main/java/net/explorviz/span/persistence/SpanConverter.java index 1ac2cc6..824d20a 100644 --- a/src/main/java/net/explorviz/span/persistence/SpanConverter.java +++ b/src/main/java/net/explorviz/span/persistence/SpanConverter.java @@ -31,7 +31,8 @@ public PersistenceSpan apply(final Span span) { HashHelper.calculateSpanHash(landscapeToken, nodeIpAddress, applicationName, applicationInstance, methodFqn); - return new PersistenceSpan(landscapeToken, gitCommitChecksum, span.getSpanId(), span.getParentSpanId(), + return new PersistenceSpan(landscapeToken, gitCommitChecksum, span.getSpanId(), + span.getParentSpanId(), span.getTraceId(), startTime, endTime, nodeIpAddress, applicationName, applicationLanguage, applicationInstance, methodFqn, methodHashCode); diff --git a/src/main/java/net/explorviz/span/trace/Trace.java b/src/main/java/net/explorviz/span/trace/Trace.java index edc6f7e..8166028 100644 --- a/src/main/java/net/explorviz/span/trace/Trace.java +++ b/src/main/java/net/explorviz/span/trace/Trace.java @@ -2,9 +2,7 @@ import com.datastax.oss.driver.api.core.cql.Row; import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import java.util.Optional; import java.util.UUID; public record Trace( @@ -31,7 +29,8 @@ public static Trace fromRow(final Row row) { final int traceCount = 1; final List spanList = new ArrayList<>(); - return new Trace(landscapeToken, traceId, gitCommitChecksum, startTime, endTime, duration, overallRequestCount, + return new Trace(landscapeToken, traceId, gitCommitChecksum, startTime, endTime, duration, + overallRequestCount, traceCount, spanList); } From e44bde6fa6c777bb93c738b5a1fd380a61d44ed9 Mon Sep 17 00:00:00 2001 From: Alexander Krause Date: Wed, 10 Apr 2024 19:45:06 +0200 Subject: [PATCH 04/27] wip: timestamp filtering based on epoch or commit (+ epoch) --- .../span/api/TimestampResourceIt.java | 2 + .../explorviz/span/api/TimestampResource.java | 17 +++++-- .../persistence/PersistenceSpanProcessor.java | 14 +++++- .../span/timestamp/TimestampLoader.java | 49 ++++++++++++++++--- src/main/resources/init_script.cql | 8 +++ 5 files changed, 77 insertions(+), 13 deletions(-) diff --git a/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java b/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java index 0dc1c22..f2e56a9 100644 --- a/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java +++ b/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java @@ -68,6 +68,8 @@ void testLoadAllTimestampsForToken() { final Response response = given().pathParam("token", uuidExpected).when() .get("/v2/landscapes/{token}/timestamps"); + System.out.println("ALEX HIER: " + response.getBody().asPrettyString()); + final List resultList = response.getBody().as(new TypeRef>() { }); diff --git a/src/main/java/net/explorviz/span/api/TimestampResource.java b/src/main/java/net/explorviz/span/api/TimestampResource.java index f0a55c0..ace1938 100644 --- a/src/main/java/net/explorviz/span/api/TimestampResource.java +++ b/src/main/java/net/explorviz/span/api/TimestampResource.java @@ -9,28 +9,37 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.QueryParam; import jakarta.ws.rs.core.MediaType; +import java.util.Optional; import java.util.UUID; import net.explorviz.span.persistence.PersistenceSpan; import net.explorviz.span.timestamp.Timestamp; import net.explorviz.span.timestamp.TimestampLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Path("/v2/landscapes") @Produces(MediaType.APPLICATION_JSON) public class TimestampResource { + private static final Logger LOGGER = LoggerFactory.getLogger(TimestampResource.class); + @Inject TimestampLoader timestampLoader; @GET @Path("/{token}/timestamps") - public Multi getStructure(@PathParam("token") final String token, - @QueryParam("newest") final long newest, @QueryParam("oldest") final long oldest) { + public Multi getTimestamps(@PathParam("token") final String token, + @QueryParam("newest") final long newest, @QueryParam("oldest") final long oldest, + @QueryParam("commit") final Optional commit) { + LOGGER.atInfo().addArgument(token).addArgument(commit.orElse("all-commits")) + .log("Loading all timestamps for token {} and commit {}"); + if (newest == 0 && oldest == 0) { - return this.timestampLoader.loadAllTimestampsForToken(parseUuid(token)); + return this.timestampLoader.loadAllTimestampsForToken(parseUuid(token), commit); } if (newest != 0) { - return this.timestampLoader.loadNewerTimestampsForToken(parseUuid(token), newest); + return this.timestampLoader.loadNewerTimestampsForToken(parseUuid(token), newest, commit); } return Multi.createFrom().empty(); } diff --git a/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java b/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java index 60d62da..c182549 100644 --- a/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java +++ b/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java @@ -38,6 +38,8 @@ public class PersistenceSpanProcessor implements Consumer { private final PreparedStatement insertTraceByTimeStatement; private final PreparedStatement insertSpanStructureStatement; private final PreparedStatement updateSpanBucketCounter; + private final PreparedStatement updateSpanBucketCounterForCommits; + @Inject public PersistenceSpanProcessor(final QuarkusCqlSession session) { @@ -65,6 +67,9 @@ public PersistenceSpanProcessor(final QuarkusCqlSession session) { this.updateSpanBucketCounter = session.prepare("UPDATE " + "span_count_per_time_bucket_and_token SET span_count = span_count + 1 " + "WHERE landscape_token = ? AND tenth_second_epoch = ?"); + this.updateSpanBucketCounterForCommits = session.prepare("UPDATE " + + "span_count_for_token_and_commit_and_time_bucket SET span_count = span_count + 1 " + + "WHERE landscape_token = ? AND git_commit_checksum = ? AND tenth_second_epoch = ?"); } @Override @@ -94,10 +99,17 @@ public void accept(final PersistenceSpan span) { private void updateSpanBucketCounter(final PersistenceSpan span) { final long tenSecondBucket = span.startTime() - (span.startTime() % 10_000); - final BoundStatement updateStmt = + BoundStatement updateStmt = this.updateSpanBucketCounter.bind(span.landscapeToken(), tenSecondBucket); this.session.executeAsync(updateStmt); + + updateStmt = + this.updateSpanBucketCounterForCommits.bind(span.landscapeToken(), span.gitCommitChecksum(), + tenSecondBucket + ); + + this.session.executeAsync(updateStmt); } diff --git a/src/main/java/net/explorviz/span/timestamp/TimestampLoader.java b/src/main/java/net/explorviz/span/timestamp/TimestampLoader.java index 1c774dd..37fe37a 100644 --- a/src/main/java/net/explorviz/span/timestamp/TimestampLoader.java +++ b/src/main/java/net/explorviz/span/timestamp/TimestampLoader.java @@ -5,6 +5,7 @@ import io.smallrye.mutiny.Multi; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; +import java.util.Optional; import java.util.UUID; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,7 +18,9 @@ public class TimestampLoader { private final QuarkusCqlSession session; private final PreparedStatement selectAllTimestampsForToken; + private final PreparedStatement selectAllTimestampsForTokenAndCommit; private final PreparedStatement selectNewerTimestampsForToken; + private final PreparedStatement selectNewerTimestampsForTokenAndCommit; @Inject public TimestampLoader(final QuarkusCqlSession session) { @@ -30,20 +33,50 @@ public TimestampLoader(final QuarkusCqlSession session) { this.selectNewerTimestampsForToken = session.prepare( "SELECT * " + "FROM span_count_per_time_bucket_and_token " + "WHERE landscape_token = ? AND tenth_second_epoch > ?"); + + this.selectAllTimestampsForTokenAndCommit = session.prepare( + "SELECT * " + "FROM span_count_for_token_and_commit_and_time_bucket " + + "WHERE landscape_token = ? AND git_commit_checksum = ?"); + + this.selectNewerTimestampsForTokenAndCommit = session.prepare( + "SELECT * " + "FROM span_count_for_token_and_commit_and_time_bucket " + + "WHERE landscape_token = ? AND git_commit_checksum = ? AND " + + "tenth_second_epoch > ?"); } - public Multi loadAllTimestampsForToken(final UUID landscapeToken) { - LOGGER.atTrace().addArgument(landscapeToken).log("Loading all timestamps for token {}"); + public Multi loadAllTimestampsForToken(final UUID landscapeToken, + final Optional commit) { + System.out.println("ALEX DA: " + commit.orElse("all-commits") + " " + commit.isPresent()); + LOGGER.atTrace().addArgument(landscapeToken).addArgument(commit.orElse("all-commits")) + .log("Loading all timestamps for token {} and commit {}"); - return session.executeReactive(this.selectAllTimestampsForToken.bind(landscapeToken)) - .map(Timestamp::fromRow); + if (commit.isPresent()) { + return session.executeReactive( + this.selectAllTimestampsForTokenAndCommit.bind(landscapeToken, commit.get())) + .map(Timestamp::fromRow); + } else { + return session.executeReactive(this.selectAllTimestampsForToken.bind(landscapeToken)) + .map(Timestamp::fromRow); + } } - public Multi loadNewerTimestampsForToken(UUID landscapeToken, long newest) { + public Multi loadNewerTimestampsForToken(UUID landscapeToken, long newest, + Optional commit) { LOGGER.atTrace().addArgument(landscapeToken).addArgument(newest) - .log("Loading newer timestamps for token {} and newest timestamp {}."); + .addArgument(commit.orElse("all-commits")) + .log("Loading newer timestamps for token {} and newest timestamp {} and commit {}."); + + if (commit.isPresent()) { + return session.executeReactive( + this.selectNewerTimestampsForTokenAndCommit.bind(landscapeToken, commit.get(), + newest)) + .map(Timestamp::fromRow); + } else { + return session.executeReactive( + this.selectNewerTimestampsForToken.bind(landscapeToken, newest)) + .map(Timestamp::fromRow); + } + - return session.executeReactive(this.selectNewerTimestampsForToken.bind(landscapeToken, newest)) - .map(Timestamp::fromRow); } } diff --git a/src/main/resources/init_script.cql b/src/main/resources/init_script.cql index da8d8ca..69a8c73 100644 --- a/src/main/resources/init_script.cql +++ b/src/main/resources/init_script.cql @@ -24,6 +24,14 @@ CREATE TABLE IF NOT EXISTS explorviz.span_count_per_time_bucket_and_token PRIMARY KEY (landscape_token, tenth_second_epoch) ); +CREATE TABLE IF NOT EXISTS explorviz.span_count_for_token_and_commit_and_time_bucket ( + landscape_token UUID, + git_commit_checksum text, + tenth_second_epoch bigint, + span_count counter, + PRIMARY KEY ((landscape_token, git_commit_checksum), tenth_second_epoch) +); + /* SELECT trace_id FROM traceid_by_time WHERE landscape_token = X AND start_time_s = X; */ /* Get complete traces by their trace id */ From 25b93e9ebd64d6430bd04f03145aff489de417a6 Mon Sep 17 00:00:00 2001 From: Alexander Krause Date: Thu, 11 Apr 2024 10:47:13 +0200 Subject: [PATCH 05/27] testing query param newer in timestamp api --- .../span/api/TimestampResourceIt.java | 130 ++++++++++++++---- 1 file changed, 103 insertions(+), 27 deletions(-) diff --git a/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java b/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java index f2e56a9..13b8cc4 100644 --- a/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java +++ b/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java @@ -8,7 +8,9 @@ import io.restassured.common.mapper.TypeRef; import io.restassured.response.Response; import jakarta.inject.Inject; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.UUID; import net.explorviz.span.kafka.KafkaTestResource; @@ -39,7 +41,7 @@ void testLoadAllTimestampsForToken() { final UUID uuidExpected = UUID.randomUUID(); - final PersistenceSpan differentTokenSpan = + final PersistenceSpan firstSpanOfFirstBucket = new PersistenceSpan(UUID.randomUUID(), gitCommitChecksum, "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); @@ -47,29 +49,27 @@ void testLoadAllTimestampsForToken() { final String duplicateMethodName = "myMethodName()"; final String otherMethodName = "myOtherMethodName()"; - final PersistenceSpan firstOccurenceSpan = + final PersistenceSpan firstSpanOfSecondBuckec = new PersistenceSpan(uuidExpected, gitCommitChecksum, "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); - final PersistenceSpan secondOccurenceSpan = + final PersistenceSpan firstSpanOfThirdBucket = new PersistenceSpan(uuidExpected, gitCommitChecksum, "789L", "", "3L", startLate, endLate, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); - final PersistenceSpan otherSpan = + final PersistenceSpan secondSpanOfSecondBucket = new PersistenceSpan(uuidExpected, gitCommitChecksum, "456L", "0L", "", startExpected, endExpected, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + otherMethodName, "321"); - spanProcessor.accept(differentTokenSpan); - spanProcessor.accept(firstOccurenceSpan); - spanProcessor.accept(secondOccurenceSpan); - spanProcessor.accept(otherSpan); + spanProcessor.accept(firstSpanOfFirstBucket); + spanProcessor.accept(firstSpanOfSecondBuckec); + spanProcessor.accept(firstSpanOfThirdBucket); + spanProcessor.accept(secondSpanOfSecondBucket); final Response response = given().pathParam("token", uuidExpected).when() .get("/v2/landscapes/{token}/timestamps"); - System.out.println("ALEX HIER: " + response.getBody().asPrettyString()); - final List resultList = response.getBody().as(new TypeRef>() { }); @@ -77,26 +77,102 @@ void testLoadAllTimestampsForToken() { Assertions.assertEquals(2, resultList.size()); // Check that there are the correct timestamp buckets with correct span count - Optional optionalTimestamp = - resultList.stream().filter(timestamp -> timestamp.epochMilli() == 1702545560000L) - .findFirst(); - - if (optionalTimestamp.isEmpty()) { - Assertions.fail( - "Found no timestamp for time bucket 1702545560000L, but there should be one."); - } else { - Assertions.assertEquals(optionalTimestamp.get().spanCount(), 2); + // Check that there are the correct timestamp buckets with correct span count + Map doubleBraceMap = new HashMap() {{ + put(1702545560000L, 2); + put(1702545570000L, 1); + }}; + + for (final Map.Entry entry : doubleBraceMap.entrySet()) { + long key = entry.getKey().longValue(); + int value = entry.getValue().intValue(); + + Optional optionalTimestamp = + resultList.stream().filter(timestamp -> timestamp.epochMilli() == key) + .findFirst(); + + if (optionalTimestamp.isEmpty()) { + Assertions.fail( + "Found no timestamp for time bucket " + key + ", but there should be one."); + } else { + Assertions.assertEquals(value, optionalTimestamp.get().spanCount()); + } } + } + + @Test + void testLoadNewerTimestampsForToken() { + final long firstBucketStart = 1702545554404L; + final long firstBucketEnd = firstBucketStart + 1000; + final long secondBucketStart = 1702545564404L; + final long secondBucketEnd = secondBucketStart + 1000; + final long thirdBucketStart = secondBucketStart + 10_000; + final long thirdBucketEnd = thirdBucketStart + 1000; + + final UUID uuidExpected = UUID.randomUUID(); - optionalTimestamp = - resultList.stream().filter(timestamp -> timestamp.epochMilli() == 1702545570000L) - .findFirst(); + final PersistenceSpan firstSpanOfFirstBucket = + new PersistenceSpan(uuidExpected, gitCommitChecksum, "0123L", "", + "1L", firstBucketStart, firstBucketEnd, "nodeIp", "app-name", "java", 0, + "net.explorviz.Class.myMethod()", "847"); + + final String duplicateMethodName = "myMethodName()"; + final String otherMethodName = "myOtherMethodName()"; + + final PersistenceSpan firstSpanOfSecondBuckec = + new PersistenceSpan(uuidExpected, gitCommitChecksum, "123L", "", "1L", secondBucketStart, + secondBucketEnd, + "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); - if (optionalTimestamp.isEmpty()) { - Assertions.fail( - "Found no timestamp for time bucket 1702545570000L, but there should be one."); - } else { - Assertions.assertEquals(optionalTimestamp.get().spanCount(), 1); + final PersistenceSpan firstSpanOfThirdBucket = + new PersistenceSpan(uuidExpected, gitCommitChecksum, "789L", "", "3L", thirdBucketStart, + thirdBucketEnd, + "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + + final PersistenceSpan secondSpanOfSecondBucket = + new PersistenceSpan(uuidExpected, gitCommitChecksum, "456L", "0L", "", secondBucketStart, + secondBucketEnd, "nodeIp", "app-name", "java", 0, + "net.explorviz.Class." + otherMethodName, + "321"); + + spanProcessor.accept(firstSpanOfFirstBucket); + spanProcessor.accept(firstSpanOfSecondBuckec); + spanProcessor.accept(firstSpanOfThirdBucket); + spanProcessor.accept(secondSpanOfSecondBucket); + + final Response response = + given().pathParam("token", uuidExpected).queryParam("newest", firstBucketStart - 10000) + .when() + .get("/v2/landscapes/{token}/timestamps"); + + final List resultList = response.getBody().as(new TypeRef>() { + }); + + //System.out.println("HIER DA " + Arrays.deepToString(resultList.toArray())); + + Assertions.assertEquals(3, resultList.size()); + + // Check that there are the correct timestamp buckets with correct span count + Map doubleBraceMap = new HashMap() {{ + put(1702545550000L, 1); + put(1702545560000L, 2); + put(1702545570000L, 1); + }}; + + for (Map.Entry entry : doubleBraceMap.entrySet()) { + long key = entry.getKey().longValue(); + int value = entry.getValue().intValue(); + + Optional optionalTimestamp = + resultList.stream().filter(timestamp -> timestamp.epochMilli() == key) + .findFirst(); + + if (optionalTimestamp.isEmpty()) { + Assertions.fail( + "Found no timestamp for time bucket " + key + ", but there should be one."); + } else { + Assertions.assertEquals(value, optionalTimestamp.get().spanCount()); + } } } From b12361bd9842d3a2200e657216204970c2f8cfd8 Mon Sep 17 00:00:00 2001 From: Alexander Krause Date: Thu, 11 Apr 2024 13:44:47 +0200 Subject: [PATCH 06/27] test commit query parameter for timestamp api --- .../span/api/TimestampResourceIt.java | 135 +++++++++++++++++- 1 file changed, 131 insertions(+), 4 deletions(-) diff --git a/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java b/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java index 13b8cc4..612c93a 100644 --- a/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java +++ b/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java @@ -78,12 +78,12 @@ void testLoadAllTimestampsForToken() { // Check that there are the correct timestamp buckets with correct span count // Check that there are the correct timestamp buckets with correct span count - Map doubleBraceMap = new HashMap() {{ + Map expectedValuesMap = new HashMap() {{ put(1702545560000L, 2); put(1702545570000L, 1); }}; - for (final Map.Entry entry : doubleBraceMap.entrySet()) { + for (final Map.Entry entry : expectedValuesMap.entrySet()) { long key = entry.getKey().longValue(); int value = entry.getValue().intValue(); @@ -153,13 +153,140 @@ void testLoadNewerTimestampsForToken() { Assertions.assertEquals(3, resultList.size()); // Check that there are the correct timestamp buckets with correct span count - Map doubleBraceMap = new HashMap() {{ + Map expectedValuesMap = new HashMap() {{ put(1702545550000L, 1); put(1702545560000L, 2); put(1702545570000L, 1); }}; - for (Map.Entry entry : doubleBraceMap.entrySet()) { + testResultListAgainstExpectedValues(resultList, expectedValuesMap); + } + + @Test + void testLoadAllTimestampsForTokenAndCommit() { + final long firstBucketStart = 1702545554404L; + final long firstBucketEnd = firstBucketStart + 1000; + final long secondBucketStart = 1702545564404L; + final long secondBucketEnd = secondBucketStart + 1000; + final long thirdBucketStart = secondBucketStart + 10_000; + final long thirdBucketEnd = thirdBucketStart + 1000; + + final UUID uuidExpected = UUID.randomUUID(); + final String expectedCommit = "testCommit"; + + final PersistenceSpan firstSpanOfFirstBucket = + new PersistenceSpan(uuidExpected, "notTestCommit-1", "0123L", "", + "1L", firstBucketStart, firstBucketEnd, "nodeIp", "app-name", "java", 0, + "net.explorviz.Class.myMethod()", "847"); + + final String duplicateMethodName = "myMethodName()"; + final String otherMethodName = "myOtherMethodName()"; + + final PersistenceSpan firstSpanOfSecondBuckec = + new PersistenceSpan(uuidExpected, expectedCommit, "123L", "", "1L", secondBucketStart, + secondBucketEnd, + "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + + final PersistenceSpan firstSpanOfThirdBucket = + new PersistenceSpan(uuidExpected, "notTestCommit-2", "789L", "", "3L", thirdBucketStart, + thirdBucketEnd, + "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + + final PersistenceSpan secondSpanOfSecondBucket = + new PersistenceSpan(uuidExpected, "notTestCommit-2", "456L", "0L", "", secondBucketStart, + secondBucketEnd, "nodeIp", "app-name", "java", 0, + "net.explorviz.Class." + otherMethodName, + "321"); + + spanProcessor.accept(firstSpanOfFirstBucket); + spanProcessor.accept(firstSpanOfSecondBuckec); + spanProcessor.accept(firstSpanOfThirdBucket); + spanProcessor.accept(secondSpanOfSecondBucket); + + final Response response = + given().pathParam("token", uuidExpected).queryParam("commit", expectedCommit) + .when() + .get("/v2/landscapes/{token}/timestamps"); + + final List resultList = response.getBody().as(new TypeRef>() { + }); + + Assertions.assertEquals(1, resultList.size()); + + // Check that there are the correct timestamp buckets with correct span count + Map expectedValuesMap = new HashMap() {{ + put(1702545560000L, 1); + }}; + + testResultListAgainstExpectedValues(resultList, expectedValuesMap); + } + + @Test + void testLoadNewerTimestampsForTokenAndCommit() { + final long firstBucketStart = 1702545554404L; + final long firstBucketEnd = firstBucketStart + 1000; + final long secondBucketStart = 1702545564404L; + final long secondBucketEnd = secondBucketStart + 1000; + final long thirdBucketStart = secondBucketStart + 10_000; + final long thirdBucketEnd = thirdBucketStart + 1000; + + final UUID uuidExpected = UUID.randomUUID(); + final String expectedCommit = "testCommit"; + + final PersistenceSpan firstSpanOfFirstBucket = + new PersistenceSpan(uuidExpected, expectedCommit, "0123L", "", + "1L", firstBucketStart, firstBucketEnd, "nodeIp", "app-name", "java", 0, + "net.explorviz.Class.myMethod()", "847"); + + final String duplicateMethodName = "myMethodName()"; + final String otherMethodName = "myOtherMethodName()"; + + final PersistenceSpan firstSpanOfSecondBuckec = + new PersistenceSpan(uuidExpected, expectedCommit, "123L", "", "1L", secondBucketStart, + secondBucketEnd, + "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + + final PersistenceSpan firstSpanOfThirdBucket = + new PersistenceSpan(uuidExpected, expectedCommit, "789L", "", "3L", thirdBucketStart, + thirdBucketEnd, + "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + + final PersistenceSpan secondSpanOfSecondBucket = + new PersistenceSpan(uuidExpected, expectedCommit, "456L", "0L", "", + secondBucketStart + 1000, + secondBucketEnd + 1000, "nodeIp", "app-name", "java", 0, + "net.explorviz.Class." + otherMethodName, + "321"); + + spanProcessor.accept(firstSpanOfFirstBucket); + spanProcessor.accept(firstSpanOfSecondBuckec); + spanProcessor.accept(firstSpanOfThirdBucket); + spanProcessor.accept(secondSpanOfSecondBucket); + + final Response response = + given().pathParam("token", uuidExpected) + .queryParam("newest", secondBucketEnd - 10000) + .queryParam("commit", expectedCommit) + .when() + .get("/v2/landscapes/{token}/timestamps"); + + final List resultList = response.getBody().as(new TypeRef>() { + }); + + Assertions.assertEquals(2, resultList.size()); + + // Check that there are the correct timestamp buckets with correct span count + Map expectedValuesMap = new HashMap() {{ + put(1702545560000L, 2); + put(1702545570000L, 1); + }}; + + testResultListAgainstExpectedValues(resultList, expectedValuesMap); + } + + private void testResultListAgainstExpectedValues(final List resultList, + final Map expectedValuesMap) { + for (Map.Entry entry : expectedValuesMap.entrySet()) { long key = entry.getKey().longValue(); int value = entry.getValue().intValue(); From 1e1c5d7b00c8fb2bdfb9e60368b5c0cb11c2deae Mon Sep 17 00:00:00 2001 From: Alexander Krause Date: Thu, 11 Apr 2024 14:33:51 +0200 Subject: [PATCH 07/27] don't use commit_sha for Docker image tags of MRs --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a359c5c..78118d1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -92,12 +92,12 @@ push-dockerhub-native-mr: -Dquarkus.package.type=native -Dquarkus.container-image.push=true -Dquarkus.container-image.name=${DOCKERHUB_IMAGE_NAME_NATIVE} - -Dquarkus.container-image.tag=$CI_MERGE_REQUEST_ID-$CI_COMMIT_SHORT_SHA + -Dquarkus.container-image.tag=$CI_MERGE_REQUEST_ID -Dquarkus.native.additional-build-args="--initialize-at-run-time=org.apache.kafka.common.security.authenticator.SaslClientAuthenticator\\,org.apache.kafka.common.security.oauthbearer.internals.expiring.ExpiringCredentialRefreshingLogin" -Dquarkus.container-image.username=$DOCKERHUB_USERNAME -Dquarkus.container-image.password=$DOCKERHUB_PASSWORD after_script: - - echo "Image was uploaded to Dockerhub; explorviz/user-service-native:$CI_MERGE_REQUEST_ID-$CI_COMMIT_SHORT_SHA" + - echo "Image was uploaded to Dockerhub; explorviz/user-service-native:$CI_MERGE_REQUEST_ID" .push-dockerhub-base-job: stage: publish @@ -124,8 +124,8 @@ push-dockerhub-mr: - ./gradlew clean assemble -Dquarkus.container-image.build=true -Dquarkus.container-image.push=true - -Dquarkus.container-image.tag=$CI_MERGE_REQUEST_ID-$CI_COMMIT_SHORT_SHA + -Dquarkus.container-image.tag=$CI_MERGE_REQUEST_ID -Dquarkus.container-image.username=$DOCKERHUB_USERNAME -Dquarkus.container-image.password=$DOCKERHUB_PASSWORD after_script: - - echo "Image was uploaded to Dockerhub; explorviz/${DOCKERHUB_IMAGE_NAME}:$CI_MERGE_REQUEST_ID-$CI_COMMIT_SHORT_SHA" + - echo "Image was uploaded to Dockerhub; explorviz/${DOCKERHUB_IMAGE_NAME}:$CI_MERGE_REQUEST_ID" From e64ac7617520a6bc622fda6f594adb463f5562c8 Mon Sep 17 00:00:00 2001 From: Alexander Krause Date: Thu, 11 Apr 2024 14:38:08 +0200 Subject: [PATCH 08/27] For MR, use image tag similar to frontend --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 78118d1..fe6dfba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -92,12 +92,12 @@ push-dockerhub-native-mr: -Dquarkus.package.type=native -Dquarkus.container-image.push=true -Dquarkus.container-image.name=${DOCKERHUB_IMAGE_NAME_NATIVE} - -Dquarkus.container-image.tag=$CI_MERGE_REQUEST_ID + -Dquarkus.container-image.tag=mr-$CI_MERGE_REQUEST_IID -Dquarkus.native.additional-build-args="--initialize-at-run-time=org.apache.kafka.common.security.authenticator.SaslClientAuthenticator\\,org.apache.kafka.common.security.oauthbearer.internals.expiring.ExpiringCredentialRefreshingLogin" -Dquarkus.container-image.username=$DOCKERHUB_USERNAME -Dquarkus.container-image.password=$DOCKERHUB_PASSWORD after_script: - - echo "Image was uploaded to Dockerhub; explorviz/user-service-native:$CI_MERGE_REQUEST_ID" + - echo "Image was uploaded to Dockerhub; explorviz/user-service-native:mr-$CI_MERGE_REQUEST_IID" .push-dockerhub-base-job: stage: publish @@ -124,8 +124,8 @@ push-dockerhub-mr: - ./gradlew clean assemble -Dquarkus.container-image.build=true -Dquarkus.container-image.push=true - -Dquarkus.container-image.tag=$CI_MERGE_REQUEST_ID + -Dquarkus.container-image.tag=mr-$CI_MERGE_REQUEST_IID -Dquarkus.container-image.username=$DOCKERHUB_USERNAME -Dquarkus.container-image.password=$DOCKERHUB_PASSWORD after_script: - - echo "Image was uploaded to Dockerhub; explorviz/${DOCKERHUB_IMAGE_NAME}:$CI_MERGE_REQUEST_ID" + - echo "Image was uploaded to Dockerhub; explorviz/${DOCKERHUB_IMAGE_NAME}:mr-$CI_MERGE_REQUEST_IID" From 8fb7d9379d843e18bcd60576d8f7da002e83f433 Mon Sep 17 00:00:00 2001 From: Alexander Krause Date: Wed, 8 May 2024 21:07:41 +0200 Subject: [PATCH 09/27] include hostName and instanceId in landscape structure --- .../span/api/LandscapeResourceIt.java | 34 ++++++++------ .../span/api/TimestampResourceIt.java | 45 +++++++++++-------- .../span/persistence/TraceLoaderIt.java | 15 ++++--- .../span/application/V2ApiApplication.java | 2 +- .../net/explorviz/span/hash/HighwayHash.java | 2 +- .../explorviz/span/landscape/Application.java | 2 +- .../net/explorviz/span/landscape/Node.java | 2 +- .../assembler/impl/AssemblyUtils.java | 4 +- .../impl/DefaultLandscapeAssembler.java | 2 +- .../landscape/loader/LandscapeRecord.java | 4 +- .../span/persistence/PersistenceSpan.java | 1 + .../persistence/PersistenceSpanProcessor.java | 9 ++-- .../span/persistence/SpanConverter.java | 4 +- src/main/resources/init_script.cql | 1 + 14 files changed, 77 insertions(+), 50 deletions(-) diff --git a/src/integrationTest/java/net/explorviz/span/api/LandscapeResourceIt.java b/src/integrationTest/java/net/explorviz/span/api/LandscapeResourceIt.java index 45898c9..f2d8bcb 100644 --- a/src/integrationTest/java/net/explorviz/span/api/LandscapeResourceIt.java +++ b/src/integrationTest/java/net/explorviz/span/api/LandscapeResourceIt.java @@ -7,12 +7,12 @@ import io.quarkus.test.junit.QuarkusTest; import io.restassured.response.Response; import jakarta.inject.Inject; -import java.util.Arrays; import java.util.List; import java.util.UUID; import net.explorviz.span.kafka.KafkaTestResource; import net.explorviz.span.landscape.Landscape; import net.explorviz.span.landscape.Method; +import net.explorviz.span.landscape.Node; import net.explorviz.span.persistence.PersistenceSpan; import net.explorviz.span.persistence.PersistenceSpanProcessor; import net.explorviz.span.trace.Trace; @@ -42,21 +42,22 @@ void testLoadAllStructureSpans() { final PersistenceSpan differentTokenSpan = new PersistenceSpan( UUID.randomUUID(), gitCommitChecksum, "123L", "", "1L", startEarly, - endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); + endEarly, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class.myMethod()", + "847"); final String duplicateMethodName = "myMethodName()"; final String otherMethodName = "myOtherMethodName()"; final PersistenceSpan firstOccurenceSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, - "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, + "123L", "", "1L", startEarly, endEarly, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan secondOccurenceSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, - "789L", "", "3L", startLate, endLate, "nodeIp", "app-name", "java", 0, + "789L", "", "3L", startLate, endLate, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan otherSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, "456L", - "0L", "", startExpected, endExpected, "nodeIp", "app-name", "java", 0, + "0L", "", startExpected, endExpected, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class." + otherMethodName, "321"); spanProcessor.accept(differentTokenSpan); @@ -69,6 +70,11 @@ void testLoadAllStructureSpans() { final Landscape result = response.getBody().as(Landscape.class); + final List node = result.nodes(); + + Assertions.assertEquals(1, node.size()); + Assertions.assertEquals("host-name", node.get(0).hostName()); + final List resultMethodList = result.nodes().get(0).applications().get(0).packages() .get(0).subPackages().get(0).classes().get(0).methods(); @@ -90,21 +96,22 @@ void testLoadStructureSpansByTimeRange() { final PersistenceSpan differentTokenSpan = new PersistenceSpan( UUID.randomUUID(), gitCommitChecksum, "123L", "", "1L", startEarly, - endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); + endEarly, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class.myMethod()", + "847"); final String duplicateMethodName = "myMethodName()"; final String otherMethodName = "myOtherMethodName()"; final PersistenceSpan firstOccurenceSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, - "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, + "123L", "", "1L", startEarly, endEarly, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan secondOccurenceSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, - "789L", "", "3L", startLate, endLate, "nodeIp", "app-name", "java", 0, + "789L", "", "3L", startLate, endLate, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan otherSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, "456L", - "", "2L", startExpected, endExpected, "nodeIp", "app-name", "java", 0, + "", "2L", startExpected, endExpected, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class." + otherMethodName, "321"); spanProcessor.accept(differentTokenSpan); @@ -141,21 +148,22 @@ void testLoadTracesByTimeRange() { final PersistenceSpan differentTokenSpan = new PersistenceSpan( UUID.randomUUID(), gitCommitChecksum, "123L", "", "1L", startEarly, - endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); + endEarly, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class.myMethod()", + "847"); final String duplicateMethodName = "myMethodName()"; final String otherMethodName = "myOtherMethodName()"; final PersistenceSpan firstOccurenceSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, - "123L", "", "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, + "123L", "", "1L", startEarly, endEarly, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan secondOccurenceSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, - "789L", "", "3L", startLate, endLate, "nodeIp", "app-name", "java", 0, + "789L", "", "3L", startLate, endLate, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan otherSpan = new PersistenceSpan(uuidExpected, gitCommitChecksum, "456L", - "", "2L", startExpected, endExpected, "nodeIp", "app-name", "java", 0, + "", "2L", startExpected, endExpected, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class." + otherMethodName, "321"); spanProcessor.accept(differentTokenSpan); diff --git a/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java b/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java index 612c93a..333d4bd 100644 --- a/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java +++ b/src/integrationTest/java/net/explorviz/span/api/TimestampResourceIt.java @@ -43,7 +43,7 @@ void testLoadAllTimestampsForToken() { final PersistenceSpan firstSpanOfFirstBucket = new PersistenceSpan(UUID.randomUUID(), gitCommitChecksum, "123L", "", - "1L", startEarly, endEarly, "nodeIp", "app-name", "java", 0, + "1L", startEarly, endEarly, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); final String duplicateMethodName = "myMethodName()"; @@ -51,15 +51,18 @@ void testLoadAllTimestampsForToken() { final PersistenceSpan firstSpanOfSecondBuckec = new PersistenceSpan(uuidExpected, gitCommitChecksum, "123L", "", "1L", startEarly, endEarly, - "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + "nodeIp", "host-name", "app-name", "java", 0, + "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan firstSpanOfThirdBucket = new PersistenceSpan(uuidExpected, gitCommitChecksum, "789L", "", "3L", startLate, endLate, - "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + "nodeIp", "host-name", "app-name", "java", 0, + "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan secondSpanOfSecondBucket = new PersistenceSpan(uuidExpected, gitCommitChecksum, "456L", "0L", "", startExpected, - endExpected, "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + otherMethodName, + endExpected, "nodeIp", "host-name", "app-name", "java", 0, + "net.explorviz.Class." + otherMethodName, "321"); spanProcessor.accept(firstSpanOfFirstBucket); @@ -113,7 +116,7 @@ void testLoadNewerTimestampsForToken() { final PersistenceSpan firstSpanOfFirstBucket = new PersistenceSpan(uuidExpected, gitCommitChecksum, "0123L", "", - "1L", firstBucketStart, firstBucketEnd, "nodeIp", "app-name", "java", 0, + "1L", firstBucketStart, firstBucketEnd, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); final String duplicateMethodName = "myMethodName()"; @@ -122,16 +125,18 @@ void testLoadNewerTimestampsForToken() { final PersistenceSpan firstSpanOfSecondBuckec = new PersistenceSpan(uuidExpected, gitCommitChecksum, "123L", "", "1L", secondBucketStart, secondBucketEnd, - "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + "nodeIp", "host-name", "app-name", "java", 0, + "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan firstSpanOfThirdBucket = new PersistenceSpan(uuidExpected, gitCommitChecksum, "789L", "", "3L", thirdBucketStart, thirdBucketEnd, - "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + "nodeIp", "host-name", "app-name", "java", 0, + "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan secondSpanOfSecondBucket = new PersistenceSpan(uuidExpected, gitCommitChecksum, "456L", "0L", "", secondBucketStart, - secondBucketEnd, "nodeIp", "app-name", "java", 0, + secondBucketEnd, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class." + otherMethodName, "321"); @@ -176,7 +181,7 @@ void testLoadAllTimestampsForTokenAndCommit() { final PersistenceSpan firstSpanOfFirstBucket = new PersistenceSpan(uuidExpected, "notTestCommit-1", "0123L", "", - "1L", firstBucketStart, firstBucketEnd, "nodeIp", "app-name", "java", 0, + "1L", firstBucketStart, firstBucketEnd, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); final String duplicateMethodName = "myMethodName()"; @@ -185,16 +190,18 @@ void testLoadAllTimestampsForTokenAndCommit() { final PersistenceSpan firstSpanOfSecondBuckec = new PersistenceSpan(uuidExpected, expectedCommit, "123L", "", "1L", secondBucketStart, secondBucketEnd, - "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + "nodeIp", "host-name", "app-name", "java", 0, + "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan firstSpanOfThirdBucket = new PersistenceSpan(uuidExpected, "notTestCommit-2", "789L", "", "3L", thirdBucketStart, thirdBucketEnd, - "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + "nodeIp", "host-name", "app-name", "java", 0, + "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan secondSpanOfSecondBucket = new PersistenceSpan(uuidExpected, "notTestCommit-2", "456L", "0L", "", secondBucketStart, - secondBucketEnd, "nodeIp", "app-name", "java", 0, + secondBucketEnd, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class." + otherMethodName, "321"); @@ -235,7 +242,7 @@ void testLoadNewerTimestampsForTokenAndCommit() { final PersistenceSpan firstSpanOfFirstBucket = new PersistenceSpan(uuidExpected, expectedCommit, "0123L", "", - "1L", firstBucketStart, firstBucketEnd, "nodeIp", "app-name", "java", 0, + "1L", firstBucketStart, firstBucketEnd, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); final String duplicateMethodName = "myMethodName()"; @@ -244,17 +251,19 @@ void testLoadNewerTimestampsForTokenAndCommit() { final PersistenceSpan firstSpanOfSecondBuckec = new PersistenceSpan(uuidExpected, expectedCommit, "123L", "", "1L", secondBucketStart, secondBucketEnd, - "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + "nodeIp", "host-name", "app-name", "java", 0, + "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan firstSpanOfThirdBucket = new PersistenceSpan(uuidExpected, expectedCommit, "789L", "", "3L", thirdBucketStart, thirdBucketEnd, - "nodeIp", "app-name", "java", 0, "net.explorviz.Class." + duplicateMethodName, "847"); + "nodeIp", "host-name", "app-name", "java", 0, + "net.explorviz.Class." + duplicateMethodName, "847"); final PersistenceSpan secondSpanOfSecondBucket = new PersistenceSpan(uuidExpected, expectedCommit, "456L", "0L", "", secondBucketStart + 1000, - secondBucketEnd + 1000, "nodeIp", "app-name", "java", 0, + secondBucketEnd + 1000, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class." + otherMethodName, "321"); @@ -287,8 +296,8 @@ void testLoadNewerTimestampsForTokenAndCommit() { private void testResultListAgainstExpectedValues(final List resultList, final Map expectedValuesMap) { for (Map.Entry entry : expectedValuesMap.entrySet()) { - long key = entry.getKey().longValue(); - int value = entry.getValue().intValue(); + long key = entry.getKey(); + int value = entry.getValue(); Optional optionalTimestamp = resultList.stream().filter(timestamp -> timestamp.epochMilli() == key) diff --git a/src/integrationTest/java/net/explorviz/span/persistence/TraceLoaderIt.java b/src/integrationTest/java/net/explorviz/span/persistence/TraceLoaderIt.java index fc67546..84a9878 100644 --- a/src/integrationTest/java/net/explorviz/span/persistence/TraceLoaderIt.java +++ b/src/integrationTest/java/net/explorviz/span/persistence/TraceLoaderIt.java @@ -45,17 +45,19 @@ void testLoadTracesByTimeRange() { final PersistenceSpan earlySpan = new PersistenceSpan(landscapeToken, gitCommitChecksum, "123L", "", "1L", startEarly, - endEarly, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", + endEarly, "nodeIp", "host-name", "app-name", "java", 0, + "net.explorviz.Class.myMethod()", "847"); final PersistenceSpan expectedSpan = - new PersistenceSpan(landscapeToken, gitCommitChecksum,"456L", "", "2L", startExpected, - endExpected, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", + new PersistenceSpan(landscapeToken, gitCommitChecksum, "456L", "", "2L", startExpected, + endExpected, "nodeIp", "host-name", "app-name", "java", 0, + "net.explorviz.Class.myMethod()", "847"); final PersistenceSpan lateSpan = - new PersistenceSpan(landscapeToken, gitCommitChecksum,"789L", "", "3L", startLate, - endLate, "nodeIp", "app-name", "java", 0, "net.explorviz.Class.myMethod()", + new PersistenceSpan(landscapeToken, gitCommitChecksum, "789L", "", "3L", startLate, + endLate, "nodeIp", "host-name", "app-name", "java", 0, "net.explorviz.Class.myMethod()", "847"); spanProcessor.accept(earlySpan); @@ -67,7 +69,8 @@ void testLoadTracesByTimeRange() { .await().indefinitely(); Assertions.assertEquals(1, result.size(), "List of traces has wrong size."); - Assertions.assertEquals(9, result.get(0).getClass().getDeclaredFields().length, "Trace has wrong number of fields."); + Assertions.assertEquals(9, result.get(0).getClass().getDeclaredFields().length, + "Trace has wrong number of fields."); Assertions.assertEquals(1, result.get(0).spanList().size(), "List of spans has wrong size."); Assertions.assertEquals(convertPersistenceSpanToSpan(expectedSpan), result.get(0).spanList().get(0), "Wrong span in trace."); diff --git a/src/main/java/net/explorviz/span/application/V2ApiApplication.java b/src/main/java/net/explorviz/span/application/V2ApiApplication.java index 63850af..16a0fe9 100644 --- a/src/main/java/net/explorviz/span/application/V2ApiApplication.java +++ b/src/main/java/net/explorviz/span/application/V2ApiApplication.java @@ -5,7 +5,7 @@ import org.eclipse.microprofile.openapi.annotations.info.Info; @OpenAPIDefinition(info = @Info(title = "ExplorViz Span API", - description = "Exposes endpoints to retrieve spans stored in this ExplorViz instance.", + description = "Exposes endpoints to retrieve spans stored in this ExplorViz instanceId.", version = "2.0")) public class V2ApiApplication extends Application { diff --git a/src/main/java/net/explorviz/span/hash/HighwayHash.java b/src/main/java/net/explorviz/span/hash/HighwayHash.java index c2b17db..9c1cea6 100644 --- a/src/main/java/net/explorviz/span/hash/HighwayHash.java +++ b/src/main/java/net/explorviz/span/hash/HighwayHash.java @@ -82,7 +82,7 @@ public void updatePacket(final byte[] packet, final int pos) { */ public void update(final long a0, final long a1, final long a2, final long a3) { if (done) { - throw new IllegalStateException("Can compute a hash only once per instance"); + throw new IllegalStateException("Can compute a hash only once per instanceId"); } v1[0] += mul0[0] + a0; v1[1] += mul0[1] + a1; diff --git a/src/main/java/net/explorviz/span/landscape/Application.java b/src/main/java/net/explorviz/span/landscape/Application.java index 25357ff..3008212 100644 --- a/src/main/java/net/explorviz/span/landscape/Application.java +++ b/src/main/java/net/explorviz/span/landscape/Application.java @@ -5,7 +5,7 @@ public record Application( String name, String language, - int instance, // TODO: Deviation from frontend, expects `String instanceId` + int instanceId, // TODO: Deviation from frontend, expects `String instanceId` List packages ) { diff --git a/src/main/java/net/explorviz/span/landscape/Node.java b/src/main/java/net/explorviz/span/landscape/Node.java index cf69a38..276414e 100644 --- a/src/main/java/net/explorviz/span/landscape/Node.java +++ b/src/main/java/net/explorviz/span/landscape/Node.java @@ -4,7 +4,7 @@ public record Node( String ipAddress, - // TODO: Deviation from frontend, missing `String hostName` + String hostName, List applications ) { diff --git a/src/main/java/net/explorviz/span/landscape/assembler/impl/AssemblyUtils.java b/src/main/java/net/explorviz/span/landscape/assembler/impl/AssemblyUtils.java index 0dfa7ef..d30dff8 100644 --- a/src/main/java/net/explorviz/span/landscape/assembler/impl/AssemblyUtils.java +++ b/src/main/java/net/explorviz/span/landscape/assembler/impl/AssemblyUtils.java @@ -38,13 +38,13 @@ public static Optional findNode(final Landscape landscape, final String ip * Searches for an {@link Application} in a node. * * @param node the node - * @param instance the instance id of the application to search for + * @param instance the instanceId id of the application to search for * @return an optional that contains the app if it is included in the node, and is empty otherwise */ public static Optional findApplication(final Node node, final String name, final int instance) { for (final Application a : node.applications()) { - if (a.instance() == instance && a.name().equals(name)) { + if (a.instanceId() == instance && a.name().equals(name)) { return Optional.of(a); } } diff --git a/src/main/java/net/explorviz/span/landscape/assembler/impl/DefaultLandscapeAssembler.java b/src/main/java/net/explorviz/span/landscape/assembler/impl/DefaultLandscapeAssembler.java index 82a85c3..5130da8 100644 --- a/src/main/java/net/explorviz/span/landscape/assembler/impl/DefaultLandscapeAssembler.java +++ b/src/main/java/net/explorviz/span/landscape/assembler/impl/DefaultLandscapeAssembler.java @@ -65,7 +65,7 @@ private Node getNodeForRecord(final Landscape landscape, final LandscapeRecord r if (foundNode.isPresent()) { node = foundNode.get(); } else { - node = new Node(ipAddress, new ArrayList<>()); + node = new Node(ipAddress, record.hostName(), new ArrayList<>()); landscape.nodes().add(node); } diff --git a/src/main/java/net/explorviz/span/landscape/loader/LandscapeRecord.java b/src/main/java/net/explorviz/span/landscape/loader/LandscapeRecord.java index d645b19..ee746de 100644 --- a/src/main/java/net/explorviz/span/landscape/loader/LandscapeRecord.java +++ b/src/main/java/net/explorviz/span/landscape/loader/LandscapeRecord.java @@ -9,6 +9,7 @@ public record LandscapeRecord( UUID landscapeToken, String methodHash, String nodeIpAddress, + String hostName, String applicationName, String applicationLanguage, int applicationInstance, @@ -22,6 +23,7 @@ public static LandscapeRecord fromRow(final Row row) { final UUID landscapeToken = row.getUuid("landscape_token"); final String methodHash = row.getString("method_hash"); final String nodeIpAddress = row.getString("node_ip_address"); + final String hostName = row.getString("host_name"); final String applicationName = row.getString("application_name"); final String applicationLanguage = row.getString("application_language"); final int applicationInstance = row.getInt("application_instance"); @@ -40,7 +42,7 @@ public static LandscapeRecord fromRow(final Row row) { final String className = operationFqnSplit[operationFqnSplit.length - 2]; final String methodName = operationFqnSplit[operationFqnSplit.length - 1]; - return new LandscapeRecord(landscapeToken, methodHash, nodeIpAddress, applicationName, + return new LandscapeRecord(landscapeToken, methodHash, nodeIpAddress, hostName, applicationName, applicationLanguage, applicationInstance, packageName, className, methodName, timeSeen); } } diff --git a/src/main/java/net/explorviz/span/persistence/PersistenceSpan.java b/src/main/java/net/explorviz/span/persistence/PersistenceSpan.java index 8fab018..68a07b5 100644 --- a/src/main/java/net/explorviz/span/persistence/PersistenceSpan.java +++ b/src/main/java/net/explorviz/span/persistence/PersistenceSpan.java @@ -11,6 +11,7 @@ public record PersistenceSpan( long startTime, long endTime, String nodeIpAddress, // TODO: Convert into InetAddress type? + String hostName, String applicationName, String applicationLanguage, int applicationInstance, diff --git a/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java b/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java index c182549..0301550 100644 --- a/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java +++ b/src/main/java/net/explorviz/span/persistence/PersistenceSpanProcessor.java @@ -61,9 +61,9 @@ public PersistenceSpanProcessor(final QuarkusCqlSession session) { + "start_time, end_time, trace_id) " + "VALUES (?, ?, ?, ?, ?, ?)"); this.insertSpanStructureStatement = session.prepare("INSERT INTO span_structure " - + "(landscape_token, method_hash, node_ip_address, application_name, application_language, " - + "application_instance, method_fqn, time_seen) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?) " - + "USING TIMESTAMP ?"); + + "(landscape_token, method_hash, node_ip_address, host_name, application_name, " + + "application_language, application_instance, method_fqn, time_seen) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) USING TIMESTAMP ?"); this.updateSpanBucketCounter = session.prepare("UPDATE " + "span_count_per_time_bucket_and_token SET span_count = span_count + 1 " + "WHERE landscape_token = ? AND tenth_second_epoch = ?"); @@ -116,7 +116,8 @@ private void updateSpanBucketCounter(final PersistenceSpan span) { private void insertSpanStructure(final PersistenceSpan span) { final BoundStatement stmtStructure = insertSpanStructureStatement.bind(span.landscapeToken(), span.methodHash(), - span.nodeIpAddress(), span.applicationName(), span.applicationLanguage(), + span.nodeIpAddress(), span.hostName(), span.applicationName(), + span.applicationLanguage(), span.applicationInstance(), span.methodFqn(), span.startTime(), Instant.now().toEpochMilli()); diff --git a/src/main/java/net/explorviz/span/persistence/SpanConverter.java b/src/main/java/net/explorviz/span/persistence/SpanConverter.java index 824d20a..5cd58f1 100644 --- a/src/main/java/net/explorviz/span/persistence/SpanConverter.java +++ b/src/main/java/net/explorviz/span/persistence/SpanConverter.java @@ -22,6 +22,7 @@ public PersistenceSpan apply(final Span span) { final long startTime = span.getStartTimeEpochMilli(); final long endTime = span.getEndTimeEpochMilli(); final String nodeIpAddress = span.getHostIpAddress(); + final String nodeHostName = span.getHostname(); final String applicationName = span.getAppName(); final int applicationInstance = Integer.parseInt(span.getAppInstanceId()); final String applicationLanguage = span.getAppLanguage(); @@ -34,7 +35,8 @@ public PersistenceSpan apply(final Span span) { return new PersistenceSpan(landscapeToken, gitCommitChecksum, span.getSpanId(), span.getParentSpanId(), span.getTraceId(), startTime, endTime, - nodeIpAddress, applicationName, applicationLanguage, applicationInstance, methodFqn, + nodeIpAddress, applicationName, applicationLanguage, nodeHostName, applicationInstance, + methodFqn, methodHashCode); } } diff --git a/src/main/resources/init_script.cql b/src/main/resources/init_script.cql index 69a8c73..56c8e1f 100644 --- a/src/main/resources/init_script.cql +++ b/src/main/resources/init_script.cql @@ -79,6 +79,7 @@ CREATE TABLE IF NOT EXISTS explorviz.span_structure landscape_token uuid, method_hash text, node_ip_address text, + host_name text, application_name text, application_language text, application_instance int, From 48f2445627c737ade170e2632283ac94344bfac6 Mon Sep 17 00:00:00 2001 From: Alexander Krause Date: Thu, 9 May 2024 06:44:21 +0200 Subject: [PATCH 10/27] test for hostname and instance id --- .../net/explorviz/span/api/LandscapeResourceIt.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/integrationTest/java/net/explorviz/span/api/LandscapeResourceIt.java b/src/integrationTest/java/net/explorviz/span/api/LandscapeResourceIt.java index f2d8bcb..20b3c23 100644 --- a/src/integrationTest/java/net/explorviz/span/api/LandscapeResourceIt.java +++ b/src/integrationTest/java/net/explorviz/span/api/LandscapeResourceIt.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.UUID; import net.explorviz.span.kafka.KafkaTestResource; +import net.explorviz.span.landscape.Application; import net.explorviz.span.landscape.Landscape; import net.explorviz.span.landscape.Method; import net.explorviz.span.landscape.Node; @@ -74,8 +75,16 @@ void testLoadAllStructureSpans() { Assertions.assertEquals(1, node.size()); Assertions.assertEquals("host-name", node.get(0).hostName()); + Assertions.assertEquals("nodeIp", node.get(0).ipAddress()); - final List resultMethodList = result.nodes().get(0).applications().get(0).packages() + final List applications = result.nodes().get(0).applications(); + + Assertions.assertEquals(1, applications.size()); + Assertions.assertEquals("app-name", applications.get(0).name()); + Assertions.assertEquals("java", applications.get(0).language()); + Assertions.assertEquals(0, applications.get(0).instanceId()); + + final List resultMethodList = applications.get(0).packages() .get(0).subPackages().get(0).classes().get(0).methods(); Assertions.assertEquals(2, resultMethodList.size()); From 871bf7c4d33ea60fb0bcbb98ef31a53fe35ecd25 Mon Sep 17 00:00:00 2001 From: Alexander Krause Date: Thu, 9 May 2024 21:59:09 +0200 Subject: [PATCH 11/27] fix conversion parameter order --- .../span/persistence/SpanConverter.java | 2 +- .../span/persistence/SpanConverterTest.java | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/test/java/net/explorviz/span/persistence/SpanConverterTest.java diff --git a/src/main/java/net/explorviz/span/persistence/SpanConverter.java b/src/main/java/net/explorviz/span/persistence/SpanConverter.java index 5cd58f1..3dc3e03 100644 --- a/src/main/java/net/explorviz/span/persistence/SpanConverter.java +++ b/src/main/java/net/explorviz/span/persistence/SpanConverter.java @@ -35,7 +35,7 @@ public PersistenceSpan apply(final Span span) { return new PersistenceSpan(landscapeToken, gitCommitChecksum, span.getSpanId(), span.getParentSpanId(), span.getTraceId(), startTime, endTime, - nodeIpAddress, applicationName, applicationLanguage, nodeHostName, applicationInstance, + nodeIpAddress, nodeHostName, applicationName, applicationLanguage, applicationInstance, methodFqn, methodHashCode); } diff --git a/src/test/java/net/explorviz/span/persistence/SpanConverterTest.java b/src/test/java/net/explorviz/span/persistence/SpanConverterTest.java new file mode 100644 index 0000000..05e046c --- /dev/null +++ b/src/test/java/net/explorviz/span/persistence/SpanConverterTest.java @@ -0,0 +1,58 @@ +package net.explorviz.span.persistence; + +import java.util.UUID; +import net.explorviz.avro.Span; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class SpanConverterTest { + + SpanConverter converter; + + @BeforeEach + public void setUp() { + this.converter = new SpanConverter(); + } + + private Span sampleSpan() { + return Span.newBuilder() + .setLandscapeToken(PersistenceSpan.DEFAULT_UUID.toString()) + .setGitCommitChecksum("gitchecksum") + .setTraceId("50c246ad9c9883d1558df9f19b9ae7a6") + .setSpanId("7ef83c66eabd5fbb") + .setParentSpanId("7ef83c66efe42aaa") + .setHostIpAddress("1.2.3.4") + .setHostname("testhostname") + .setAppName("testappname") + .setAppInstanceId("42") + .setAppLanguage("lava") + .setFullyQualifiedOperationName("asd.bfd") + .setHashCode("-909819732013219679") + .setStartTimeEpochMilli(1668069002431000000L) + .setEndTimeEpochMilli(1668072086000000000L) + .build(); + } + + private PersistenceSpan convertSpanToPersistenceSpan(final Span span) { + return new PersistenceSpan(UUID.fromString(span.getLandscapeToken()), + span.getGitCommitChecksum(), + span.getSpanId(), + span.getParentSpanId(), + span.getTraceId(), span.getStartTimeEpochMilli(), span.getEndTimeEpochMilli(), + span.getHostIpAddress(), span.getHostname(), span.getAppName(), span.getAppLanguage(), + Integer.valueOf(span.getAppInstanceId()), + span.getFullyQualifiedOperationName(), + span.getHashCode()); + } + + @Test + public void testSpanToPersistenceSpanConversion() { + final Span testSpan = this.sampleSpan(); + final PersistenceSpan expectedSpan = this.convertSpanToPersistenceSpan(testSpan); + + PersistenceSpan resultSpan = this.converter.apply(testSpan); + + Assertions.assertEquals(expectedSpan, resultSpan); + } +} From 6237cbbc4ecbc4a2628bd6ea759d52faaa836799 Mon Sep 17 00:00:00 2001 From: Alexander Krause Date: Sun, 12 May 2024 22:21:45 +0200 Subject: [PATCH 12/27] timestamp resource mocked tests --- build.gradle | 1 + .../explorviz/span/api/TimestampResource.java | 9 ++- .../span/timestamp/TimestampLoader.java | 1 - .../span/api/TimestampResourceTest.java | 66 +++++++++++++++++++ 4 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 src/test/java/net/explorviz/span/api/TimestampResourceTest.java diff --git a/build.gradle b/build.gradle index dbd186d..b664a19 100644 --- a/build.gradle +++ b/build.gradle @@ -41,6 +41,7 @@ dependencies { implementation 'io.quarkus:quarkus-smallrye-openapi' testImplementation 'io.quarkus:quarkus-junit5' + testImplementation 'io.quarkus:quarkus-junit5-mockito' // Integration / Api Tests testImplementation 'io.rest-assured:rest-assured' diff --git a/src/main/java/net/explorviz/span/api/TimestampResource.java b/src/main/java/net/explorviz/span/api/TimestampResource.java index ace1938..14d4f70 100644 --- a/src/main/java/net/explorviz/span/api/TimestampResource.java +++ b/src/main/java/net/explorviz/span/api/TimestampResource.java @@ -23,16 +23,21 @@ public class TimestampResource { private static final Logger LOGGER = LoggerFactory.getLogger(TimestampResource.class); - @Inject + TimestampLoader timestampLoader; + @Inject + public TimestampResource(final TimestampLoader timestampLoader) { + this.timestampLoader = timestampLoader; + } + @GET @Path("/{token}/timestamps") public Multi getTimestamps(@PathParam("token") final String token, @QueryParam("newest") final long newest, @QueryParam("oldest") final long oldest, @QueryParam("commit") final Optional commit) { LOGGER.atInfo().addArgument(token).addArgument(commit.orElse("all-commits")) - .log("Loading all timestamps for token {} and commit {}"); + .addArgument(newest).log("Loading timestamps for token {}, commit {}, and from epoch {}"); if (newest == 0 && oldest == 0) { return this.timestampLoader.loadAllTimestampsForToken(parseUuid(token), commit); diff --git a/src/main/java/net/explorviz/span/timestamp/TimestampLoader.java b/src/main/java/net/explorviz/span/timestamp/TimestampLoader.java index 37fe37a..fc5a10d 100644 --- a/src/main/java/net/explorviz/span/timestamp/TimestampLoader.java +++ b/src/main/java/net/explorviz/span/timestamp/TimestampLoader.java @@ -46,7 +46,6 @@ public TimestampLoader(final QuarkusCqlSession session) { public Multi loadAllTimestampsForToken(final UUID landscapeToken, final Optional commit) { - System.out.println("ALEX DA: " + commit.orElse("all-commits") + " " + commit.isPresent()); LOGGER.atTrace().addArgument(landscapeToken).addArgument(commit.orElse("all-commits")) .log("Loading all timestamps for token {} and commit {}"); diff --git a/src/test/java/net/explorviz/span/api/TimestampResourceTest.java b/src/test/java/net/explorviz/span/api/TimestampResourceTest.java new file mode 100644 index 0000000..cc969dc --- /dev/null +++ b/src/test/java/net/explorviz/span/api/TimestampResourceTest.java @@ -0,0 +1,66 @@ +package net.explorviz.span.api; + +import java.util.Optional; +import java.util.UUID; +import net.explorviz.span.persistence.PersistenceSpan; +import net.explorviz.span.timestamp.TimestampLoader; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +public class TimestampResourceTest { + + TimestampResource timestampResource; + TimestampLoader mockedTimestampLoader; + + @BeforeEach + public void setUp() { + mockedTimestampLoader = Mockito.mock(TimestampLoader.class); + this.timestampResource = new TimestampResource(mockedTimestampLoader); + } + + @Test + public void testGetAllTimestampsForToken() { + final String expectedToken = PersistenceSpan.DEFAULT_UUID.toString(); + + this.timestampResource.getTimestamps(expectedToken, 0L, 0L, Optional.empty()); + + Mockito.verify(mockedTimestampLoader, Mockito.times(1)) + .loadAllTimestampsForToken(UUID.fromString(expectedToken), Optional.empty()); + } + + @Test + public void testGetAllTimestampsForTokenAndCommit() { + final String expectedToken = PersistenceSpan.DEFAULT_UUID.toString(); + + this.timestampResource.getTimestamps(expectedToken, 0L, 0L, Optional.of("commit")); + + Mockito.verify(mockedTimestampLoader, Mockito.times(1)) + .loadAllTimestampsForToken(UUID.fromString(expectedToken), Optional.of("commit")); + } + + @Test + public void testGetNewerTimestampsForTokenAndCommit() { + final String expectedToken = PersistenceSpan.DEFAULT_UUID.toString(); + + this.timestampResource.getTimestamps(expectedToken, 1715367170000L, 0L, Optional.of("commit")); + + Mockito.verify(mockedTimestampLoader, Mockito.times(1)) + .loadNewerTimestampsForToken(UUID.fromString(expectedToken), 1715367170000L, + Optional.of("commit")); + } + + @Test + public void testGetNewerTimestampsForToken() { + final String expectedToken = PersistenceSpan.DEFAULT_UUID.toString(); + + this.timestampResource.getTimestamps(expectedToken, 1715367170000L, 0L, Optional.empty()); + + Mockito.verify(mockedTimestampLoader, Mockito.times(1)) + .loadNewerTimestampsForToken(UUID.fromString(expectedToken), 1715367170000L, + Optional.empty()); + } + + + +} From d2b5f609f3e3b7cd12ce3c1036a0fcfd74dcaa08 Mon Sep 17 00:00:00 2001 From: Paul Wilke Date: Sat, 28 Sep 2024 15:41:07 +0200 Subject: [PATCH 13/27] Added a Dockerfile to create a docker image that can initialize the cassandra database. --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9cd870a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM cassandra:3.11.14 + +COPY src/main/resources/init_script.cql ./init.cql From b59735ffda0d772279d89b29466ddf6c12f4bfc3 Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Thu, 21 Nov 2024 11:08:55 +0100 Subject: [PATCH 14/27] Set cross-commit as default value for git commit checksum --- src/main/avro/ExplorvizProtocol.avdl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/avro/ExplorvizProtocol.avdl b/src/main/avro/ExplorvizProtocol.avdl index d9d4d5d..4d37407 100644 --- a/src/main/avro/ExplorvizProtocol.avdl +++ b/src/main/avro/ExplorvizProtocol.avdl @@ -24,7 +24,7 @@ protocol ExplorvizProtocol { record Span { string landscapeToken; - string gitCommitChecksum; + string gitCommitChecksum = "cross-commit"; string spanId; string parentSpanId; string traceId; From 267889b424378ce685e3488a436d92f7e70266a2 Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 11:05:06 +0100 Subject: [PATCH 15/27] Update Dockerfile to build init-cassandra container --- Dockerfile | 3 --- init-cassandra.Dockerfile | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) delete mode 100644 Dockerfile create mode 100644 init-cassandra.Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 9cd870a..0000000 --- a/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM cassandra:3.11.14 - -COPY src/main/resources/init_script.cql ./init.cql diff --git a/init-cassandra.Dockerfile b/init-cassandra.Dockerfile new file mode 100644 index 0000000..5cec1ec --- /dev/null +++ b/init-cassandra.Dockerfile @@ -0,0 +1,6 @@ +FROM cassandra:3.11.14 + +COPY src/main/resources/init_script.cql ./init.cql + +CMD ["cqlsh", "cassandra-explorviz", "-f", "init.cql"] +#CMD ["cqlsh cassandra-explorviz -f init.cql"] From 3996ec0d97e2ca82e75aa62e57f972f9d4712d27 Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 11:05:52 +0100 Subject: [PATCH 16/27] Remove comment --- init-cassandra.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init-cassandra.Dockerfile b/init-cassandra.Dockerfile index 5cec1ec..def0cda 100644 --- a/init-cassandra.Dockerfile +++ b/init-cassandra.Dockerfile @@ -3,4 +3,4 @@ FROM cassandra:3.11.14 COPY src/main/resources/init_script.cql ./init.cql CMD ["cqlsh", "cassandra-explorviz", "-f", "init.cql"] -#CMD ["cqlsh cassandra-explorviz -f init.cql"] + From 61dcda247a52eba1c9975310238b41d61cefca26 Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 12:44:55 +0100 Subject: [PATCH 17/27] Add GitHub workflow to build init-casandra image --- .github/deploy-init-cassandra.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/deploy-init-cassandra.yml diff --git a/.github/deploy-init-cassandra.yml b/.github/deploy-init-cassandra.yml new file mode 100644 index 0000000..c77fe65 --- /dev/null +++ b/.github/deploy-init-cassandra.yml @@ -0,0 +1,28 @@ +name: Init-Cassandra Pipeline + +on: + push: + branches: ['main'] + paths: ['**.cql'] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log in to Docker Container Registry + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push multi-arch Docker image + run: | + docker buildx build \ + --file init-cassandra.Dockerfile \ + --platform linux/amd64,linux/arm64 \ + --tag explorviz/init-cassandra . \ + --push + From b77ed493e9bc181f4a830ae4f6c9e0a4a2bb7d0d Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 12:47:21 +0100 Subject: [PATCH 18/27] Add newline to end of init-cassandra script --- src/main/resources/init_script.cql | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/init_script.cql b/src/main/resources/init_script.cql index 56c8e1f..8389e1a 100644 --- a/src/main/resources/init_script.cql +++ b/src/main/resources/init_script.cql @@ -87,3 +87,4 @@ CREATE TABLE IF NOT EXISTS explorviz.span_structure time_seen bigint, PRIMARY KEY ((landscape_token), method_hash) ); + From 38874469064e642b82cd0863a32bf6790e401c4b Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 12:53:02 +0100 Subject: [PATCH 19/27] Remove empty line in cql script --- src/main/resources/init_script.cql | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/resources/init_script.cql b/src/main/resources/init_script.cql index 8389e1a..56c8e1f 100644 --- a/src/main/resources/init_script.cql +++ b/src/main/resources/init_script.cql @@ -87,4 +87,3 @@ CREATE TABLE IF NOT EXISTS explorviz.span_structure time_seen bigint, PRIMARY KEY ((landscape_token), method_hash) ); - From e190cda3d3cc2b1c4005a21060764065f3d634b3 Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 12:57:56 +0100 Subject: [PATCH 20/27] Update deploy-init-cassandra.yml --- .github/deploy-init-cassandra.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/deploy-init-cassandra.yml b/.github/deploy-init-cassandra.yml index c77fe65..d567d7f 100644 --- a/.github/deploy-init-cassandra.yml +++ b/.github/deploy-init-cassandra.yml @@ -3,7 +3,8 @@ name: Init-Cassandra Pipeline on: push: branches: ['main'] - paths: ['**.cql'] + paths: + - '**/*.cql' jobs: build-and-deploy: From 8e3336a695e4f3f522e8c0d4684ba0d0f9ed5286 Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 12:59:59 +0100 Subject: [PATCH 21/27] Remove empty line from .cql script --- .github/deploy-init-cassandra.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/deploy-init-cassandra.yml b/.github/deploy-init-cassandra.yml index d567d7f..7e7270b 100644 --- a/.github/deploy-init-cassandra.yml +++ b/.github/deploy-init-cassandra.yml @@ -2,9 +2,9 @@ name: Init-Cassandra Pipeline on: push: - branches: ['main'] + branches: ["main"] paths: - - '**/*.cql' + - "**/*.cql" jobs: build-and-deploy: @@ -26,4 +26,3 @@ jobs: --platform linux/amd64,linux/arm64 \ --tag explorviz/init-cassandra . \ --push - From 4dfde91c720413a331f5f69009bf22e3ddb3f3f5 Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 13:02:16 +0100 Subject: [PATCH 22/27] Build init-cassandra image when new commits are pushed to main branch --- .github/deploy-init-cassandra.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/deploy-init-cassandra.yml b/.github/deploy-init-cassandra.yml index 7e7270b..553b470 100644 --- a/.github/deploy-init-cassandra.yml +++ b/.github/deploy-init-cassandra.yml @@ -3,8 +3,6 @@ name: Init-Cassandra Pipeline on: push: branches: ["main"] - paths: - - "**/*.cql" jobs: build-and-deploy: From 402058272307998989c7d3c4165ce2dbccb2be40 Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 13:03:15 +0100 Subject: [PATCH 23/27] Update README.md --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 07d34e2..bee7611 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,6 @@ Scalable service that processes, persists, aggregates and queries the observed traces of method executions within monitored software applications. -## Features - -This replaces the [trace-service](https://git.se.informatik.uni-kiel.de/ExplorViz/code/trace-service) and -[landscape-service](https://git.se.informatik.uni-kiel.de/ExplorViz/code/landscape-service) previously used to process -spans. - ## Prerequisites - Java 17 or higher From a696f923fc01db6b01be6c0337659d660eff5e6d Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 13:05:09 +0100 Subject: [PATCH 24/27] Move GitHub Workflow file in correct folder --- .github/{ => workflows}/deploy-init-cassandra.yml | 2 ++ 1 file changed, 2 insertions(+) rename .github/{ => workflows}/deploy-init-cassandra.yml (96%) diff --git a/.github/deploy-init-cassandra.yml b/.github/workflows/deploy-init-cassandra.yml similarity index 96% rename from .github/deploy-init-cassandra.yml rename to .github/workflows/deploy-init-cassandra.yml index 553b470..7e7270b 100644 --- a/.github/deploy-init-cassandra.yml +++ b/.github/workflows/deploy-init-cassandra.yml @@ -3,6 +3,8 @@ name: Init-Cassandra Pipeline on: push: branches: ["main"] + paths: + - "**/*.cql" jobs: build-and-deploy: From db88c4920017689347267a6aa30665ec25dc8246 Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 13:07:26 +0100 Subject: [PATCH 25/27] Rename init-cassandra job --- .github/workflows/deploy-init-cassandra.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-init-cassandra.yml b/.github/workflows/deploy-init-cassandra.yml index 7e7270b..11a2735 100644 --- a/.github/workflows/deploy-init-cassandra.yml +++ b/.github/workflows/deploy-init-cassandra.yml @@ -7,7 +7,7 @@ on: - "**/*.cql" jobs: - build-and-deploy: + deploy-init-cassandra: runs-on: ubuntu-latest steps: - name: Checkout repository From 20350545ecc8304cd80bc1afbc8512b86dc2bce6 Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 13:09:10 +0100 Subject: [PATCH 26/27] Build init-cassandra image when new commits are pushed to main branch --- .github/workflows/deploy-init-cassandra.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/deploy-init-cassandra.yml b/.github/workflows/deploy-init-cassandra.yml index 11a2735..9da33af 100644 --- a/.github/workflows/deploy-init-cassandra.yml +++ b/.github/workflows/deploy-init-cassandra.yml @@ -3,8 +3,6 @@ name: Init-Cassandra Pipeline on: push: branches: ["main"] - paths: - - "**/*.cql" jobs: deploy-init-cassandra: From 41bee9abe8977b4ebcdd73b77dae797a0223b017 Mon Sep 17 00:00:00 2001 From: Malte Hansen Date: Tue, 3 Dec 2024 13:34:08 +0100 Subject: [PATCH 27/27] Add kubernetes attributes to cassandra span table --- src/main/resources/init_script.cql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/init_script.cql b/src/main/resources/init_script.cql index 56c8e1f..10f0bf5 100644 --- a/src/main/resources/init_script.cql +++ b/src/main/resources/init_script.cql @@ -85,5 +85,9 @@ CREATE TABLE IF NOT EXISTS explorviz.span_structure application_instance int, method_fqn text, time_seen bigint, + k8s_pod_name text, + k8s_node_name text, + k8s_namespace text, + k8s_deployment_name text, PRIMARY KEY ((landscape_token), method_hash) );