예제 #1
0
파일: metric.py 프로젝트: DataDog/dogapi
    def _post(self, args):
        self.dog.timeout = args.timeout
        if args.localhostname:
            host = find_localhost()
        else:
            host = args.host
        if args.tags:
            tags = sorted(set([t.strip() for t in
                               args.tags.split(',') if t]))
        else:
            tags = None

        # are we sending a counter?
        if args.counter:
            metric_type = MetricType.Counter
        else:
            metric_type = MetricType.Gauge
        res = self.dog.metric(args.name, args.value, host=host,
            device=args.device, tags=tags, metric_type=metric_type)
        report_warnings(res)
        report_errors(res)
예제 #2
0
    def _post(self, args):
        self.dog.timeout = args.timeout
        if args.localhostname:
            host = find_localhost()
        else:
            host = args.host
        if args.tags:
            tags = sorted(set([t.strip() for t in args.tags.split(',') if t]))
        else:
            tags = None

        # are we sending a counter?
        if args.counter:
            metric_type = MetricType.Counter
        else:
            metric_type = MetricType.Gauge
        res = self.dog.metric(args.name,
                              args.value,
                              host=host,
                              device=args.device,
                              tags=tags,
                              metric_type=metric_type)
        report_warnings(res)
        report_errors(res)
예제 #3
0
 def test_find_localhost(self):
     # Once run
     assert socket.getfqdn() == find_localhost()
     # Once memoized
     assert socket.getfqdn() == find_localhost()