def log(self, name, val, **tags):
global _last_timestamp, _last_metrics<EOL>assert not self.done.is_set(), "<STR_LIT>"<EOL>assert all(c in _valid_metric_chars for c in name), "<STR_LIT>" + name<EOL>val = float(val)  <EOL>if int(val) == val:<EOL><INDENT>val = int(val)<EOL><DEDENT>if self.host_tag and '<STR_LIT:host>' not in tags:<EOL><INDENT>tags['<STR_LIT:host>'] = self.host_tag<EOL><DEDENT>timestamp = int(tags.pop('<STR_LIT>', time.time()))<EOL>assert not self.done.is_set(), "<STR_LIT>"<EOL>assert tags != {}, "<STR_LIT>"<EOL>tagvals = '<STR_LIT:U+0020>'.join(['<STR_LIT>' % (k, v) for k, v in tags.items()])<EOL>unique_str = "<STR_LIT>" % (name, timestamp, tagvals, self.host, self.port)<EOL>if timestamp == _last_timestamp or _last_timestamp == None:<EOL><INDENT>if unique_str in _last_metrics:<EOL><INDENT>return  <EOL><DEDENT>else:<EOL><INDENT>_last_metrics.add(unique_str)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>_last_timestamp = timestamp<EOL>_last_metrics.clear()<EOL><DEDENT>line = "<STR_LIT>" % (name, timestamp, val, tagvals)<EOL>try:<EOL><INDENT>self.q.put(line, False)<EOL>self.queued += <NUM_LIT:1><EOL><DEDENT>except queue.Full:<EOL><INDENT>print("<STR_LIT>" % self.q.qsize(), file=sys.stderr)<EOL>self.q.get()  <EOL>self.q.put(line, False)<EOL><DEDENT>return line<EOL>
Log metric name with value val. You must include at least one tag as a kwarg