#NEWLINE# def test_report_now( self ) : #NEWLINE# #INDENT# r = NewRelicReporter ( 'license_key' , registry = self . registry , reporting_interval = 1 , clock = self . clock , name = 'foo' ) #NEWLINE# h1 = self . registry . histogram ( 'hist' ) #NEWLINE# for i in range ( 10 ) : #NEWLINE# #INDENT# h1 . add ( ( 2 ** i ) ) #NEWLINE# #UNINDENT# t1 = self . registry . timer ( 't1' ) #NEWLINE# m1 = self . registry . meter ( 'm1' ) #NEWLINE# m1 . mark ( ) #NEWLINE# with t1 . time ( ) : #NEWLINE# #INDENT# c1 = self . registry . counter ( 'c1' ) #NEWLINE# c2 = self . registry . counter ( 'counter-2' ) #NEWLINE# c1 . inc ( ) #NEWLINE# c2 . dec ( ) #NEWLINE# c2 . dec ( ) #NEWLINE# self . clock . add ( 1 ) #NEWLINE# #UNINDENT# output = r . collect_metrics ( self . registry ) #NEWLINE# expected = ( '{"agent": {"host": "%s", "pid": %s, "version": "0.3.2"}, "components": [{"duration": 1, "guid": "com.github.pyformance", "metrics": {"Component/t1": {"count": 1, "max": 1, "min": 1, "sum_of_squares": 1, "total": 1}}, "name": "foo"}]}' % ( socket . gethostname ( ) , os . getpid ( ) ) ) #NEWLINE# self . assertEqual ( expected . replace ( '.0' , '' ) , output . replace ( '.0' , '' ) )