def test_failed_existing_span(self):
        tracer = MockTracer()
        tracing = CommandTracing(tracer, span_tags=dict(one=123))
        event = MockEvent()
        tracing.started(event)
        scope = tracing._scopes.get('request_id')
        tracing.failed(event)
        assert tracing._scopes.get('request_id') is None

        tags = scope.span.tags
        assert tags['event.failure'] == json.dumps(event.failure)
        assert tags['reported_duration'] == event.duration_micros
Exemplo n.º 2
0
    def test_failed_existing_span(self):
        tracer = MockTracer()
        tracing = CommandTracing(tracer, span_tags=dict(one=123))
        event = MockEvent()
        event.failure = {'errmsg': 'error message', 'codeName': 'SomeError'}
        tracing.started(event)
        scope = tracing._scopes.get('request_id')
        tracing.failed(event)
        assert tracing._scopes.get('request_id') is None

        tags = scope.span.tags
        assert tags['event.failure'] == json.dumps(event.failure)
        assert tags['reported_duration'] == event.duration_micros
        assert tags['sfx.error.message'] == event.failure['errmsg']
        assert tags['sfx.error.kind'] == event.failure['codeName']
 def test_failed_no_existing_scope(self):
     tracer = MockTracer()
     tracing = CommandTracing(tracer, span_tags=dict(one=123))
     tracing.failed(MockEvent())