Skip to content

Commit 70e6eba

Browse files
Yun-Kimmajorgreys
authored andcommitted
chore: remove deprecated items (#6580)
This PR adds a note to upgrade to 2.x in `upgrading.rst` and removes all deprecated items slated for removal in 2.0.0. This includes: - `DD_GEVENT_PATCH_ALL`: no special configuration is now necessary to make `ddtrace-run` work with gevent. - `DD_AWS_TAG_ALL_PARAMS`: the boto/botocore/aiobotocore integrations no longer collect all API parameters by default. - `DD_REMOTECONFIG_POLL_SECONDS`: replaced by `DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS` - ASM deprecated constants including ``APPSEC_ENABLED``, ``APPSEC_JSON``, ``APPSEC_EVENT_RULE_VERSION``, ``APPSEC_EVENT_RULE_ERRORS``, ``APPSEC_EVENT_RULE_LOADED``, ``APPSEC_EVENT_RULE_ERROR_COUNT``, ``APPSEC_WAF_DURATION``, ``APPSEC_WAF_DURATION_EXT``, ``APPSEC_WAF_TIMEOUTS``, ``APPSEC_WAF_VERSION``, ``APPSEC_ORIGIN_VALUE``, ``APPSEC_BLOCKED``, ``IAST_JSON``, ``IAST_ENABLED``, ``IAST_CONTEXT_KEY``. These constants were meant for private use only and should not affect existing code. - ``ddtrace.contrib.grpc.constants.GRPC_PORT_KEY``: replaced by `ddtrace.ext.net.TARGET_PORT` - ``ddtrace.ext.cassandra.ROW_COUNT``, ``ddtrace.ext.mongo.ROW_COUNT``, ``ddtrace.ext.sql.ROW_COUNT``: replaced by `ddtrace.ext.db.ROWCOUNT` - `ddtrace.filters.TraceCiVisibilityFilter`: removed as this was for private use only and does not affect existing code. - `ddtrace.contrib.starlette.get_resource` and `ddtrace.contrib.starlette.span_modifier` and `ddtrace.contrib.fastapi.span_modifier`: the fastapi and starlette integrations now provide the full route and not just mounted route for sub-applications by default. - `ddtrace.contrib.starlette.config['aggregate_resources']` and `ddtrace.contrib.fastapi.config['aggregate_resources']`: the starlette and fastapi integrations no longer have the option to aggregate resources as this occurs by default now. - `DD_TRACE_OBFUSCATION_QUERY_STRING_PATTERN`: replaced by `DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP`. Additionally, the `pep562` dependency and references to it have been removed as it is no longer needed after dropping support for Python < 3.7. Note that `DD_CALL_BASIC_CONFIG` and `DD_LOG_FORMAT` are removed in - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
1 parent fa6a120 commit 70e6eba

File tree

65 files changed

+967
-1865
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+967
-1865
lines changed

ddtrace/_logger.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
from ddtrace.internal.utils.formats import asbool
66

77

8+
DD_LOG_FORMAT = "%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] {}- %(message)s".format(
9+
"[dd.service=%(dd.service)s dd.env=%(dd.env)s dd.version=%(dd.version)s"
10+
" dd.trace_id=%(dd.trace_id)s dd.span_id=%(dd.span_id)s] "
11+
)
12+
813
DEFAULT_FILE_SIZE_BYTES = 15 << 20 # 15 MB
914

1015

@@ -32,14 +37,13 @@ def configure_ddtrace_logger():
3237
3338
"""
3439
ddtrace_logger = logging.getLogger("ddtrace")
35-
40+
ddtrace_logger.addHandler(logging.StreamHandler())
3641
_configure_ddtrace_debug_logger(ddtrace_logger)
3742
_configure_ddtrace_file_logger(ddtrace_logger)
3843

3944

4045
def _configure_ddtrace_debug_logger(logger):
41-
debug_enabled = asbool(os.environ.get("DD_TRACE_DEBUG", "false"))
42-
if debug_enabled:
46+
if asbool(os.environ.get("DD_TRACE_DEBUG", "false")):
4347
logger.setLevel(logging.DEBUG)
4448
logger.debug("debug mode has been enabled for the ddtrace logger")
4549

@@ -62,11 +66,21 @@ def _configure_ddtrace_file_logger(logger):
6266
ddtrace_file_handler = RotatingFileHandler(
6367
filename=log_path, mode="a", maxBytes=max_file_bytes, backupCount=num_backup
6468
)
65-
6669
log_format = "%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] - %(message)s"
6770
log_formatter = logging.Formatter(log_format)
68-
6971
ddtrace_file_handler.setLevel(file_log_level_value)
7072
ddtrace_file_handler.setFormatter(log_formatter)
7173
logger.addHandler(ddtrace_file_handler)
7274
logger.debug("ddtrace logs will be routed to %s", log_path)
75+
76+
77+
def _configure_log_injection():
78+
"""
79+
Ensures that logging is patched before we inject trace information into logs.
80+
"""
81+
from ddtrace import patch
82+
83+
patch(logging=True)
84+
ddtrace_logger = logging.getLogger("ddtrace")
85+
for handler in ddtrace_logger.handlers:
86+
handler.setFormatter(logging.Formatter(DD_LOG_FORMAT))

ddtrace/bootstrap/sitecustomize.py

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import warnings # noqa
1111

1212
from ddtrace import config # noqa
13+
from ddtrace._logger import _configure_log_injection
1314
from ddtrace.debugging._config import di_config # noqa
1415
from ddtrace.debugging._config import ed_config # noqa
1516
from ddtrace.internal.compat import PY2 # noqa
@@ -19,43 +20,16 @@
1920
from ddtrace.internal.runtime.runtime_metrics import RuntimeWorker # noqa
2021
from ddtrace.internal.utils.formats import asbool # noqa
2122
from ddtrace.internal.utils.formats import parse_tags_str # noqa
22-
from ddtrace.tracer import DD_LOG_FORMAT # noqa
23-
from ddtrace.vendor.debtcollector import deprecate # noqa
2423

2524

25+
# Debug mode from the tracer will do the same here, so only need to do this otherwise.
2626
if config.logs_injection:
27-
# immediately patch logging if trace id injected
28-
from ddtrace import patch
29-
30-
patch(logging=True)
31-
32-
33-
# DEV: Once basicConfig is called here, future calls to it cannot be used to
34-
# change the formatter since it applies the formatter to the root handler only
35-
# upon initializing it the first time.
36-
# See https://github.com/python/cpython/blob/112e4afd582515fcdcc0cde5012a4866e5cfda12/Lib/logging/__init__.py#L1550
37-
# Debug mode from the tracer will do a basicConfig so only need to do this otherwise
38-
if not config._debug_mode and config._call_basic_config:
39-
deprecate(
40-
"ddtrace.tracer.logging.basicConfig",
41-
message="`logging.basicConfig()` should be called in a user's application.",
42-
removal_version="2.0.0",
43-
)
44-
if config.logs_injection:
45-
logging.basicConfig(format=DD_LOG_FORMAT)
46-
else:
47-
logging.basicConfig()
27+
_configure_log_injection()
28+
4829

4930
log = get_logger(__name__)
5031

5132

52-
if os.environ.get("DD_GEVENT_PATCH_ALL") is not None:
53-
deprecate(
54-
"The environment variable DD_GEVENT_PATCH_ALL is deprecated and will be removed in a future version. ",
55-
postfix="There is no special configuration necessary to make ddtrace work with gevent if using ddtrace-run. "
56-
"If not using ddtrace-run, import ddtrace.auto before calling gevent.monkey.patch_all().",
57-
removal_version="2.0.0",
58-
)
5933
if "gevent" in sys.modules or "gevent.monkey" in sys.modules:
6034
import gevent.monkey # noqa
6135

ddtrace/constants.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,3 @@
1-
from ddtrace.internal.compat import ensure_pep562
2-
from ddtrace.vendor.debtcollector import deprecate
3-
4-
5-
deprecated_names = {
6-
"APPSEC_ENABLED": "_dd.appsec.enabled",
7-
"APPSEC_JSON": "_dd.appsec.json",
8-
"APPSEC_EVENT_RULE_VERSION": "_dd.appsec.event_rules.version",
9-
"APPSEC_EVENT_RULE_ERRORS": "_dd.appsec.event_rules.errors",
10-
"APPSEC_EVENT_RULE_LOADED": "_dd.appsec.event_rules.loaded",
11-
"APPSEC_EVENT_RULE_ERROR_COUNT": "_dd.appsec.event_rules.error_count",
12-
"APPSEC_WAF_DURATION": "_dd.appsec.waf.duration",
13-
"APPSEC_WAF_DURATION_EXT": "_dd.appsec.waf.duration_ext",
14-
"APPSEC_WAF_TIMEOUTS": "_dd.appsec.waf.timeouts",
15-
"APPSEC_WAF_VERSION": "_dd.appsec.waf.version",
16-
"APPSEC_ORIGIN_VALUE": "appsec",
17-
"APPSEC_BLOCKED": "appsec.blocked",
18-
"IAST_JSON": "_dd.iast.json",
19-
"IAST_ENABLED": "_dd.iast.enabled",
20-
"IAST_CONTEXT_KEY": "_iast_data",
21-
}
22-
23-
24-
def __getattr__(name):
25-
if name in deprecated_names:
26-
deprecate(
27-
("%s.%s is deprecated" % (__name__, name)),
28-
removal_version="2.0.0",
29-
)
30-
return deprecated_names[name]
31-
raise AttributeError("'%s' has no attribute '%s'", __name__, name)
32-
33-
341
SAMPLE_RATE_METRIC_KEY = "_sample_rate"
352
SAMPLING_PRIORITY_KEY = "_sampling_priority_v1"
363
ANALYTICS_SAMPLE_RATE_KEY = "_dd1.sr.eausr"
@@ -77,5 +44,3 @@ def __getattr__(name):
7744
AUTO_KEEP = 1
7845
# Use this to explicitly inform the backend that a trace should be kept and stored.
7946
USER_KEEP = 2
80-
81-
ensure_pep562(__name__)

ddtrace/contrib/aiobotocore/__init__.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,6 @@
2424
2525
Default: ``False``
2626
27-
.. py:data:: ddtrace.config.aiobotocore['tag_all_params']
28-
29-
**Deprecated**: This retains the deprecated behavior of adding span tags for
30-
all API parameters that are not explicitly excluded by the integration.
31-
These deprecated span tags will be added along with the API parameters
32-
enabled by default.
33-
34-
This configuration is ignored if ``tag_no_parms`` (``DD_AWS_TAG_NO_PARAMS``)
35-
is set to ``True``.
36-
37-
To collect all API parameters, ``ddtrace.config.botocore.tag_all_params =
38-
True`` or by setting the environment variable ``DD_AWS_TAG_ALL_PARAMS=true``.
39-
40-
41-
Default: ``False``
4227
"""
4328
from ...internal.utils.importlib import require_modules
4429

ddtrace/contrib/aiobotocore/patch.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from ddtrace import config
66
from ddtrace.internal.constants import COMPONENT
77
from ddtrace.internal.utils.version import parse_version
8-
from ddtrace.vendor import debtcollector
98
from ddtrace.vendor import wrapt
109

1110
from ...constants import ANALYTICS_SAMPLE_RATE_KEY
@@ -40,18 +39,10 @@
4039
TRACED_ARGS = {"params", "path", "verb"}
4140

4241

43-
if os.getenv("DD_AWS_TAG_ALL_PARAMS") is not None:
44-
debtcollector.deprecate(
45-
"Using environment variable 'DD_AWS_TAG_ALL_PARAMS' is deprecated",
46-
message="The aiobotocore integration no longer includes all API parameters by default.",
47-
removal_version="2.0.0",
48-
)
49-
5042
config._add(
5143
"aiobotocore",
5244
{
5345
"tag_no_params": asbool(os.getenv("DD_AWS_TAG_NO_PARAMS", default=False)),
54-
"tag_all_params": asbool(os.getenv("DD_AWS_TAG_ALL_PARAMS", default=False)),
5546
},
5647
)
5748

@@ -152,9 +143,6 @@ async def _wrapped_api_call(original_func, instance, args, kwargs):
152143
operation = None
153144
span.resource = endpoint_name
154145

155-
if not config.aiobotocore["tag_no_params"] and config.aiobotocore["tag_all_params"]:
156-
aws.add_span_arg_tags(span, endpoint_name, args, ARGS_NAME, TRACED_ARGS)
157-
158146
region_name = deep_getattr(instance, "meta.region_name")
159147

160148
meta = {

ddtrace/contrib/boto/__init__.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,6 @@
2424
True`` or by setting the environment variable ``DD_AWS_TAG_NO_PARAMS=true``.
2525
2626
27-
Default: ``False``
28-
29-
.. py:data:: ddtrace.config.boto['tag_all_params']
30-
31-
**Deprecated**: This retains the deprecated behavior of adding span tags for
32-
all API parameters that are not explicitly excluded by the integration.
33-
These deprecated span tags will be added along with the API parameters
34-
enabled by default.
35-
36-
This configuration is ignored if ``tag_no_parms`` (``DD_AWS_TAG_NO_PARAMS``)
37-
is set to ``True``.
38-
39-
To collect all API parameters, ``ddtrace.config.botocore.tag_all_params =
40-
True`` or by setting the environment variable ``DD_AWS_TAG_ALL_PARAMS=true``.
41-
42-
4327
Default: ``False``
4428
4529
"""

ddtrace/contrib/boto/patch.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from ddtrace.internal.constants import COMPONENT
1616
from ddtrace.internal.utils.wrappers import unwrap
1717
from ddtrace.pin import Pin
18-
from ddtrace.vendor import debtcollector
1918
from ddtrace.vendor import wrapt
2019

2120
from ...internal.schema import schematize_cloud_api_operation
@@ -41,18 +40,10 @@
4140
AWS_AUTH_TRACED_ARGS = {"path", "data", "host"}
4241

4342

44-
if os.getenv("DD_AWS_TAG_ALL_PARAMS") is not None:
45-
debtcollector.deprecate(
46-
"Using environment variable 'DD_AWS_TAG_ALL_PARAMS' is deprecated",
47-
message="The boto integration no longer includes all API parameters by default.",
48-
removal_version="2.0.0",
49-
)
50-
5143
config._add(
5244
"boto",
5345
{
5446
"tag_no_params": asbool(os.getenv("DD_AWS_TAG_NO_PARAMS", default=False)),
55-
"tag_all_params": asbool(os.getenv("DD_AWS_TAG_ALL_PARAMS", default=False)),
5647
},
5748
)
5849

@@ -117,9 +108,6 @@ def patched_query_request(original_func, instance, args, kwargs):
117108
else:
118109
span.resource = endpoint_name
119110

120-
if not config.boto["tag_no_params"] and config.boto["tag_all_params"]:
121-
aws.add_span_arg_tags(span, endpoint_name, args, AWS_QUERY_ARGS_NAME, AWS_QUERY_TRACED_ARGS)
122-
123111
# Obtaining region name
124112
region_name = _get_instance_region_name(instance)
125113

@@ -184,9 +172,6 @@ def patched_auth_request(original_func, instance, args, kwargs):
184172
else:
185173
span.resource = endpoint_name
186174

187-
if not config.boto["tag_no_params"] and config.boto["tag_all_params"]:
188-
aws.add_span_arg_tags(span, endpoint_name, args, AWS_AUTH_ARGS_NAME, AWS_AUTH_TRACED_ARGS)
189-
190175
# Obtaining region name
191176
region_name = _get_instance_region_name(instance)
192177

ddtrace/contrib/botocore/__init__.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,6 @@
6767
6868
Default: ``False``
6969
70-
.. py:data:: ddtrace.config.botocore['tag_all_params']
71-
72-
**Deprecated**: This retains the deprecated behavior of adding span tags for
73-
all API parameters that are not explicitly excluded by the integration.
74-
These deprecated span tags will be added along with the API parameters
75-
enabled by default.
76-
77-
This configuration is ignored if ``tag_no_parms`` (``DD_AWS_TAG_NO_PARAMS``)
78-
is set to ``True``.
79-
80-
To collect all API parameters, ``ddtrace.config.botocore.tag_all_params =
81-
True`` or by setting the environment variable ``DD_AWS_TAG_ALL_PARAMS=true``.
82-
83-
84-
Default: ``False``
8570
8671
.. py:data:: ddtrace.config.botocore['instrument_internals']
8772

ddtrace/contrib/botocore/patch.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from ddtrace import config
2323
from ddtrace.internal.schema.span_attribute_schema import SpanDirection
2424
from ddtrace.settings.config import Config
25-
from ddtrace.vendor import debtcollector
2625
from ddtrace.vendor import wrapt
2726

2827
from ...constants import ANALYTICS_SAMPLE_RATE_KEY
@@ -66,12 +65,6 @@
6665

6766
log = get_logger(__name__)
6867

69-
if os.getenv("DD_AWS_TAG_ALL_PARAMS") is not None:
70-
debtcollector.deprecate(
71-
"Using environment variable 'DD_AWS_TAG_ALL_PARAMS' is deprecated",
72-
message="The botocore integration no longer includes all API parameters by default.",
73-
removal_version="2.0.0",
74-
)
7568

7669
# Botocore default settings
7770
config._add(
@@ -81,7 +74,6 @@
8174
"invoke_with_legacy_context": asbool(os.getenv("DD_BOTOCORE_INVOKE_WITH_LEGACY_CONTEXT", default=False)),
8275
"operations": collections.defaultdict(Config._HTTPServerConfig),
8376
"tag_no_params": asbool(os.getenv("DD_AWS_TAG_NO_PARAMS", default=False)),
84-
"tag_all_params": asbool(os.getenv("DD_AWS_TAG_ALL_PARAMS", default=False)),
8577
"instrument_internals": asbool(os.getenv("DD_BOTOCORE_INSTRUMENT_INTERNALS", default=False)),
8678
},
8779
)
@@ -595,9 +587,6 @@ def patched_api_call(original_func, instance, args, kwargs):
595587
else:
596588
span.resource = endpoint_name
597589

598-
if not config.botocore["tag_no_params"] and config.botocore["tag_all_params"]:
599-
aws.add_span_arg_tags(span, endpoint_name, args, ARGS_NAME, TRACED_ARGS)
600-
601590
region_name = deep_getattr(instance, "meta.region_name")
602591

603592
span.set_tag_str("aws.agent", "botocore")

ddtrace/contrib/fastapi/patch.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
from ddtrace import Pin
55
from ddtrace import config
66
from ddtrace.contrib.asgi.middleware import TraceMiddleware
7-
from ddtrace.contrib.starlette.patch import get_resource
87
from ddtrace.contrib.starlette.patch import traced_handler
98
from ddtrace.internal.logger import get_logger
109
from ddtrace.internal.schema import schematize_service_name
11-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
1210
from ddtrace.internal.utils.wrappers import unwrap as _u
13-
from ddtrace.vendor.debtcollector import removals
1411
from ddtrace.vendor.wrapt import ObjectProxy
1512
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w
1613

@@ -23,7 +20,6 @@
2320
_default_service=schematize_service_name("fastapi"),
2421
request_span_name="fastapi.request",
2522
distributed_tracing=True,
26-
aggregate_resources=True,
2723
),
2824
)
2925

@@ -33,13 +29,6 @@ def get_version():
3329
return getattr(fastapi, "__version__", "")
3430

3531

36-
@removals.remove(removal_version="2.0.0", category=DDTraceDeprecationWarning)
37-
def span_modifier(span, scope):
38-
resource = get_resource(scope)
39-
if config.fastapi["aggregate_resources"] and resource:
40-
span.resource = "{} {}".format(scope["method"], resource)
41-
42-
4332
def wrap_middleware_stack(wrapped, instance, args, kwargs):
4433
return TraceMiddleware(app=wrapped(*args, **kwargs), integration_config=config.fastapi)
4534

0 commit comments

Comments
 (0)