|
18 | 18 | import java.util.concurrent.atomic.AtomicReference; |
19 | 19 | import java.lang.ThreadLocal; |
20 | 20 | import java.util.Collections; |
| 21 | +import java.util.List; |
| 22 | +import java.util.Arrays; |
21 | 23 |
|
22 | 24 | /** |
23 | 25 | * Intercepts KafkaProducer constructor calls to optimize configurations and |
@@ -206,7 +208,10 @@ public static void onEnter(@Advice.AllArguments Object[] args) { |
206 | 208 | properties.putAll(originalProperties); |
207 | 209 | // Push ConfigInfo with original config for stats reporting |
208 | 210 | java.util.Deque<ConfigInfo> cfgStack = TL_CFG_STACK.get(); |
209 | | - cfgStack.push(new ConfigInfo(originalPropertiesMap, new java.util.HashMap<>())); |
| 211 | + // Check if there's an existing ConfigInfo with an error |
| 212 | + ConfigInfo existingConfig = cfgStack.isEmpty() ? null : cfgStack.peek(); |
| 213 | + String error = existingConfig != null ? existingConfig.error : null; |
| 214 | + cfgStack.push(new ConfigInfo(originalPropertiesMap, new java.util.HashMap<>(), error)); |
210 | 215 | } |
211 | 216 | } catch (Exception e) { |
212 | 217 | logger.error("[ERR-053] Error during producer optimization: {}", e.getMessage(), e); |
@@ -291,21 +296,21 @@ public static void onExit(@Advice.This Object producer) { |
291 | 296 |
|
292 | 297 | // Set the most impactful topic if possible |
293 | 298 | try { |
294 | | - ai.superstream.model.MetadataMessage metadataMessage = null; |
295 | | - java.util.List<String> topics = null; |
| 299 | + MetadataMessage metadataMessage = null; |
| 300 | + List<String> topics = null; |
296 | 301 | // Try to get metadata and topics if available |
297 | 302 | if (producerProps != null) { |
298 | 303 | String bootstrapServersProp = producerProps.getProperty("bootstrap.servers"); |
299 | 304 | if (bootstrapServersProp != null) { |
300 | | - metadataMessage = ai.superstream.core.SuperstreamManager.getInstance().getOrFetchMetadataMessage(bootstrapServersProp, producerProps); |
| 305 | + metadataMessage = SuperstreamManager.getInstance().getOrFetchMetadataMessage(bootstrapServersProp, producerProps); |
301 | 306 | } |
302 | 307 | String topicsEnv = System.getenv("SUPERSTREAM_TOPICS_LIST"); |
303 | 308 | if (topicsEnv != null && !topicsEnv.trim().isEmpty()) { |
304 | | - topics = java.util.Arrays.asList(topicsEnv.split(",")); |
| 309 | + topics = Arrays.asList(topicsEnv.split(",")); |
305 | 310 | } |
306 | 311 | } |
307 | 312 | if (metadataMessage != null && topics != null) { |
308 | | - String mostImpactfulTopic = ai.superstream.core.SuperstreamManager.getInstance().getConfigurationOptimizer().getMostImpactfulTopicName(metadataMessage, topics); |
| 313 | + String mostImpactfulTopic = SuperstreamManager.getInstance().getConfigurationOptimizer().getMostImpactfulTopicName(metadataMessage, topics); |
309 | 314 | if (mostImpactfulTopic == null) { |
310 | 315 | mostImpactfulTopic = ""; |
311 | 316 | } |
|
0 commit comments