5 Replies Latest reply on Oct 14, 2016 4:21 PM by Cheng Fang

    metrics configuration

    kk31 Newbie

      I am using jdbcItemReader, customItemProcessor and csvItemwriter.   is there anyway we can configure metrics in job.xml in each on the steps. 


      We would like to know  how many rows read in jdbcItemReader,    how many rows we wrote to csv file.

      if its not possible at each level,  can we set it up at job level.



        • 1. Re: metrics configuration
          Cheng Fang Master

          metrics are at step level.  These are the metrics types collected (not configurable):


          Metric.MetricType (Java(TM) EE 7 Specification APIs)


          To get step metrics, call StepExecution.getMetrics():

          StepExecution (Java(TM) EE 7 Specification APIs)

          • 2. Re: metrics configuration
            kk31 Newbie

            Can we override these step metrics (or) are these read only properties?



            I tried in my itemprocessor.process(), but the values are incorrect.     Is it the right place to override  step metrics?


            StepExecutionImpl executionImpl = new StepExecutionImpl(stepContext.getStepName());
            StepMetrics   smetrics =executionImpl.getStepMetrics();
            smetrics.set(MetricType.WRITE_COUNT, this.itemsWritten);
            • 3. Re: metrics configuration
              Cheng Fang Master

              step metrics are kept and owned by the batch runtime, and should not be modified by applications.


              Applications should not instantiate JBeret internal classes like StepExecutionImpl.  Any such instances created by applications are not known to JBeret.


              You can get StepExecution from JobOperator.


              YOu can also inject StepContext into your step-level batch artifacts, and get step metrics from stepContext.


              If you really need to, your application can keep stats as part of application data, separate from the step metrics from JBeret.

              • 4. Re: metrics configuration
                kk31 Newbie

                Thanks for the suggestion.


                  our itemprocessor returns 707 rows from table and each row contains  array of strings  with default delimiter as ','  

                  In our job.xml, beanIOItemWriter/beanmapping.xml, we gave  delimiter values as '\n' , which shows the count as 7568.


                  Default stepmetrics gives write count as 707(ideally true), but since we are writing to a file as 7568 lines, we would like  get the write count as 7568.  




                I wrote my stepListener which give me this number(7568) by using stepcontext.getTransientData(Object),    but is there any settings out of the box that we can configure, so that after apply delimiter saying these many no of lines were written into file.  

                • 5. Re: metrics configuration
                  Cheng Fang Master

                  there is no such configuration for step metrics.  Step item reader, processor, and writer each counts the number of items it received, and so there is no other meansurement units like number of lines/words.