Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-11182

GraphiteSink emits wrong timestamps

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.0, 2.5.1
    • 2.6.0
    • None
    • None

    Description

      the org.apache.hadoop.metrics2.sink.GraphiteSink class emits metrics at the configured time period, but the timestamps written only change every 128 seconds, even it the configured time period in the configuration file is much shorter.

      This is due to a bug in line 93:

      092            // Round the timestamp to second as Graphite accepts it in such format.
      093            int timestamp = Math.round(record.timestamp() / 1000.0f);
      

      The timestamp property is a long and is divided by a float which yields a result that is not precise enough and yields same valued results for timestamps that lie up to 128 seconds apart. Also, the result is then written into an int variable.

      One solution would be to divide by 1000.0d, but the best fix would be to not even convert to a decimal format in the first place. Instead one could replace the line with the following:

         long timestamp = record.timestamp() / 1000L;
      

      Attachments

        1. HADOOP-11182-GraphiteSink-v1.patch
          0.9 kB
          Sascha Coenen
        2. HADOOP-11182-v2.patch
          7 kB
          Sascha Coenen
        3. HADOOP-11182-v3.patch
          4 kB
          Sascha Coenen
        4. newPatchFindbugsWarningshadoop-common.html
          47 kB
          Ravi Prakash

        Activity

          People

            raviprak Ravi Prakash
            SaschaC Sascha Coenen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: