Пример #1
0
def test_execute_capture_backtrace(tracked_request):
    with n_plus_one_thresholds(count=1,
                               duration=0.0), conn_with_scout() as conn:
        result = conn.execute("SELECT 'Hello World!'")

    assert list(result) == [("Hello World!", )]
    assert len(tracked_request.complete_spans) == 1
    span = tracked_request.complete_spans[0]
    assert span.operation == "SQL/Query"
    assert span.tags["db.statement"] == "SELECT 'Hello World!'"
    assert "stack" in span.tags
Пример #2
0
def test_executemany_capture_backtrace(tracked_request):
    tracked_request.start_span(operation="parent")
    with n_plus_one_thresholds(count=2,
                               duration=0.0), conn_with_scout() as conn:
        conn.execute("CREATE TABLE t(i integer)")
        conn.execute("INSERT INTO t(i) VALUES (?)", [1], [2])

    assert len(tracked_request.complete_spans) == 2
    span = tracked_request.complete_spans[1]
    assert span.operation == "SQL/Many"
    assert span.tags["db.statement"] == "INSERT INTO t(i) VALUES (?)"
    assert "stack" in span.tags
Пример #3
0
def test_sql_capture_backtrace(tracked_requests):
    with n_plus_one_thresholds(count=1, duration=0.0), app_with_scout() as app:
        response = TestApp(app).get("/sql/")

    assert response.status_int == 200
    assert len(tracked_requests) == 1
    spans = tracked_requests[0].complete_spans
    assert [s.operation for s in spans] == [
        "SQL/Query",
        "SQL/Many",
        "SQL/Query",
        "Controller/tests.integration.django_app.sql",
        "Middleware",
    ]
    assert "stack" in spans[0].tags
    assert "stack" in spans[1].tags
    assert "stack" in spans[2].tags