Esempio n. 1
0
def tracer():
    tracer = DummyTracer()
    patch()
    try:
        yield tracer
    finally:
        unpatch()
Esempio n. 2
0
def test_user_specified_dd_mariadb_service_snapshot():
    """
    When a user specifies a service for the app
        The mariadb integration should not use it.
    """
    import mariadb

    from ddtrace import config  # noqa
    from ddtrace import patch
    from ddtrace import tracer

    patch(mariadb=True)
    from tests.contrib.config import MARIADB_CONFIG

    connection = mariadb.connect(**MARIADB_CONFIG)
    cursor = connection.cursor()
    cursor.execute("SELECT 1")
    rows = cursor.fetchall()
    assert len(rows) == 1
    tracer.shutdown()
Esempio n. 3
0
    assert span.service == "mariadb"
    assert span.name == "mariadb.connection.rollback"


def test_analytics_default(connection, tracer):
    cursor = connection.cursor()
    cursor.execute("SELECT 1")
    rows = cursor.fetchall()
    assert len(rows) == 1
    spans = tracer.pop()
    assert len(spans) == 1
    span = spans[0]
    assert span.get_metric(ANALYTICS_SAMPLE_RATE_KEY) is None


test_user_specified_code = """
from ddtrace import config
from ddtrace import patch
from ddtrace import tracer
import mariadb
patch(mariadb=True)
from tests.contrib.config import MARIADB_CONFIG
connection = mariadb.connect(**MARIADB_CONFIG)
cursor = connection.cursor()
cursor.execute("SELECT 1")
rows = cursor.fetchall()
assert len(rows) == 1
tracer.shutdown()
"""