Skip to content

Commit 97fc120

Browse files
improve logs
1 parent 9d13bff commit 97fc120

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

.idea/runConfigurations/kafka_clients_example.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

superstream-clients/dependency-reduced-pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>ai.superstream</groupId>
55
<artifactId>superstream-clients</artifactId>
66
<name>Superstream Kafka Client Optimizer</name>
7-
<version>1.0.204</version>
7+
<version>1.0.205</version>
88
<description>A Java library that dynamically optimizes Kafka client configuration based on recommendations</description>
99
<url>https://github.com/superstreamlabs/superstream-clients-java</url>
1010
<developers>

superstream-clients/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>ai.superstream</groupId>
88
<artifactId>superstream-clients</artifactId>
9-
<version>1.0.204</version>
9+
<version>1.0.205</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Superstream Kafka Client Optimizer</name>

superstream-clients/src/main/java/ai/superstream/core/ConfigurationOptimizer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,23 @@ public Map<String, Object> getOptimalConfiguration(MetadataMessage metadataMessa
5252
} else {
5353
logger.debug(
5454
"No matching topic configurations found for the application topics. Applying default optimizations.");
55+
logger.warn(
56+
"The topics you're publishing to haven't been analyzed yet. For optimal results, either wait for the next analysis cycle or trigger one manually via the SuperClient Console");
5557
}
5658

5759
// Apply default optimizations when no matching topics found
5860
optimalConfiguration = new HashMap<>();
5961
optimalConfiguration.put("compression.type", "zstd");
60-
optimalConfiguration.put("batch.size", 16384); // 16KB
62+
optimalConfiguration.put("batch.size", 32768); // 32KB
6163

6264
// Only add linger if not latency-sensitive
6365
if (!isLatencySensitive) {
6466
optimalConfiguration.put("linger.ms", 5000); // 5 seconds default
6567
logger.debug(
66-
"Default optimizations will be applied: compression.type=zstd, batch.size=16384, linger.ms=5000");
68+
"Default optimizations will be applied: compression.type=zstd, batch.size=32768, linger.ms=5000");
6769
} else {
6870
logger.debug(
69-
"Default optimizations will be applied: compression.type=zstd, batch.size=16384 (linger.ms unchanged)");
71+
"Default optimizations will be applied: compression.type=zstd, batch.size=32768 (linger.ms unchanged)");
7072
}
7173
return optimalConfiguration;
7274
}

superstream-clients/src/main/java/ai/superstream/core/SuperstreamManager.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,25 @@ public boolean optimizeProducer(String bootstrapServers, String clientId, Proper
219219
""
220220
);
221221

222-
// Log optimization success with linger.ms status based on environment variable
222+
// Log optimization success with appropriate message based on configuration and client ID
223223
boolean isLatencySensitive = configurationOptimizer.isLatencySensitive();
224+
boolean isUsingDefaults = applicationTopics != null && !applicationTopics.isEmpty() &&
225+
(metadataMessage.getTopicsConfiguration() == null ||
226+
metadataMessage.getTopicsConfiguration().stream().noneMatch(tc -> applicationTopics.contains(tc.getTopicName())));
227+
228+
String baseMessage = isUsingDefaults ?
229+
"Successfully optimized producer with default optimization parameters" :
230+
"Successfully optimized producer configuration";
231+
232+
if (clientId != null && !clientId.trim().isEmpty()) {
233+
baseMessage += " for " + clientId;
234+
}
235+
224236
if (isLatencySensitive) {
225-
logger.info("Successfully optimized producer configuration for {} (linger.ms left unchanged due to latency sensitivity)", clientId);
226-
} else {
227-
logger.info("Successfully optimized producer configuration for {}", clientId);
237+
baseMessage += " (linger.ms left unchanged due to latency sensitivity)";
228238
}
239+
240+
logger.info(baseMessage);
229241
return true;
230242
} catch (Exception e) {
231243
logger.error("[ERR-030] Failed to optimize producer configuration: {}", e.getMessage(), e);

0 commit comments

Comments
 (0)