def test_func_span():
    tracer = Tracer()
    span = tracer.start_trace(operation_name='parent')
    with RequestContextManager(span=span):
        with func_span('test') as child_span:
            assert span is child_span
        with func_span('test', tags={'x': 'y'}) as child_span:
            assert span is child_span
def test_db_span():
    tracer = Tracer()
    span = tracer.start_trace(operation_name='parent')
    with RequestContextManager(span=span):
        with db_span(_COMMIT, 'MySQLdb') as child_span:
            assert span is child_span
        with db_span('select * from X', 'MySQLdb') as child_span:
            assert span is child_span
def test_tracer():
    tracer = Tracer()
    span = tracer.start_trace(operation_name='root')
    child = tracer.join_trace(operation_name='child',
                              parent_trace_context=span.trace_context)
    assert span == child
    assert span.trace_context == child.trace_context
    fut = tracer.close()
    assert type(fut) is Future
    fut.result(timeout=1)