コード例 #1
0
import psycopg2cffi
import psycopg2cffi.extensions
import psycopg2cffi.extras

from testing_support.fixtures import (
    validate_transaction_metrics, validate_transaction_errors,
    validate_stats_engine_explain_plan_output_is_none)
from testing_support.validators.validate_transaction_slow_sql_count import \
        validate_transaction_slow_sql_count
from testing_support.validators.validate_database_trace_inputs import validate_database_trace_inputs

from testing_support.db_settings import postgresql_settings

from newrelic.api.background_task import background_task

DB_SETTINGS = postgresql_settings()[0]

_test_execute_via_cursor_scoped_metrics = [
    ('Function/psycopg2cffi:connect', 1),
    ('Function/psycopg2cffi._impl.connection:Connection.__enter__', 1),
    ('Function/psycopg2cffi._impl.connection:Connection.__exit__', 1),
    ('Datastore/statement/Postgres/%s/select' % DB_SETTINGS["table_name"], 1),
    ('Datastore/statement/Postgres/%s/insert' % DB_SETTINGS["table_name"], 1),
    ('Datastore/statement/Postgres/%s/update' % DB_SETTINGS["table_name"], 1),
    ('Datastore/statement/Postgres/%s/delete' % DB_SETTINGS["table_name"], 1),
    ('Datastore/statement/Postgres/now/call', 1),
    ('Datastore/statement/Postgres/pg_sleep/call', 1),
    ('Datastore/operation/Postgres/drop', 1),
    ('Datastore/operation/Postgres/create', 1),
    ('Datastore/operation/Postgres/commit', 3),
    ('Datastore/operation/Postgres/rollback', 1)
コード例 #2
0
# limitations under the License.

import asyncio

import asyncpg
import pytest
from testing_support.db_settings import postgresql_settings
from testing_support.fixtures import (
    override_application_settings,
    validate_transaction_metrics,
)
from testing_support.util import instance_hostname

from newrelic.api.background_task import background_task

DB_MULTIPLE_SETTINGS = postgresql_settings()

ASYNCPG_VERSION = tuple(
    int(x) for x in getattr(asyncpg, "__version__", "0.0").split(".")[:2])

if ASYNCPG_VERSION < (0, 11):
    CONNECT_METRICS = []

    # Only 1 statement will be recorded since connect is not captured
    STATEMENT_COUNT = 1

    # 2 DBs are queried
    TOTAL_COUNT = STATEMENT_COUNT * 2
else:
    CONNECT_METRICS = [("Datastore/operation/Postgres/connect", 2)]