{"record":{"id":"70c0d7916199c150","repo":"pentaho/pentaho-kettle","slug":"you-can-not-get-metrics-for-the-current-step","errorCode":null,"errorMessage":"You can not get metrics for the current step [","messagePattern":"You can not get metrics for the current step \\[","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/stepsmetrics/StepsMetrics.java","lineNumber":90,"sourceCode":"      // check for output fields\n      data.realstepnamefield = environmentSubstitute( meta.getStepNameFieldName() );\n      data.realstepidfield = environmentSubstitute( meta.getStepIdFieldName() );\n      data.realsteplinesinputfield = environmentSubstitute( meta.getStepLinesInputFieldName() );\n      data.realsteplinesoutputfield = environmentSubstitute( meta.getStepLinesOutputFieldName() );\n      data.realsteplinesreadfield = environmentSubstitute( meta.getStepLinesReadFieldName() );\n      data.realsteplineswrittentfield = environmentSubstitute( meta.getStepLinesWrittenFieldName() );\n      data.realsteplinesupdatedfield = environmentSubstitute( meta.getStepLinesUpdatedFieldName() );\n      data.realsteplineserrorsfield = environmentSubstitute( meta.getStepLinesErrorsFieldName() );\n      data.realstepsecondsfield = environmentSubstitute( meta.getStepSecondsFieldName() );\n\n      // Get target stepnames\n      String[] targetSteps = getTransMeta().getNextStepNames( getStepMeta() );\n\n      data.stepInterfaces = new ConcurrentHashMap<Integer, StepInterface>();\n      for ( int i = 0; i < stepnrs; i++ ) {\n        // We can not get metrics from current step\n        if ( stepnames[i].equals( getStepname() ) ) {\n          throw new KettleException( \"You can not get metrics for the current step [\" + stepnames[i] + \"]!\" );\n        }\n        if ( targetSteps != null ) {\n          // We can not metrics from the target steps\n          for ( int j = 0; j < targetSteps.length; j++ ) {\n            if ( stepnames[i].equals( targetSteps[j] ) ) {\n              throw new KettleException( \"You can not get metrics for the target step [\" + targetSteps[j] + \"]!\" );\n            }\n          }\n        }\n\n        int CopyNr = Const.toInt( meta.getStepCopyNr()[i], 0 );\n        StepInterface si = getTrans().getStepInterface( stepnames[i], CopyNr );\n        if ( si != null ) {\n          data.stepInterfaces.put( i, getDispatcher().findBaseSteps( stepnames[i] ).get( CopyNr ) );\n        } else {\n          if ( meta.getStepRequired()[i].equals( StepsMetricsMeta.YES ) ) {\n            throw new KettleException( \"We cannot get step [\" + stepnames[i] + \"] CopyNr=\" + CopyNr + \"!\" );\n          }","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/stepsmetrics/StepsMetrics.java#L72-L108","documentation":"StepsMetrics collects runtime metrics from other steps in the same transformation. Referencing itself (the monitoring step's own name) in the monitored-steps list creates a cycle that cannot be resolved, so processRow throws this KettleException naming the offending step. The metrics of a step running this very code cannot be sampled by that step itself.","triggerScenarios":"The monitored 'step name' grid contains the same name as the StepsMetrics step itself (getStepname()), detected at processRow time when iterating stepnames.","commonSituations":"Renaming a monitored step to match the metrics step's name; misreading the dialog as 'steps to include' and adding the metrics step itself; generating the config programmatically with a self-reference.","solutions":["Remove the StepsMetrics step's own name from its monitored-steps grid.","Rename the metrics step (e.g. 'Metrics sampler') so it cannot collide with monitored names.","Re-check the list after renames — the check compares literal step names.","If generating metadata in code, assert !monitored.equals(metricsStepName) before saving."],"exampleFix":"// before: self-reference\nmeta.setStepName(new String[] { \"Metrics\", \"Sort rows\" }); // 'Metrics' is this step\n// after: monitor only other steps\nmeta.setStepName(new String[] { \"Sort rows\", \"Filter rows\" });","handlingStrategy":"validation","validationCode":"for (String monitored : meta.getStepName()) {\n  if (monitored.equals(metricsStepMeta.getName())) {\n    throw new IllegalArgumentException(\"StepsMetrics cannot monitor itself: \" + monitored);\n  }\n}","typeGuard":"boolean noSelfReference(StepsMetricsMeta m, StepMeta self) {\n  String[] names = m.getStepName();\n  return names != null && java.util.Arrays.stream(names).noneMatch(n -> n.equals(self.getName()));\n}","tryCatchPattern":"try {\n  trans.execute(null);\n} catch (KettleException e) {\n  if (e.getMessage().startsWith(\"You can not get metrics for the current step [\")) {\n    throw new IllegalStateException(\"StepsMetrics self-reference in monitored list\", e);\n  }\n  throw e;\n}","preventionTips":["Give the metrics step a distinctive name (e.g. 'Metrics sampler') so it never collides with monitored steps.","Re-verify monitored lists after renaming any step in the transformation.","Assert no self-reference when generating StepsMetrics metadata in code."],"tags":["configuration","self-reference","steps-metrics"],"backgroundTag":"invalid-argument-value","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}