Skip to content

Commit 655978b

Browse files
report error as part of the metadata
1 parent a77e4db commit 655978b

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ public class ClientReporter {
4040
* @param optimizedConfiguration The optimized configuration
4141
* @param mostImpactfulTopic The most impactful topic
4242
* @param producerUuid The producer UUID to include in the report
43+
* @param error The error string to include in the report
4344
* @return True if the message was sent successfully, false otherwise
4445
*/
4546
public boolean reportClient(String bootstrapServers, Properties originalClientProperties, int superstreamClusterId, boolean active,
4647
String clientId, Map<String, Object> originalConfiguration,
4748
Map<String, Object> optimizedConfiguration,
48-
String mostImpactfulTopic, String producerUuid) {
49+
String mostImpactfulTopic, String producerUuid,
50+
String error) {
4951
Properties properties = new Properties();
5052

5153
// Copy all authentication-related and essential properties from the original client
@@ -74,7 +76,8 @@ public boolean reportClient(String bootstrapServers, Properties originalClientPr
7476
optimizedConfiguration,
7577
mostImpactfulTopic,
7678
NetworkUtils.getHostname(),
77-
producerUuid
79+
producerUuid,
80+
error
7881
);
7982

8083
// Convert the message to JSON

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ public boolean optimizeProducer(String bootstrapServers, String clientId, Proper
116116

117117
// Check if optimization is active
118118
if (!metadataMessage.isActive()) {
119-
logger.error("[ERR-054] Superstream optimization is not active for this kafka cluster, please head to the Superstream console and activate it.");
120-
reportClientInformation(bootstrapServers, properties, metadataMessage, clientId, originalProperties, Collections.emptyMap());
119+
String errMsg = "[ERR-054] Superstream optimization is not active for this kafka cluster, please head to the Superstream console and activate it.";
120+
logger.error(errMsg);
121+
reportClientInformation(bootstrapServers, properties, metadataMessage, clientId, originalProperties, Collections.emptyMap(), errMsg);
121122
return false;
122123
}
123124

@@ -133,7 +134,7 @@ public boolean optimizeProducer(String bootstrapServers, String clientId, Proper
133134

134135
if (modifiedKeys.isEmpty()) {
135136
logger.debug("No configuration parameters were modified");
136-
reportClientInformation(bootstrapServers, properties, metadataMessage, clientId, originalProperties, Collections.emptyMap());
137+
reportClientInformation(bootstrapServers, properties, metadataMessage, clientId, originalProperties, Collections.emptyMap(), "");
137138
return false;
138139
}
139140

@@ -180,7 +181,8 @@ public boolean optimizeProducer(String bootstrapServers, String clientId, Proper
180181
metadataMessage,
181182
clientId,
182183
originalProperties,
183-
optimizedProperties
184+
optimizedProperties,
185+
""
184186
);
185187

186188
// Log optimization success with linger.ms status based on environment variable
@@ -250,7 +252,8 @@ private List<String> getApplicationTopics() {
250252
*/
251253
private void reportClientInformation(String bootstrapServers, Properties originalProperties, MetadataMessage metadataMessage,
252254
String clientId, Properties originalConfiguration,
253-
Map<String, Object> optimizedConfiguration) {
255+
Map<String, Object> optimizedConfiguration,
256+
String error) {
254257
try {
255258
Map<String, Object> originalConfiguration1 = convertPropertiesToMap(originalConfiguration);
256259
List<String> topics = getApplicationTopics();
@@ -272,7 +275,8 @@ private void reportClientInformation(String bootstrapServers, Properties origina
272275
originalConfiguration1,
273276
optimizedConfiguration,
274277
mostImpactfulTopic,
275-
producerUuid
278+
producerUuid,
279+
error
276280
);
277281

278282
if (!success) {

superstream-clients/src/main/java/ai/superstream/model/ClientMessage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public ClientMessage() {
3030

3131
public ClientMessage(int superstreamClusterId, boolean active, String clientId, String ipAddress, String clientVersion, String language, String clientType,
3232
Map<String, Object> originalConfiguration, Map<String, Object> optimizedConfiguration,
33-
String mostImpactfulTopic, String hostname, String producerUuid) {
33+
String mostImpactfulTopic, String hostname, String producerUuid, String error) {
3434
this.superstreamClusterId = superstreamClusterId;
3535
this.active = active;
3636
this.clientId = clientId;
@@ -44,6 +44,7 @@ public ClientMessage(int superstreamClusterId, boolean active, String clientId,
4444
this.environmentVariables = ai.superstream.util.EnvironmentVariables.getSuperstreamEnvironmentVariables();
4545
this.hostname = hostname;
4646
this.producerUuid = producerUuid;
47+
this.error = error;
4748
}
4849

4950
@JsonProperty("superstream_cluster_id")

0 commit comments

Comments
 (0)