def build_message(self, metric, value, timestamp, tags={}):
if not metric or metric.split(None, <NUM_LIT:1>)[<NUM_LIT:0>] != metric:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if not isinstance(value, (int, float)):<EOL><INDENT>raise TypeError('<STR_LIT>'.format(<EOL>type(value).__name__))<EOL><DEDENT>tags_suffix = '<STR_LIT>'.join('<STR_LIT>'.format(x[<NUM_LIT:0>], x[<NUM_LIT:1>]) for x in sorted(tags.items()))<EOL>message = u'<STR_LIT>'.format(<EOL>self.prefix + '<STR_LIT:.>' if self.prefix else '<STR_LIT>',<EOL>metric,<EOL>tags_suffix,<EOL>value,<EOL>int(round(timestamp))<EOL>)<EOL>message = message.encode('<STR_LIT:utf-8>')<EOL>return message<EOL>
Build a Graphite message to send and return it as a byte string.