55package io .streamshub .mcp .strimzi .service ;
66
77import com .fasterxml .jackson .databind .ObjectMapper ;
8+ import io .opentelemetry .instrumentation .annotations .WithSpan ;
89import io .quarkiverse .mcp .server .Cancellation ;
910import io .quarkiverse .mcp .server .Elicitation ;
1011import io .quarkiverse .mcp .server .McpLog ;
@@ -210,11 +211,12 @@ public KafkaClusterDiagnosticReport diagnose(final String namespace,
210211
211212 // ---- Phase 1: Initial data gathering ----
212213
213- private KafkaClusterResponse gatherClusterStatus (final String namespace ,
214- final String clusterName ,
215- final Elicitation elicitation ,
216- final List <String > completed ,
217- final McpLog mcpLog ) {
214+ @ WithSpan ("diagnose.cluster.status" )
215+ KafkaClusterResponse gatherClusterStatus (final String namespace ,
216+ final String clusterName ,
217+ final Elicitation elicitation ,
218+ final List <String > completed ,
219+ final McpLog mcpLog ) {
218220 try {
219221 KafkaClusterResponse result = kafkaService .getCluster (namespace , clusterName );
220222 completed .add (STEP_CLUSTER_STATUS );
@@ -231,11 +233,12 @@ private KafkaClusterResponse gatherClusterStatus(final String namespace,
231233 }
232234 }
233235
234- private List <KafkaNodePoolResponse > gatherNodePools (final String namespace ,
235- final String clusterName ,
236- final List <String > completed ,
237- final List <String > failed ,
238- final McpLog mcpLog ) {
236+ @ WithSpan ("diagnose.cluster.node_pools" )
237+ List <KafkaNodePoolResponse > gatherNodePools (final String namespace ,
238+ final String clusterName ,
239+ final List <String > completed ,
240+ final List <String > failed ,
241+ final McpLog mcpLog ) {
239242 try {
240243 List <KafkaNodePoolResponse > result = nodePoolService .listNodePools (namespace , clusterName );
241244 completed .add (STEP_NODE_POOLS );
@@ -248,11 +251,12 @@ private List<KafkaNodePoolResponse> gatherNodePools(final String namespace,
248251 }
249252 }
250253
251- private KafkaClusterPodsResponse gatherClusterPods (final String namespace ,
252- final String clusterName ,
253- final List <String > completed ,
254- final List <String > failed ,
255- final McpLog mcpLog ) {
254+ @ WithSpan ("diagnose.cluster.pods" )
255+ KafkaClusterPodsResponse gatherClusterPods (final String namespace ,
256+ final String clusterName ,
257+ final List <String > completed ,
258+ final List <String > failed ,
259+ final McpLog mcpLog ) {
256260 try {
257261 KafkaClusterPodsResponse result = kafkaService .getClusterPods (namespace , clusterName );
258262 completed .add (STEP_POD_HEALTH );
@@ -267,10 +271,11 @@ private KafkaClusterPodsResponse gatherClusterPods(final String namespace,
267271
268272 // ---- Phase 2: Deep investigation ----
269273
270- private StrimziOperatorResponse gatherOperatorStatus (final String namespace ,
271- final List <String > completed ,
272- final List <String > failed ,
273- final McpLog mcpLog ) {
274+ @ WithSpan ("diagnose.cluster.operator_status" )
275+ StrimziOperatorResponse gatherOperatorStatus (final String namespace ,
276+ final List <String > completed ,
277+ final List <String > failed ,
278+ final McpLog mcpLog ) {
274279 try {
275280 List <StrimziOperatorResponse > operators = operatorService .listOperators (namespace );
276281 if (!operators .isEmpty ()) {
@@ -288,11 +293,12 @@ private StrimziOperatorResponse gatherOperatorStatus(final String namespace,
288293 }
289294 }
290295
291- private StrimziOperatorLogsResponse gatherOperatorLogs (final String namespace ,
292- final Integer sinceMinutes ,
293- final List <String > completed ,
294- final List <String > failed ,
295- final McpLog mcpLog ) {
296+ @ WithSpan ("diagnose.cluster.operator_logs" )
297+ StrimziOperatorLogsResponse gatherOperatorLogs (final String namespace ,
298+ final Integer sinceMinutes ,
299+ final List <String > completed ,
300+ final List <String > failed ,
301+ final McpLog mcpLog ) {
296302 try {
297303 StrimziOperatorLogsResponse result = operatorService .getOperatorLogs (
298304 namespace , null , buildErrorLogParams (sinceMinutes ));
@@ -306,12 +312,13 @@ private StrimziOperatorLogsResponse gatherOperatorLogs(final String namespace,
306312 }
307313 }
308314
309- private KafkaClusterLogsResponse gatherClusterLogs (final String namespace ,
310- final String clusterName ,
311- final Integer sinceMinutes ,
312- final List <String > completed ,
313- final List <String > failed ,
314- final McpLog mcpLog ) {
315+ @ WithSpan ("diagnose.cluster.logs" )
316+ KafkaClusterLogsResponse gatherClusterLogs (final String namespace ,
317+ final String clusterName ,
318+ final Integer sinceMinutes ,
319+ final List <String > completed ,
320+ final List <String > failed ,
321+ final McpLog mcpLog ) {
315322 try {
316323 KafkaClusterLogsResponse result = kafkaService .getClusterLogs (
317324 namespace , clusterName , buildErrorLogParams (sinceMinutes ));
@@ -325,12 +332,13 @@ private KafkaClusterLogsResponse gatherClusterLogs(final String namespace,
325332 }
326333 }
327334
328- private StrimziEventsResponse gatherEvents (final String namespace ,
329- final String clusterName ,
330- final Integer sinceMinutes ,
331- final List <String > completed ,
332- final List <String > failed ,
333- final McpLog mcpLog ) {
335+ @ WithSpan ("diagnose.cluster.events" )
336+ StrimziEventsResponse gatherEvents (final String namespace ,
337+ final String clusterName ,
338+ final Integer sinceMinutes ,
339+ final List <String > completed ,
340+ final List <String > failed ,
341+ final McpLog mcpLog ) {
334342 try {
335343 StrimziEventsResponse result = eventsService .getClusterEvents (
336344 namespace , clusterName , sinceMinutes );
@@ -344,11 +352,12 @@ private StrimziEventsResponse gatherEvents(final String namespace,
344352 }
345353 }
346354
347- private KafkaMetricsResponse gatherMetrics (final String namespace ,
348- final String clusterName ,
349- final List <String > completed ,
350- final List <String > failed ,
351- final McpLog mcpLog ) {
355+ @ WithSpan ("diagnose.cluster.metrics" )
356+ KafkaMetricsResponse gatherMetrics (final String namespace ,
357+ final String clusterName ,
358+ final List <String > completed ,
359+ final List <String > failed ,
360+ final McpLog mcpLog ) {
352361 try {
353362 KafkaMetricsResponse result = kafkaMetricsService .getKafkaMetrics (
354363 namespace , clusterName , "replication" , null , null , null , null , null );
@@ -364,11 +373,12 @@ private KafkaMetricsResponse gatherMetrics(final String namespace,
364373
365374 // ---- Sampling: triage and analysis ----
366375
367- private InvestigationAreas decideInvestigationAreas (final Sampling sampling ,
368- final KafkaClusterResponse cluster ,
369- final List <KafkaNodePoolResponse > nodePools ,
370- final KafkaClusterPodsResponse pods ,
371- final String symptom ) {
376+ @ WithSpan ("diagnose.cluster.triage" )
377+ InvestigationAreas decideInvestigationAreas (final Sampling sampling ,
378+ final KafkaClusterResponse cluster ,
379+ final List <KafkaNodePoolResponse > nodePools ,
380+ final KafkaClusterPodsResponse pods ,
381+ final String symptom ) {
372382 if (sampling == null || !sampling .isSupported ()) {
373383 return InvestigationAreas .all ();
374384 }
@@ -392,17 +402,18 @@ private InvestigationAreas decideInvestigationAreas(final Sampling sampling,
392402 }
393403 }
394404
405+ @ WithSpan ("diagnose.cluster.analysis" )
395406 @ SuppressWarnings ("checkstyle:ParameterNumber" )
396- private String produceAnalysis (final Sampling sampling ,
397- final KafkaClusterResponse cluster ,
398- final List <KafkaNodePoolResponse > nodePools ,
399- final KafkaClusterPodsResponse pods ,
400- final StrimziOperatorResponse operator ,
401- final StrimziOperatorLogsResponse operatorLogs ,
402- final KafkaClusterLogsResponse clusterLogs ,
403- final StrimziEventsResponse events ,
404- final KafkaMetricsResponse metrics ,
405- final String symptom ) {
407+ String produceAnalysis (final Sampling sampling ,
408+ final KafkaClusterResponse cluster ,
409+ final List <KafkaNodePoolResponse > nodePools ,
410+ final KafkaClusterPodsResponse pods ,
411+ final StrimziOperatorResponse operator ,
412+ final StrimziOperatorLogsResponse operatorLogs ,
413+ final KafkaClusterLogsResponse clusterLogs ,
414+ final StrimziEventsResponse events ,
415+ final KafkaMetricsResponse metrics ,
416+ final String symptom ) {
406417 if (sampling == null || !sampling .isSupported ()) {
407418 return null ;
408419 }
0 commit comments