Skip to content

Commit

Permalink
core: deprecate unused app type (#1144)
Browse files Browse the repository at this point in the history
* core: remove unused app type

* deprecate app_type
  • Loading branch information
majorgreys authored Nov 25, 2019
1 parent e73da92 commit a4b4534
Show file tree
Hide file tree
Showing 37 changed files with 45 additions and 136 deletions.
2 changes: 1 addition & 1 deletion ddtrace/contrib/aiobotocore/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/aiohttp/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/aiopg/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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__`)
Expand Down
4 changes: 1 addition & 3 deletions ddtrace/contrib/algoliasearch/patch.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/boto/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/botocore/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/cassandra/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 0 additions & 2 deletions ddtrace/contrib/celery/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/consul/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/dbapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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__`)
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/elasticsearch/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand Down
5 changes: 1 addition & 4 deletions ddtrace/contrib/flask/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/httplib/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
7 changes: 2 additions & 5 deletions ddtrace/contrib/kombu/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/mako/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions ddtrace/contrib/molten/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)),
))

Expand All @@ -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__
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/mysql/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/mysqldb/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion ddtrace/contrib/psycopg/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/pymemcache/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
3 changes: 1 addition & 2 deletions ddtrace/contrib/pymongo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/pymysql/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/redis/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/rediscluster/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand Down
2 changes: 0 additions & 2 deletions ddtrace/contrib/requests/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -30,7 +29,6 @@ def patch():
Pin(
service=config.requests['service_name'],
app='requests',
app_type=AppTypes.web,
_config=config.requests,
).onto(requests.Session)

Expand Down
3 changes: 1 addition & 2 deletions ddtrace/contrib/sqlalchemy/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit a4b4534

Please sign in to comment.