Skip to content

Commit ab5e75a

Browse files
committed
* log-exporter: remove trace exporting
Signed-off-by: neo <1100909+neowu@users.noreply.github.com>
1 parent 49c7135 commit ab5e75a

File tree

6 files changed

+11
-57
lines changed

6 files changed

+11
-57
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
### 9.1.5 (11/11/2024 - )
44

55
* log-exporter: change gsutil to "gcloud storage"
6+
* log-exporter: remove trace exporting
7+
> trace is only for troubleshooting, unnecessary for long term
68
* mongo: update driver to 5.2.1
79

810
> gsutil is deprecated and requires old version of python

TODO.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,10 @@
55
* impl own json bind by referring https://github.com/json-iterator/java and https://github.com/ngs-doo/dsl-json with annotation processor?
66

77
* framework error (queue listener, background task error, custom scheduler trigger) forward to kafka?
8-
* redis using ping/pong to validate connection? for zero downtime upgrading e.g. with gcloud memory store
98
* use adminClient to check kafka ready? or retry sending message?
109

1110
* kafka: is static membership (group.instance.id) useful within stateful set?
1211

13-
* log: use es data stream + ILM to rotate index? and is time series data stream (TSDS) useful (only for metrics data)
14-
> not able to close index, only delete, and can simplify log processor and ES interface (no need to support "index" param in all requests)
15-
> to use TSDS, convert statMessage into pure metrics, and make error/info into action?
16-
> https://www.elastic.co/guide/en/elasticsearch/reference/current/tsds.html
17-
> or framework should manage time based index by itself?
18-
1912
* db: update "on duplicated key" values() syntax,
2013
> The use of VALUES() to refer to the new row and columns is deprecated beginning with MySQL 8.0.20, and is subject to removal in a future version of MySQL.
2114
@@ -30,4 +23,8 @@
3023
https://bugs.openjdk.org/browse/JDK-8335181
3124

3225
* log diagram, fix d3 tooltip (generate separated json, and make d3 tooltip show other non-HTML info)
33-
* change kafka compression to zstd? as it is production ready and widely used
26+
27+
* redis using ping/pong to validate connection? for zero downtime upgrading e.g. with gcloud memory store
28+
* migrate to dragonflydb and support RESP3 (cluster / MOVED handling) ?
29+
* migrate to opensearch ?
30+
* log exporter, save in parquet format, or reimplement in rust?

docker/kafka/docker-compose.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
services:
22
kafka:
33
image: apache/kafka:3.9.0
4+
hostname: dev.internal
45
ports:
56
- 9092:9092
67
- 1099:1099
78
environment:
89
KAFKA_NODE_ID: 1
910
CLUSTER_ID: lK_g8qooQNOD9klGoxLojA
10-
KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099 -Djava.rmi.server.hostname=dev.internal
11+
KAFKA_JMX_PORT: 1099
12+
KAFKA_JMX_HOSTNAME: dev.internal
1113
KAFKA_JVM_PERFORMANCE_OPTS: -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -XX:MaxInlineLevel=15 -Djava.awt.headless=true
1214
KAFKA_HEAP_OPTS: -Xms1G -Xmx1G
1315
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
@@ -24,7 +26,7 @@ services:
2426
volumes:
2527
- data:/var/lib/kafka/data
2628
# mm:
27-
# image: neowu/kafka:3.6.0
29+
# image: apache/kafka:3.9.0
2830
# volumes:
2931
# - ./connect-mirror-maker.properties:/opt/kafka/config/connect-mirror-maker.properties
3032
# entrypoint: ["/bin/bash", "-c", "/opt/kafka/bin/connect-mirror-maker.sh /opt/kafka/config/connect-mirror-maker.properties"]

ext/log-exporter/src/main/java/core/log/kafka/ActionLogMessageHandler.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import java.io.BufferedOutputStream;
1212
import java.io.IOException;
13-
import java.nio.charset.StandardCharsets;
1413
import java.nio.file.Files;
1514
import java.nio.file.Path;
1615
import java.time.LocalDateTime;
@@ -37,22 +36,12 @@ public void handle(List<Message<ActionLogMessage>> messages) throws IOException
3736
for (Message<ActionLogMessage> message : messages) {
3837
ActionLogEntry entry = entry(message.value);
3938

40-
if (message.value.traceLog != null) {
41-
entry.traceLogPath = archiveService.traceLogPath(now, entry.app, entry.id);
42-
writeTraceLog(entry.traceLogPath, message.value.traceLog);
43-
}
44-
4539
stream.write(writer.toJSON(entry));
4640
stream.write('\n');
4741
}
4842
}
4943
}
5044

