title: prometheus unit test for Summary
body: <p>Im trying to write a unit test for 'Summary' but not sure what variables I need to check?</p>
  
  <pre><code>from prometheus_client import Counter, Summary
  import unittest
  import time
  from prometheus_client import REGISTRY
  
  my_summary = Summary('my_summary', 'A useful help string.')
  
  
  def my_function():
      time.sleep(1)
      my_summary.observe(5)
  
  
  
  class TestMyFunction(unittest.TestCase):
      def test_metric_incremented(self):
         print 'here'
         before =  REGISTRY.get_sample_value('my_summary')
         print 'summary before == ', before       
         my_function()       
         after =  REGISTRY.get_sample_value('my_summary')
         print 'summary after == ', after
         self.assertEqual(0, after - before)
  
  
  
  if __name__ == '__main__':
      unittest.main()           
  </code></pre>
  
  <p>Here is my code I observe the function 5 seconds. Not sure if this is the right approach..Any test example would be great.</p>
  
  <p>I tried following this blog - <a href="https://www.robustperception.io/how-to-unit-test-prometheus-instrumentation/" rel="nofollow noreferrer">https://www.robustperception.io/how-to-unit-test-prometheus-instrumentation/</a></p>