code: def derivative(self, name, new, max_value=0,
                     time_delta=True, interval=None,
                     allow_negative=False, instance=None):
          
          # Format Metric Path
          path = self.get_metric_path(name, instance=instance)
  
          if path in self.last_values:
              old = self.last_values[path]
              # Check for rollover
              if new < old:
                  old = old - max_value
              # Get Change in X (value)
              derivative_x = new - old
  
              # If we pass in a interval, use it rather then the configured one
              if interval is None:
                  interval = float(self.config['interval'])
  
              # Get Change in Y (time)
              if time_delta:
                  derivative_y = interval
              else:
                  derivative_y = 1
  
              result = float(derivative_x) / float(derivative_y)
              if result < 0 and not allow_negative:
                  result = 0
          else:
              result = 0
  
          # Store Old Value
          self.last_values[path] = new
  
          # Return result
          return result
docs: Calculate the derivative of the metric.