51-
private void writeTraceLog(String traceLogPath, String content) throws IOException {
52-
Path path = archiveService.initializeLogFilePath(traceLogPath);
53-
Files.writeString(path, content, StandardCharsets.UTF_8, CREATE, APPEND);
54-
}
55-
5645
private ActionLogEntry entry(ActionLogMessage message) {
5746
var entry = new ActionLogEntry();
5847
entry.id = message.id;

ext/log-exporter/src/main/java/core/log/service/ArchiveService.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22

33
import core.framework.crypto.Hash;
44
import core.framework.inject.Inject;
5-
import core.framework.util.Files;
65
import core.framework.util.Network;
76
import core.framework.util.Strings;
87
import org.slf4j.Logger;
98
import org.slf4j.LoggerFactory;
109

11-
import java.io.File;
1210
import java.io.IOException;
1311
import java.nio.file.Path;
1412
import java.time.LocalDate;
15-
import java.time.LocalDateTime;
1613

1714
import static java.nio.file.Files.createDirectories;
1815
import static java.nio.file.Files.exists;
@@ -45,20 +42,6 @@ public void uploadArchive(LocalDate date) {
4542
uploadService.upload(eventFilePath, eventPath);
4643
}
4744

48-
Path traceLogDirPath = Path.of(logDir.toString(), Strings.format("/trace/{}", date));
49-
if (exists(traceLogDirPath)) {
50-
File[] appDirs = traceLogDirPath.toFile().listFiles(File::isDirectory);
51-
if (appDirs != null) {
52-
for (File appDir : appDirs) {
53-
String app = appDir.getName();
54-
String traceLogPath = Strings.format("/trace/{}/{}-{}-{}.tar.gz", date, app, date, hash);
55-
Path traceLogFilePath = Path.of(logDir.toString(), traceLogPath);
56-
shell.execute("tar", "-czf", traceLogFilePath.toString(), "-C", logDir.toString(), Strings.format("trace/{}/{}", date, app));
57-
uploadService.upload(traceLogFilePath, traceLogPath);
58-
}
59-
}
60-
}
61-
6245
logger.info("uploading end, date={}", date);
6346
}
6447

@@ -70,13 +53,6 @@ public void cleanupArchive(LocalDate date) {
7053

7154
Path eventFilePath = Path.of(logDir.toString(), eventPath(date));
7255
shell.execute("rm", "-f", eventFilePath.toString());
73-
74-
Path traceLogDirPath = Path.of(logDir.toString(), Strings.format("/trace/{}", date));
75-
if (exists(traceLogDirPath)) {
76-
logger.info("delete trace logs, path={}", traceLogDirPath);
77-
// use shell (rm -rf or find) may cause pod terminate with error code 137 on mounted disk
78-
Files.deleteDir(traceLogDirPath);
79-
}
8056
}
8157

8258
public String actionLogPath(LocalDate date) {
@@ -87,10 +63,6 @@ public String eventPath(LocalDate date) {
8763
return Strings.format("/event/{}/event-{}-{}.ndjson", date.getYear(), date, hash);
8864
}
8965

90-
public String traceLogPath(LocalDateTime now, String app, String id) {
91-
return Strings.format("/trace/{}/{}/{}/{}.txt", now.toLocalDate(), app, now.getHour(), id);
92-
}
93-
9466
public Path initializeLogFilePath(String logPath) throws IOException {
9567
Path path = Path.of(logDir.toString(), logPath);
9668
Path parent = path.getParent();

ext/log-exporter/src/test/java/core/log/service/ArchiveServiceTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.junit.jupiter.api.condition.OS;
99

1010
import java.time.LocalDate;
11-
import java.time.LocalDateTime;
1211

1312
import static org.assertj.core.api.Assertions.assertThat;
1413

@@ -41,13 +40,6 @@ void eventPath() {
4140
.matches("/event/2022/event-2022-11-03-[a-z0-9]*.ndjson");
4241
}
4342

44-
@Test
45-
void traceArchivePath() {
46-
LocalDateTime now = LocalDateTime.parse("2022-11-03T02:00:00");
47-
assertThat(archiveService.traceLogPath(now, "service", "id"))
48-
.isEqualTo("/trace/2022-11-03/service/2/id.txt");
49-
}
50-
5143
@Test
5244
@EnabledOnOs({OS.MAC, OS.LINUX})
5345
void cleanupArchive() {

0 commit comments

Comments
 (0)