def test_numeric_tags_value(self):
     s = Span(tracer=None, name='test.span')
     s.set_tag(ANALYTICS_SAMPLE_RATE_KEY, 0.5)
     d = s.to_dict()
     assert d
     expected = {
         ANALYTICS_SAMPLE_RATE_KEY: 0.5
     }
     assert d['metrics'] == expected
    def test_span_boolean_err(self):
        s = Span(tracer=None, name='foo.bar', service='s', resource='r')
        s.error = True
        s.finish()

        d = s.to_dict()
        assert d
        assert d['error'] == 1
        assert type(d['error']) == int
 def test_tags(self):
     s = Span(tracer=None, name='test.span')
     s.set_tag('a', 'a')
     s.set_tag('b', 1)
     s.set_tag('c', '1')
     d = s.to_dict()
     expected = {
         'a': 'a',
         'b': '1',
         'c': '1',
     }
     assert d['meta'] == expected
 def test_set_valid_metrics(self):
     s = Span(tracer=None, name='test.span')
     s.set_metric('a', 0)
     s.set_metric('b', -12)
     s.set_metric('c', 12.134)
     s.set_metric('d', 1231543543265475686787869123)
     s.set_metric('e', '12.34')
     d = s.to_dict()
     expected = {
         'a': 0,
         'b': -12,
         'c': 12.134,
         'd': 1231543543265475686787869123,
         'e': 12.34,
     }
     assert d['metrics'] == expected
    def test_span_to_dict(self):
        s = Span(tracer=None, name='test.span', service='s', resource='r')
        s.span_type = 'foo'
        s.set_tag('a', '1')
        s.set_meta('b', '2')
        s.finish()

        d = s.to_dict()
        assert d
        assert d['span_id'] == s.span_id
        assert d['trace_id'] == s.trace_id
        assert d['parent_id'] == s.parent_id
        assert d['meta'] == {'a': '1', 'b': '2'}
        assert d['type'] == 'foo'
        assert d['error'] == 0
        assert type(d['error']) == int
 def test_numeric_tags_bad_value(self):
     s = Span(tracer=None, name='test.span')
     s.set_tag(ANALYTICS_SAMPLE_RATE_KEY, 'Hello')
     d = s.to_dict()
     assert d
     assert 'metrics' not in d