@classmethod
def from_dict(cls, connection, data):
    """Returns a metric object from a dictionary item,
        which is usually from librato's API"""
    obj = cls(connection, data['name'])
    obj.display_name = data['display_name'] if 'display_name' in data else None
    obj.events = data['events'] if 'events' in data else None
    obj.query = data['query'] if 'query' in data else {}
    return obj
