def test_opentracing_propagation(self):
    query = "SELECT 'tracing'"
    db = self._get_conn()
    ot_tracer = init_tracer('psycopg-svc', self.tracer)
    with ot_tracer.start_active_span('db.access'):
        cursor = db.cursor()
        cursor.execute(query)
        rows = cursor.fetchall()
    self.assertEquals(rows, [('tracing',)])
    self.assert_structure(dict(name='db.access', service='psycopg-svc'), (dict(name='postgres.query', resource=query, service='postgres', error=0, span_type='sql'),))
    assert_is_measured(self.get_spans()[1])
    self.reset()
    with self.override_config('psycopg', dict(trace_fetch_methods=True)):
        db = self._get_conn()
        ot_tracer = init_tracer('psycopg-svc', self.tracer)
        with ot_tracer.start_active_span('db.access'):
            cursor = db.cursor()
            cursor.execute(query)
            rows = cursor.fetchall()
        self.assertEquals(rows, [('tracing',)])
        self.assert_structure(dict(name='db.access', service='psycopg-svc'), (dict(name='postgres.query', resource=query, service='postgres', error=0, span_type='sql'), dict(name='postgres.query.fetchall', resource=query, service='postgres', error=0, span_type='sql')))
        assert_is_measured(self.get_spans()[1])
def test_opentracing_propagation(self):
    query = "SELECT 'tracing'"
    db = self._get_conn()
    ot_tracer = init_tracer('psycopg-svc', self.tracer)
    with ot_tracer.start_active_span('db.access'):
        cursor = db.cursor()
        cursor.execute(query)
        rows = cursor.fetchall()
    self.assertEquals(rows, [('tracing',)])
    self.assert_structure(dict(name='db.access', service='psycopg-svc'), (dict(name='postgres.query', resource=query, service='postgres', error=0, span_type='sql'),))
    assert_is_measured(self.get_spans()[1])
    self.reset()
    with self.override_config('psycopg', dict(trace_fetch_methods=True)):
        db = self._get_conn()
        ot_tracer = init_tracer('psycopg-svc', self.tracer)
        with ot_tracer.start_active_span('db.access'):
            cursor = db.cursor()
            cursor.execute(query)
            rows = cursor.fetchall()
        self.assertEquals(rows, [('tracing',)])
        self.assert_structure(dict(name='db.access', service='psycopg-svc'), (dict(name='postgres.query', resource=query, service='postgres', error=0, span_type='sql'), dict(name='postgres.query.fetchall', resource=query, service='postgres', error=0, span_type='sql')))
        assert_is_measured(self.get_spans()[1])