<s> import random <EOL> class Metric ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , connection , name , sample_rate = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> self . connection = connection <EOL> self . name = name <EOL> self . sample_rate = sample_rate <EOL> def clear ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def send ( self , data ) : <EOL> """<STR_LIT>""" <EOL> if self . sample_rate < <NUM_LIT:1> : <EOL> if random . random ( ) > self . sample_rate : <EOL> return <EOL> data += "<STR_LIT>" % ( self . sample_rate , ) <EOL> data = self . name + "<STR_LIT::>" + data <EOL> self . write ( data ) <EOL> def write ( self , data ) : <EOL> """<STR_LIT>""" <EOL> if self . connection is not None : <EOL> self . connection . write ( data . encode ( '<STR_LIT:utf-8>' ) ) </s>
