From 61bed442b86af0e91650c9e718703061404705d5 Mon Sep 17 00:00:00 2001 From: "Tahir H. Butt" Date: Thu, 21 Nov 2019 11:08:40 -0500 Subject: [PATCH 1/2] core: remove unused app type --- ddtrace/contrib/aiobotocore/patch.py | 2 +- ddtrace/contrib/aiohttp/patch.py | 2 +- ddtrace/contrib/aiopg/connection.py | 4 +- ddtrace/contrib/algoliasearch/patch.py | 4 +- ddtrace/contrib/boto/patch.py | 4 +- ddtrace/contrib/botocore/patch.py | 2 +- ddtrace/contrib/cassandra/session.py | 2 +- ddtrace/contrib/celery/app.py | 2 - ddtrace/contrib/consul/patch.py | 2 +- ddtrace/contrib/dbapi/__init__.py | 4 +- ddtrace/contrib/elasticsearch/patch.py | 4 +- ddtrace/contrib/flask/patch.py | 5 +-- ddtrace/contrib/httplib/patch.py | 2 +- ddtrace/contrib/kombu/patch.py | 7 +--- ddtrace/contrib/mako/patch.py | 2 +- ddtrace/contrib/molten/patch.py | 6 +-- ddtrace/contrib/mysql/patch.py | 4 +- ddtrace/contrib/mysqldb/patch.py | 4 +- ddtrace/contrib/psycopg/patch.py | 1 - ddtrace/contrib/pymemcache/patch.py | 2 +- ddtrace/contrib/pymongo/client.py | 3 +- ddtrace/contrib/pymysql/patch.py | 4 +- ddtrace/contrib/redis/patch.py | 4 +- ddtrace/contrib/rediscluster/patch.py | 4 +- ddtrace/contrib/requests/patch.py | 2 - ddtrace/contrib/sqlalchemy/engine.py | 3 +- ddtrace/contrib/sqlite3/patch.py | 3 +- ddtrace/contrib/tornado/application.py | 2 +- ddtrace/contrib/vertica/patch.py | 5 +-- ddtrace/ext/__init__.py | 5 --- ddtrace/ext/apps.py | 0 ddtrace/ext/consul.py | 3 -- ddtrace/ext/sql.py | 4 -- ddtrace/pin.py | 7 +--- ddtrace/tracer.py | 4 -- tests/contrib/sqlite3/test_sqlite3.py | 3 -- tests/test_integration.py | 53 -------------------------- 37 files changed, 39 insertions(+), 135 deletions(-) delete mode 100644 ddtrace/ext/apps.py diff --git a/ddtrace/contrib/aiobotocore/patch.py b/ddtrace/contrib/aiobotocore/patch.py index 9e5905e17f6..6c376b5ca92 100644 --- a/ddtrace/contrib/aiobotocore/patch.py +++ b/ddtrace/contrib/aiobotocore/patch.py @@ -23,7 +23,7 @@ def patch(): setattr(aiobotocore.client, '_datadog_patch', True) wrapt.wrap_function_wrapper('aiobotocore.client', 'AioBaseClient._make_api_call', _wrapped_api_call) - Pin(service='aws', app='aws', app_type='web').onto(aiobotocore.client.AioBaseClient) + Pin(service='aws', app='aws').onto(aiobotocore.client.AioBaseClient) def unpatch(): diff --git a/ddtrace/contrib/aiohttp/patch.py b/ddtrace/contrib/aiohttp/patch.py index 0a5f0c15c22..81b6deae11a 100644 --- a/ddtrace/contrib/aiohttp/patch.py +++ b/ddtrace/contrib/aiohttp/patch.py @@ -26,7 +26,7 @@ def patch(): _w = wrapt.wrap_function_wrapper _w('aiohttp_jinja2', 'render_template', _trace_render_template) - Pin(app='aiohttp', service=None, app_type='web').onto(aiohttp_jinja2) + Pin(app='aiohttp', service=None).onto(aiohttp_jinja2) def unpatch(): diff --git a/ddtrace/contrib/aiopg/connection.py b/ddtrace/contrib/aiopg/connection.py index da21fd94d47..7e34ba4eb79 100644 --- a/ddtrace/contrib/aiopg/connection.py +++ b/ddtrace/contrib/aiopg/connection.py @@ -5,7 +5,7 @@ from .. import dbapi from ...constants import ANALYTICS_SAMPLE_RATE_KEY -from ...ext import sql, AppTypes +from ...ext import sql from ...pin import Pin from ...settings import config @@ -77,7 +77,7 @@ class AIOTracedConnection(wrapt.ObjectProxy): def __init__(self, conn, pin=None, cursor_cls=AIOTracedCursor): super(AIOTracedConnection, self).__init__(conn) name = dbapi._get_vendor(conn) - db_pin = pin or Pin(service=name, app=name, app_type=AppTypes.db) + db_pin = pin or Pin(service=name, app=name) db_pin.onto(self) # wrapt requires prefix of `_self` for attributes that are only in the # proxy (since some of our source objects will use `__slots__`) diff --git a/ddtrace/contrib/algoliasearch/patch.py b/ddtrace/contrib/algoliasearch/patch.py index 633e48d1f67..0cc7db0674c 100644 --- a/ddtrace/contrib/algoliasearch/patch.py +++ b/ddtrace/contrib/algoliasearch/patch.py @@ -1,4 +1,3 @@ -from ddtrace.ext import AppTypes from ddtrace.pin import Pin from ddtrace.settings import config from ddtrace.utils.wrappers import unwrap as _u @@ -34,8 +33,7 @@ def patch(): setattr(algoliasearch, '_datadog_patch', True) pin = Pin( - service=config.algoliasearch.service_name, app=APP_NAME, - app_type=AppTypes.db + service=config.algoliasearch.service_name, app=APP_NAME ) if algoliasearch_version < (2, 0) and algoliasearch_version >= (1, 0): diff --git a/ddtrace/contrib/boto/patch.py b/ddtrace/contrib/boto/patch.py index 0814ac3f849..a30b432bde4 100644 --- a/ddtrace/contrib/boto/patch.py +++ b/ddtrace/contrib/boto/patch.py @@ -41,10 +41,10 @@ def patch(): wrapt.wrap_function_wrapper( 'boto.connection', 'AWSAuthConnection.make_request', patched_auth_request ) - Pin(service='aws', app='aws', app_type='web').onto( + Pin(service='aws', app='aws').onto( boto.connection.AWSQueryConnection ) - Pin(service='aws', app='aws', app_type='web').onto( + Pin(service='aws', app='aws').onto( boto.connection.AWSAuthConnection ) diff --git a/ddtrace/contrib/botocore/patch.py b/ddtrace/contrib/botocore/patch.py index 066ba021d2f..65045fabd87 100644 --- a/ddtrace/contrib/botocore/patch.py +++ b/ddtrace/contrib/botocore/patch.py @@ -28,7 +28,7 @@ def patch(): setattr(botocore.client, '_datadog_patch', True) wrapt.wrap_function_wrapper('botocore.client', 'BaseClient._make_api_call', patched_api_call) - Pin(service='aws', app='aws', app_type='web').onto(botocore.client.BaseClient) + Pin(service='aws', app='aws').onto(botocore.client.BaseClient) def unpatch(): diff --git a/ddtrace/contrib/cassandra/session.py b/ddtrace/contrib/cassandra/session.py index 35b5eb5fc16..95a7e3a9462 100644 --- a/ddtrace/contrib/cassandra/session.py +++ b/ddtrace/contrib/cassandra/session.py @@ -32,7 +32,7 @@ def patch(): """ patch will add tracing to the cassandra library. """ setattr(cassandra.cluster.Cluster, 'connect', wrapt.FunctionWrapper(_connect, traced_connect)) - Pin(service=SERVICE, app=SERVICE, app_type='db').onto(cassandra.cluster.Cluster) + Pin(service=SERVICE, app=SERVICE).onto(cassandra.cluster.Cluster) def unpatch(): diff --git a/ddtrace/contrib/celery/app.py b/ddtrace/contrib/celery/app.py index 85eaea7fbd6..0c3a835c7f8 100644 --- a/ddtrace/contrib/celery/app.py +++ b/ddtrace/contrib/celery/app.py @@ -2,7 +2,6 @@ from ddtrace import Pin, config from ddtrace.pin import _DD_PIN_NAME -from ddtrace.ext import AppTypes from .constants import APP from .signals import ( @@ -27,7 +26,6 @@ def patch_app(app, pin=None): pin = pin or Pin( service=config.celery['worker_service_name'], app=APP, - app_type=AppTypes.worker, _config=config.celery, ) pin.onto(app) diff --git a/ddtrace/contrib/consul/patch.py b/ddtrace/contrib/consul/patch.py index 646357c3123..aec3390aeb7 100644 --- a/ddtrace/contrib/consul/patch.py +++ b/ddtrace/contrib/consul/patch.py @@ -17,7 +17,7 @@ def patch(): return setattr(consul, '__datadog_patch', True) - pin = Pin(service=consulx.SERVICE, app=consulx.APP, app_type=consulx.APP_TYPE) + pin = Pin(service=consulx.SERVICE, app=consulx.APP) pin.onto(consul.Consul.KV) for f_name in _KV_FUNCS: diff --git a/ddtrace/contrib/dbapi/__init__.py b/ddtrace/contrib/dbapi/__init__.py index 3d3d2059512..44324824001 100644 --- a/ddtrace/contrib/dbapi/__init__.py +++ b/ddtrace/contrib/dbapi/__init__.py @@ -3,7 +3,7 @@ """ from ...constants import ANALYTICS_SAMPLE_RATE_KEY -from ...ext import AppTypes, sql +from ...ext import sql from ...internal.logger import get_logger from ...pin import Pin from ...settings import config @@ -155,7 +155,7 @@ def __init__(self, conn, pin=None, cursor_cls=None): super(TracedConnection, self).__init__(conn) name = _get_vendor(conn) self._self_datadog_name = '{}.connection'.format(name) - db_pin = pin or Pin(service=name, app=name, app_type=AppTypes.db) + db_pin = pin or Pin(service=name, app=name) db_pin.onto(self) # wrapt requires prefix of `_self` for attributes that are only in the # proxy (since some of our source objects will use `__slots__`) diff --git a/ddtrace/contrib/elasticsearch/patch.py b/ddtrace/contrib/elasticsearch/patch.py index 046f2f4ad3e..9e8fa980fd0 100644 --- a/ddtrace/contrib/elasticsearch/patch.py +++ b/ddtrace/contrib/elasticsearch/patch.py @@ -6,7 +6,7 @@ from ...compat import urlencode from ...constants import ANALYTICS_SAMPLE_RATE_KEY -from ...ext import elasticsearch as metadata, http, AppTypes +from ...ext import elasticsearch as metadata, http from ...pin import Pin from ...utils.wrappers import unwrap as _u from ...settings import config @@ -32,7 +32,7 @@ def _patch(elasticsearch): return setattr(elasticsearch, '_datadog_patch', True) _w(elasticsearch.transport, 'Transport.perform_request', _get_perform_request(elasticsearch)) - Pin(service=metadata.SERVICE, app=metadata.APP, app_type=AppTypes.db).onto(elasticsearch.transport.Transport) + Pin(service=metadata.SERVICE, app=metadata.APP).onto(elasticsearch.transport.Transport) def unpatch(): diff --git a/ddtrace/contrib/flask/patch.py b/ddtrace/contrib/flask/patch.py index 3b4c07f3008..0dc9bb2e6e5 100644 --- a/ddtrace/contrib/flask/patch.py +++ b/ddtrace/contrib/flask/patch.py @@ -8,7 +8,6 @@ from ddtrace import config, Pin from ...constants import ANALYTICS_SAMPLE_RATE_KEY -from ...ext import AppTypes from ...ext import http from ...internal.logger import get_logger from ...propagation.http import HTTPPropagator @@ -29,7 +28,6 @@ # DEV: Environment variable 'DATADOG_SERVICE_NAME' used for backwards compatibility service_name=os.environ.get('DATADOG_SERVICE_NAME') or 'flask', app='flask', - app_type=AppTypes.web, collect_view_args=True, distributed_tracing_enabled=True, @@ -70,8 +68,7 @@ def patch(): # Attach service pin to `flask.app.Flask` Pin( service=config.flask['service_name'], - app=config.flask['app'], - app_type=config.flask['app_type'], + app=config.flask['app'] ).onto(flask.Flask) # flask.app.Flask methods that have custom tracing (add metadata, wrap functions, etc) diff --git a/ddtrace/contrib/httplib/patch.py b/ddtrace/contrib/httplib/patch.py index 65c40af2332..f401dcd39e2 100644 --- a/ddtrace/contrib/httplib/patch.py +++ b/ddtrace/contrib/httplib/patch.py @@ -17,7 +17,7 @@ def _wrap_init(func, instance, args, kwargs): - Pin(app='httplib', service=None, app_type=ext_http.TYPE).onto(instance) + Pin(app='httplib', service=None).onto(instance) return func(*args, **kwargs) diff --git a/ddtrace/contrib/kombu/patch.py b/ddtrace/contrib/kombu/patch.py index a4a2062a1ad..9790f20737b 100644 --- a/ddtrace/contrib/kombu/patch.py +++ b/ddtrace/contrib/kombu/patch.py @@ -5,7 +5,6 @@ # project from ...constants import ANALYTICS_SAMPLE_RATE_KEY from ...ext import kombu as kombux -from ...ext import AppTypes from ...pin import Pin from ...propagation.http import HTTPPropagator from ...settings import config @@ -48,14 +47,12 @@ def patch(): _w(kombux.TYPE, 'Consumer.receive', traced_receive) Pin( service=config.kombu['service_name'], - app='kombu', - app_type=AppTypes.worker, + app='kombu' ).onto(kombu.messaging.Producer) Pin( service=config.kombu['service_name'], - app='kombu', - app_type=AppTypes.worker, + app='kombu' ).onto(kombu.messaging.Consumer) diff --git a/ddtrace/contrib/mako/patch.py b/ddtrace/contrib/mako/patch.py index ebc179e2d0c..fa574ab82d1 100644 --- a/ddtrace/contrib/mako/patch.py +++ b/ddtrace/contrib/mako/patch.py @@ -15,7 +15,7 @@ def patch(): return setattr(mako, '__datadog_patch', True) - Pin(service='mako', app='mako', app_type=http.TEMPLATE).onto(Template) + Pin(service='mako', app='mako').onto(Template) _w(mako, 'template.Template.render', _wrap_render) _w(mako, 'template.Template.render_unicode', _wrap_render) diff --git a/ddtrace/contrib/molten/patch.py b/ddtrace/contrib/molten/patch.py index be0596944c4..62003cea7b5 100644 --- a/ddtrace/contrib/molten/patch.py +++ b/ddtrace/contrib/molten/patch.py @@ -6,7 +6,7 @@ from ... import Pin, config from ...compat import urlencode from ...constants import ANALYTICS_SAMPLE_RATE_KEY -from ...ext import AppTypes, http +from ...ext import http from ...propagation.http import HTTPPropagator from ...utils.formats import asbool, get_env from ...utils.importlib import func_name @@ -19,7 +19,6 @@ config._add('molten', dict( service_name=get_env('molten', 'service_name', 'molten'), app='molten', - app_type=AppTypes.web, distributed_tracing=asbool(get_env('molten', 'distributed_tracing', True)), )) @@ -33,8 +32,7 @@ def patch(): pin = Pin( service=config.molten['service_name'], - app=config.molten['app'], - app_type=config.molten['app_type'], + app=config.molten['app'] ) # add pin to module since many classes use __slots__ diff --git a/ddtrace/contrib/mysql/patch.py b/ddtrace/contrib/mysql/patch.py index 30b49e8bc0e..15a0b1aa516 100644 --- a/ddtrace/contrib/mysql/patch.py +++ b/ddtrace/contrib/mysql/patch.py @@ -5,7 +5,7 @@ # project from ddtrace import Pin from ddtrace.contrib.dbapi import TracedConnection -from ...ext import net, db, AppTypes +from ...ext import net, db CONN_ATTR_BY_TAG = { @@ -38,7 +38,7 @@ def _connect(func, instance, args, kwargs): def patch_conn(conn): tags = {t: getattr(conn, a) for t, a in CONN_ATTR_BY_TAG.items() if getattr(conn, a, '') != ''} - pin = Pin(service='mysql', app='mysql', app_type=AppTypes.db, tags=tags) + pin = Pin(service='mysql', app='mysql', tags=tags) # grab the metadata from the conn wrapped = TracedConnection(conn, pin=pin) diff --git a/ddtrace/contrib/mysqldb/patch.py b/ddtrace/contrib/mysqldb/patch.py index ddc72dc7851..ac6e0e1d4e2 100644 --- a/ddtrace/contrib/mysqldb/patch.py +++ b/ddtrace/contrib/mysqldb/patch.py @@ -7,7 +7,7 @@ from ddtrace import Pin from ddtrace.contrib.dbapi import TracedConnection -from ...ext import net, db, AppTypes +from ...ext import net, db from ...utils.wrappers import unwrap as _u KWPOS_BY_TAG = { @@ -55,7 +55,7 @@ def patch_conn(conn, *args, **kwargs): for t, (k, p) in KWPOS_BY_TAG.items() if k in kwargs or len(args) > p} tags[net.TARGET_PORT] = conn.port - pin = Pin(service='mysql', app='mysql', app_type=AppTypes.db, tags=tags) + pin = Pin(service='mysql', app='mysql', tags=tags) # grab the metadata from the conn wrapped = TracedConnection(conn, pin=pin) diff --git a/ddtrace/contrib/psycopg/patch.py b/ddtrace/contrib/psycopg/patch.py index 913a49fd8ee..3aeb68b7134 100644 --- a/ddtrace/contrib/psycopg/patch.py +++ b/ddtrace/contrib/psycopg/patch.py @@ -89,7 +89,6 @@ def patch_conn(conn, traced_conn_cls=Psycopg2TracedConnection): Pin( service='postgres', app='postgres', - app_type='db', tags=tags).onto(c) return c diff --git a/ddtrace/contrib/pymemcache/patch.py b/ddtrace/contrib/pymemcache/patch.py index 5fdad8e1754..6ab0cabc073 100644 --- a/ddtrace/contrib/pymemcache/patch.py +++ b/ddtrace/contrib/pymemcache/patch.py @@ -16,7 +16,7 @@ def patch(): # Create a global pin with default configuration for our pymemcache clients Pin( - app=memcachedx.SERVICE, service=memcachedx.SERVICE, app_type=memcachedx.TYPE + app=memcachedx.SERVICE, service=memcachedx.SERVICE ).onto(pymemcache) diff --git a/ddtrace/contrib/pymongo/client.py b/ddtrace/contrib/pymongo/client.py index 59271901781..25eea416670 100644 --- a/ddtrace/contrib/pymongo/client.py +++ b/ddtrace/contrib/pymongo/client.py @@ -10,7 +10,6 @@ import ddtrace from ...compat import iteritems from ...constants import ANALYTICS_SAMPLE_RATE_KEY -from ...ext import AppTypes from ...ext import mongo as mongox from ...ext import net as netx from ...internal.logger import get_logger @@ -62,7 +61,7 @@ def __init__(self, client=None, *args, **kwargs): client._topology = TracedTopology(client._topology) # Default Pin - ddtrace.Pin(service=mongox.TYPE, app=mongox.TYPE, app_type=AppTypes.db).onto(self) + ddtrace.Pin(service=mongox.TYPE, app=mongox.TYPE).onto(self) def __setddpin__(self, pin): pin.onto(self._topology) diff --git a/ddtrace/contrib/pymysql/patch.py b/ddtrace/contrib/pymysql/patch.py index 8ea8cf4c3d1..ccb56781f8d 100644 --- a/ddtrace/contrib/pymysql/patch.py +++ b/ddtrace/contrib/pymysql/patch.py @@ -5,7 +5,7 @@ # project from ddtrace import Pin from ddtrace.contrib.dbapi import TracedConnection -from ...ext import net, db, AppTypes +from ...ext import net, db CONN_ATTR_BY_TAG = { net.TARGET_HOST: 'host', @@ -31,7 +31,7 @@ def _connect(func, instance, args, kwargs): def patch_conn(conn): tags = {t: getattr(conn, a, '') for t, a in CONN_ATTR_BY_TAG.items()} - pin = Pin(service='pymysql', app='pymysql', app_type=AppTypes.db, tags=tags) + pin = Pin(service='pymysql', app='pymysql', tags=tags) # grab the metadata from the conn wrapped = TracedConnection(conn, pin=pin) diff --git a/ddtrace/contrib/redis/patch.py b/ddtrace/contrib/redis/patch.py index 66fe8debecb..51361c390e6 100644 --- a/ddtrace/contrib/redis/patch.py +++ b/ddtrace/contrib/redis/patch.py @@ -6,7 +6,7 @@ from ddtrace import config from ...constants import ANALYTICS_SAMPLE_RATE_KEY from ...pin import Pin -from ...ext import AppTypes, redis as redisx +from ...ext import redis as redisx from ...utils.wrappers import unwrap from .util import format_command_args, _extract_conn_tags @@ -34,7 +34,7 @@ def patch(): _w('redis', 'Redis.pipeline', traced_pipeline) _w('redis.client', 'Pipeline.execute', traced_execute_pipeline) _w('redis.client', 'Pipeline.immediate_execute_command', traced_execute_command) - Pin(service=redisx.DEFAULT_SERVICE, app=redisx.APP, app_type=AppTypes.db).onto(redis.StrictRedis) + Pin(service=redisx.DEFAULT_SERVICE, app=redisx.APP).onto(redis.StrictRedis) def unpatch(): diff --git a/ddtrace/contrib/rediscluster/patch.py b/ddtrace/contrib/rediscluster/patch.py index d73466a17d7..66c2d59c960 100644 --- a/ddtrace/contrib/rediscluster/patch.py +++ b/ddtrace/contrib/rediscluster/patch.py @@ -6,7 +6,7 @@ from ddtrace import config from ...constants import ANALYTICS_SAMPLE_RATE_KEY from ...pin import Pin -from ...ext import AppTypes, redis as redisx +from ...ext import redis as redisx from ...utils.wrappers import unwrap from ..redis.patch import traced_execute_command, traced_pipeline from ..redis.util import format_command_args @@ -23,7 +23,7 @@ def patch(): _w('rediscluster', 'StrictRedisCluster.execute_command', traced_execute_command) _w('rediscluster', 'StrictRedisCluster.pipeline', traced_pipeline) _w('rediscluster', 'StrictClusterPipeline.execute', traced_execute_pipeline) - Pin(service=redisx.DEFAULT_SERVICE, app=redisx.APP, app_type=AppTypes.db).onto(rediscluster.StrictRedisCluster) + Pin(service=redisx.DEFAULT_SERVICE, app=redisx.APP).onto(rediscluster.StrictRedisCluster) def unpatch(): diff --git a/ddtrace/contrib/requests/patch.py b/ddtrace/contrib/requests/patch.py index 7317ee13355..0072481514c 100644 --- a/ddtrace/contrib/requests/patch.py +++ b/ddtrace/contrib/requests/patch.py @@ -10,7 +10,6 @@ from .legacy import _distributed_tracing, _distributed_tracing_setter from .constants import DEFAULT_SERVICE from .connection import _wrap_send -from ...ext import AppTypes # requests default settings config._add('requests', { @@ -30,7 +29,6 @@ def patch(): Pin( service=config.requests['service_name'], app='requests', - app_type=AppTypes.web, _config=config.requests, ).onto(requests.Session) diff --git a/ddtrace/contrib/sqlalchemy/engine.py b/ddtrace/contrib/sqlalchemy/engine.py index a3fb1af96a2..5f3f3c2c6b1 100644 --- a/ddtrace/contrib/sqlalchemy/engine.py +++ b/ddtrace/contrib/sqlalchemy/engine.py @@ -63,8 +63,7 @@ def __init__(self, tracer, service, engine): Pin( app=self.vendor, tracer=tracer, - service=self.service, - app_type=sqlx.APP_TYPE, + service=self.service ).onto(engine) listen(engine, 'before_cursor_execute', self._before_cur_exec) diff --git a/ddtrace/contrib/sqlite3/patch.py b/ddtrace/contrib/sqlite3/patch.py index c60f8322e6d..3cae546b2f3 100644 --- a/ddtrace/contrib/sqlite3/patch.py +++ b/ddtrace/contrib/sqlite3/patch.py @@ -5,7 +5,6 @@ # project from ...contrib.dbapi import TracedConnection, TracedCursor, FetchTracedCursor -from ...ext import AppTypes from ...pin import Pin from ...settings import config @@ -32,7 +31,7 @@ def traced_connect(func, _, args, kwargs): def patch_conn(conn): wrapped = TracedSQLite(conn) - Pin(service='sqlite', app='sqlite', app_type=AppTypes.db).onto(wrapped) + Pin(service='sqlite', app='sqlite').onto(wrapped) return wrapped diff --git a/ddtrace/contrib/tornado/application.py b/ddtrace/contrib/tornado/application.py index 079c32d697f..a413197d39b 100644 --- a/ddtrace/contrib/tornado/application.py +++ b/ddtrace/contrib/tornado/application.py @@ -53,4 +53,4 @@ def tracer_config(__init__, app, args, kwargs): tracer.set_tags(tags) # configure the PIN object for template rendering - ddtrace.Pin(app='tornado', service=service, app_type='web', tracer=tracer).onto(template) + ddtrace.Pin(app='tornado', service=service, tracer=tracer).onto(template) diff --git a/ddtrace/contrib/vertica/patch.py b/ddtrace/contrib/vertica/patch.py index dfe3aecc2c2..b2a09c394c6 100644 --- a/ddtrace/contrib/vertica/patch.py +++ b/ddtrace/contrib/vertica/patch.py @@ -5,7 +5,7 @@ import ddtrace from ...constants import ANALYTICS_SAMPLE_RATE_KEY from ...ext import db as dbx, sql -from ...ext import net, AppTypes +from ...ext import net from ...internal.logger import get_logger from ...pin import Pin from ...settings import config @@ -46,7 +46,6 @@ def cursor_span_end(instance, cursor, _, conf, *args, **kwargs): pin = Pin( service=config.vertica['service_name'], app=APP, - app_type=AppTypes.db, tags=tags, _config=config.vertica['patch']['vertica_python.vertica.cursor.Cursor'], ) @@ -59,7 +58,6 @@ def cursor_span_end(instance, cursor, _, conf, *args, **kwargs): { 'service_name': 'vertica', 'app': 'vertica', - 'app_type': 'db', 'patch': { 'vertica_python.vertica.connection.Connection': { 'routines': { @@ -168,7 +166,6 @@ def init_wrapper(wrapped, instance, args, kwargs): Pin( service=config['service_name'], app=config['app'], - app_type=config['app_type'], tags=config.get('tags', {}), tracer=config.get('tracer', ddtrace.tracer), _config=config['patch'][patch_item], diff --git a/ddtrace/ext/__init__.py b/ddtrace/ext/__init__.py index cabf64ef81f..e69de29bb2d 100644 --- a/ddtrace/ext/__init__.py +++ b/ddtrace/ext/__init__.py @@ -1,5 +0,0 @@ -class AppTypes(object): - web = 'web' - db = 'db' - cache = 'cache' - worker = 'worker' diff --git a/ddtrace/ext/apps.py b/ddtrace/ext/apps.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/ddtrace/ext/consul.py b/ddtrace/ext/consul.py index d8653d738db..be17e922361 100644 --- a/ddtrace/ext/consul.py +++ b/ddtrace/ext/consul.py @@ -1,7 +1,4 @@ -from . import AppTypes - APP = 'consul' -APP_TYPE = AppTypes.cache SERVICE = 'consul' CMD = 'consul.command' diff --git a/ddtrace/ext/sql.py b/ddtrace/ext/sql.py index b9b93c371f3..b65c5e87a83 100644 --- a/ddtrace/ext/sql.py +++ b/ddtrace/ext/sql.py @@ -1,9 +1,5 @@ -from ddtrace.ext import AppTypes - - # the type of the spans TYPE = 'sql' -APP_TYPE = AppTypes.db # tags QUERY = 'sql.query' # the query text diff --git a/ddtrace/pin.py b/ddtrace/pin.py index 9e58f7ca099..eec136d77e4 100644 --- a/ddtrace/pin.py +++ b/ddtrace/pin.py @@ -29,7 +29,6 @@ class Pin(object): def __init__(self, service, app=None, app_type=None, tags=None, tracer=None, _config=None): tracer = tracer or ddtrace.tracer self.app = app - self.app_type = app_type self.tags = tags self.tracer = tracer self._target = None @@ -53,8 +52,8 @@ def __setattr__(self, name, value): super(Pin, self).__setattr__(name, value) def __repr__(self): - return 'Pin(service=%s, app=%s, app_type=%s, tags=%s, tracer=%s)' % ( - self.service, self.app, self.app_type, self.tags, self.tracer) + return 'Pin(service=%s, app=%s, tags=%s, tracer=%s)' % ( + self.service, self.app, self.tags, self.tracer) @staticmethod def _find(*objs): @@ -121,7 +120,6 @@ def override(cls, obj, service=None, app=None, app_type=None, tags=None, tracer= pin.clone( service=service, app=app, - app_type=app_type, tags=tags, tracer=tracer, ).onto(obj) @@ -175,7 +173,6 @@ def clone(self, service=None, app=None, app_type=None, tags=None, tracer=None): return Pin( service=service or self.service, app=app or self.app, - app_type=app_type or self.app_type, tags=tags, tracer=tracer or self.tracer, # do not clone the Tracer _config=config, diff --git a/ddtrace/tracer.py b/ddtrace/tracer.py index 7160d15bce7..67a8957311e 100644 --- a/ddtrace/tracer.py +++ b/ddtrace/tracer.py @@ -533,10 +533,6 @@ def write(self, spans): @deprecated(message='Manually setting service info is no longer necessary', version='1.0.0') def set_service_info(self, *args, **kwargs): """Set the information about the given service. - - :param str service: the internal name of the service (e.g. acme_search, datadog_web) - :param str app: the off the shelf name of the application (e.g. rails, postgres, custom-app) - :param str app_type: the type of the application (e.g. db, web) """ return diff --git a/tests/contrib/sqlite3/test_sqlite3.py b/tests/contrib/sqlite3/test_sqlite3.py index 2a069124be9..45277ccc46b 100644 --- a/tests/contrib/sqlite3/test_sqlite3.py +++ b/tests/contrib/sqlite3/test_sqlite3.py @@ -53,7 +53,6 @@ def test_sqlite(self): db = sqlite3.connect(':memory:') pin = Pin.get_from(db) assert pin - self.assertEqual('db', pin.app_type) pin.clone( service=service, tracer=self.tracer).onto(db) @@ -194,7 +193,6 @@ def test_sqlite_ot(self): db = sqlite3.connect(':memory:') pin = Pin.get_from(db) assert pin - self.assertEqual('db', pin.app_type) pin.clone(tracer=self.tracer).onto(db) cursor = db.execute(q) rows = cursor.fetchall() @@ -213,7 +211,6 @@ def test_sqlite_ot(self): db = sqlite3.connect(':memory:') pin = Pin.get_from(db) assert pin - self.assertEqual('db', pin.app_type) pin.clone(tracer=self.tracer).onto(db) cursor = db.execute(q) rows = cursor.fetchall() diff --git a/tests/test_integration.py b/tests/test_integration.py index 89b85e53843..8752413342a 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -277,21 +277,6 @@ def test_send_presampler_headers(self, mocked_http): for k, v in expected_headers.items(): assert v == headers[k] - @mock.patch('ddtrace.api.httplib.HTTPConnection') - def test_send_presampler_headers_not_in_services(self, mocked_http): - # register some services and send them to the trace agent - services = [{ - 'client.service': { - 'app': 'django', - 'app_type': 'web', - }, - }] - - # make a call and retrieve the `conn` Mock object - self.api_msgpack.send_services(services) - request_call = mocked_http.return_value.request - assert request_call.call_count == 0 - def _send_traces_and_check(self, traces, nresponses=1): # test JSON encoder responses = self.api_json.send_traces(traces) @@ -367,44 +352,6 @@ def test_send_multiple_traces_multiple_spans(self): self._send_traces_and_check(traces) - def test_send_single_service(self): - # register some services and send them to the trace agent - services = [{ - 'client.service': { - 'app': 'django', - 'app_type': 'web', - }, - }] - - # test JSON encoder - response = self.api_json.send_services(services) - assert response is None - - # test Msgpack encoder - response = self.api_msgpack.send_services(services) - assert response is None - - def test_send_service_called_multiple_times(self): - # register some services and send them to the trace agent - services = [{ - 'backend': { - 'app': 'django', - 'app_type': 'web', - }, - 'database': { - 'app': 'postgres', - 'app_type': 'db', - }, - }] - - # test JSON encoder - response = self.api_json.send_services(services) - assert response is None - - # test Msgpack encoder - response = self.api_msgpack.send_services(services) - assert response is None - @skipUnless( os.environ.get('TEST_DATADOG_INTEGRATION', False), From 873dbeb60d832fae35473e9810c109c1074b6317 Mon Sep 17 00:00:00 2001 From: "Tahir H. Butt" Date: Fri, 22 Nov 2019 13:19:13 -0500 Subject: [PATCH 2/2] deprecate app_type --- ddtrace/pin.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ddtrace/pin.py b/ddtrace/pin.py index eec136d77e4..c64755b491a 100644 --- a/ddtrace/pin.py +++ b/ddtrace/pin.py @@ -1,5 +1,7 @@ import ddtrace +from ddtrace.vendor import debtcollector + from .internal.logger import get_logger from .vendor import wrapt @@ -24,8 +26,9 @@ class Pin(object): >>> pin = Pin.override(conn, service='user-db') >>> conn = sqlite.connect('/tmp/image.db') """ - __slots__ = ['app', 'app_type', 'tags', 'tracer', '_target', '_config', '_initialized'] + __slots__ = ['app', 'tags', 'tracer', '_target', '_config', '_initialized'] + @debtcollector.removals.removed_kwarg("app_type") def __init__(self, service, app=None, app_type=None, tags=None, tracer=None, _config=None): tracer = tracer or ddtrace.tracer self.app = app @@ -100,6 +103,7 @@ def get_from(obj): return pin @classmethod + @debtcollector.removals.removed_kwarg("app_type") def override(cls, obj, service=None, app=None, app_type=None, tags=None, tracer=None): """Override an object with the given attributes. @@ -156,6 +160,7 @@ def remove_from(self, obj): except AttributeError: log.debug("can't remove pin from object. skipping", exc_info=True) + @debtcollector.removals.removed_kwarg("app_type") def clone(self, service=None, app=None, app_type=None, tags=None, tracer=None): """Return a clone of the pin with the given attributes replaced.""" # do a shallow copy of Pin dicts