Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci_visibility): set up Test Optimization logging before pytest log capture [backport 3.3] #13065

Open
wants to merge 3 commits into
base: 3.3
Choose a base branch
from

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Apr 4, 2025

Backport 2db08ec from #13030 to 3.3.

We have a recurring problem where emitting logs at the end of a pytest test session results in errors like:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/logging/__init__.py", line 1103, in emit
    stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.

This happens because our plugin calls take_over_logger_stream_handler(), which calls logging.StreamHandler(), which defaults to using sys.stderr as its output stream, but by the time we call it, pytest's pytest_load_initial_conftests hook from capture.py has already executed and replaced sys.stderr with a FileIO buffer that is closed by the end of the test session, so we grab a reference to this internal FileIO buffer instead of the actual sys.stderr. This PR makes our own pytest_load_initial_conftests hook run earlier than pytest's capture.py one.

Additionally, this fixes take_over_logger_stream_handler() to copy the handler list before calling removeHandler(), as this mutates the list we are iterating through.

One user-visible side effect of this is that now we always print these logs at the beginning of the test session, regardless of whether pytest -s is used:

[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:294 Service: vitor-test (env: some-env)
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:295 Requests mode: agentless
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:296 Git metadata upload enabled: True
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:297 API-provided settings: coverage collection: False
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:298 API-provided settings: Intelligent Test Runner: False, test skipping: False
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:303 API-provided settings: Early Flake Detection enabled: True
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:307 API-provided settings: Auto Test Retries enabled: True
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:308 Detected configurations: {'os.architecture': 'x86_64', 'os.platform': 'Linux', 'os.version': '6.5.0-1027-oem', 'runtime.name': 'CPython', 'runtime.version': '3.10.14'}
[Datadog CI Visibility] WARNING  ddtrace.internal.ci_visibility.recorder:recorder.py:313 CODEOWNERS file is not available
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:628 Unique tests fetched for Early Flake Detection: 34
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:576 Final settings: coverage collection: False, test skipping: False, Early Flake Detection: True, Auto Test Retries: True, Flaky Test Management: True

Whether this is a bug or a feature is up to discussion. Previously we only printed this if pytest was called with -s, more by accident than by design.

The way I managed to reproduce it was by raising an exception right after tracer shutdown in CIVisibility._stop_service():

    def _stop_service(self) -> None:
        ...
        try:
            self.tracer.shutdown()
            raise Exception("ꙮ")  # <--- added here
        except Exception:
            log.warning("Failed to shutdown tracer", exc_info=True)

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

…g capture (#13030)

We have a recurring problem where emitting logs at the end of a pytest
test session results in errors like:
```
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/logging/__init__.py", line 1103, in emit
    stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
```
This happens because our plugin calls
`take_over_logger_stream_handler()`, which calls
`logging.StreamHandler()`, which defaults to using `sys.stderr` as its
output stream, but by the time we call it, pytest's
[`pytest_load_initial_conftests` hook from
`capture.py`](https://github.com/pytest-dev/pytest/blob/8.3.x/src/_pytest/capture.py#L155)
has already executed and replaced `sys.stderr` with a `FileIO` buffer
that is closed by the end of the test session, so we grab a reference to
this internal `FileIO` buffer instead of the actual `sys.stderr`. This
PR makes our own `pytest_load_initial_conftests` hook run earlier than
pytest's `capture.py` one.

Additionally, this fixes `take_over_logger_stream_handler()` to copy the
handler list before calling `removeHandler()`, as this mutates the list
we are iterating through.

One user-visible side effect of this is that now we always print these
logs at the beginning of the test session, regardless of whether `pytest
-s` is used:

```
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:294 Service: vitor-test (env: some-env)
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:295 Requests mode: agentless
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:296 Git metadata upload enabled: True
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:297 API-provided settings: coverage collection: False
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:298 API-provided settings: Intelligent Test Runner: False, test skipping: False
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:303 API-provided settings: Early Flake Detection enabled: True
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:307 API-provided settings: Auto Test Retries enabled: True
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:308 Detected configurations: {'os.architecture': 'x86_64', 'os.platform': 'Linux', 'os.version': '6.5.0-1027-oem', 'runtime.name': 'CPython', 'runtime.version': '3.10.14'}
[Datadog CI Visibility] WARNING  ddtrace.internal.ci_visibility.recorder:recorder.py:313 CODEOWNERS file is not available
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:628 Unique tests fetched for Early Flake Detection: 34
[Datadog CI Visibility] INFO     ddtrace.internal.ci_visibility.recorder:recorder.py:576 Final settings: coverage collection: False, test skipping: False, Early Flake Detection: True, Auto Test Retries: True, Flaky Test Management: True
```

Whether this is a bug or a feature is up to discussion. Previously we
only printed this if `pytest` was called with `-s`, more by accident
than by design.

The way I managed to reproduce it was by raising an exception right
after tracer shutdown in `CIVisibility._stop_service()`:

```
    def _stop_service(self) -> None:
        ...
        try:
            self.tracer.shutdown()
            raise Exception("ꙮ")  # <--- added here
        except Exception:
            log.warning("Failed to shutdown tracer", exc_info=True)
```

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- 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)

(cherry picked from commit 2db08ec)
@github-actions github-actions bot requested review from a team as code owners April 4, 2025 10:10
Copy link
Contributor Author

github-actions bot commented Apr 9, 2025

CODEOWNERS have been resolved as:

releasenotes/notes/ci_visibility-fix-io-operation-closed-file-1e1089eabd5296ce.yaml  @DataDog/apm-python
ddtrace/contrib/internal/pytest/_plugin_v2.py                           @DataDog/ci-app-libraries
ddtrace/internal/ci_visibility/utils.py                                 @DataDog/ci-app-libraries

Copy link
Contributor Author

github-actions bot commented Apr 9, 2025

Bootstrap import analysis

Comparison of import times between this PR and main.

Summary

The average import time in this PR is: 245 ± 5 ms.

The average import time in main is: 236 ± 5 ms.

The import time difference between this PR and main is: 9.9 ± 0.2 ms.

Import time breakdown

The following import paths have appeared:

ddtrace.auto 133.399 ms (54.34%)
ddtrace 112.043 ms (45.64%)
ddtrace._logger 67.032 ms (27.31%)
ddtrace.settings._core 66.086 ms (26.92%)
ddtrace.settings 66.053 ms (26.91%)
ddtrace.settings._config 65.192 ms (26.56%)
ddtrace.settings.endpoint_config 25.120 ms (10.23%)
ddtrace.internal.utils.http 24.193 ms (9.86%)
http.client 17.774 ms (7.24%)
email.parser 9.818 ms (4.00%)
email.feedparser 9.513 ms (3.88%)
email._policybase 8.187 ms (3.34%)
email.utils 6.207 ms (2.53%)
email._parseaddr 3.088 ms (1.26%)
calendar 2.715 ms (1.11%)
locale 1.645 ms (0.67%)
_locale 0.175 ms (0.07%)
socket 2.550 ms (1.04%)
_socket 0.473 ms (0.19%)
array 0.420 ms (0.17%)
email.header 1.579 ms (0.64%)
email.quoprimime 0.342 ms (0.14%)
email.charset 0.298 ms (0.12%)
email.base64mime 0.226 ms (0.09%)
email.errors 0.690 ms (0.28%)
ssl 4.727 ms (1.93%)
_ssl 1.789 ms (0.73%)
email.message 1.228 ms (0.50%)
email._encoded_words 0.385 ms (0.16%)
email.iterators 0.240 ms (0.10%)
http 0.881 ms (0.36%)
ddtrace.internal.http 3.210 ms (1.31%)
ddtrace.internal.runtime 1.625 ms (0.66%)
uuid 0.893 ms (0.36%)
_uuid 0.366 ms (0.15%)
ddtrace.internal.forksafe 0.372 ms (0.15%)
ddtrace.internal.runtime.container 1.232 ms (0.50%)
email.encoders 1.506 ms (0.61%)
base64 0.687 ms (0.28%)
binascii 0.316 ms (0.13%)
quopri 0.266 ms (0.11%)
email 0.251 ms (0.10%)
ddtrace.internal.uds 0.276 ms (0.11%)
ddtrace.internal.utils.retry 0.620 ms (0.25%)
__future__ 0.266 ms (0.11%)
ddtrace.settings._telemetry 16.448 ms (6.70%)
ddtrace.internal.telemetry 16.107 ms (6.56%)
ddtrace.internal.telemetry.writer 15.612 ms (6.36%)
ddtrace.internal.utils.version 4.264 ms (1.74%)
ddtrace.vendor.packaging.version 3.501 ms (1.43%)
ddtrace.vendor.packaging 0.571 ms (0.23%)
ddtrace.vendor 0.266 ms (0.11%)
ddtrace.vendor.packaging._structures 0.290 ms (0.12%)
ddtrace.version 0.248 ms (0.10%)
ddtrace._version 0.233 ms (0.10%)
ddtrace.internal.telemetry.data 3.900 ms (1.59%)
ddtrace.internal.packages 2.789 ms (1.14%)
_sysconfigdata__linux_x86_64-linux-gnu 0.608 ms (0.25%)
ddtrace.settings.third_party 0.384 ms (0.16%)
sysconfig 0.516 ms (0.21%)
ddtrace.internal.hostname 0.247 ms (0.10%)
ddtrace.internal.periodic 1.994 ms (0.81%)
ddtrace.internal._threads 1.166 ms (0.48%)
ddtrace.internal.service 0.445 ms (0.18%)
ddtrace.internal.atexit 1.205 ms (0.49%)
signal 0.682 ms (0.28%)
ddtrace.internal.utils.signals 0.248 ms (0.10%)
ddtrace.internal.encoding 0.947 ms (0.39%)
ddtrace.internal._encoding 0.590 ms (0.24%)
ddtrace.internal.telemetry.constants 0.555 ms (0.23%)
ddtrace.internal.agent 0.457 ms (0.19%)
ddtrace.internal.telemetry.metrics 0.435 ms (0.18%)
ddtrace.internal.telemetry.metrics_namespaces 0.342 ms (0.14%)
ddtrace.internal.telemetry.logging 0.329 ms (0.13%)
ddtrace.internal.telemetry.modules 0.261 ms (0.11%)
ddtrace.internal.gitmetadata 14.690 ms (5.98%)
ddtrace.ext.ci 10.980 ms (4.47%)
ddtrace.ext.git 9.216 ms (3.75%)
shutil 3.086 ms (1.26%)
bz2 1.032 ms (0.42%)
_bz2 0.371 ms (0.15%)
_compression 0.321 ms (0.13%)
lzma 0.759 ms (0.31%)
_lzma 0.419 ms (0.17%)
zlib 0.420 ms (0.17%)
subprocess 2.399 ms (0.98%)
selectors 0.622 ms (0.25%)
fcntl 0.295 ms (0.12%)
select 0.286 ms (0.12%)
_posixsubprocess 0.269 ms (0.11%)
msvcrt 0.110 ms (0.04%)
random 1.545 ms (0.63%)
bisect 0.521 ms (0.21%)
_bisect 0.283 ms (0.12%)
_sha2 0.280 ms (0.11%)
_random 0.270 ms (0.11%)
ddtrace.internal.utils.time 0.926 ms (0.38%)
datetime 0.590 ms (0.24%)
_datetime 0.364 ms (0.15%)
tempfile 0.579 ms (0.24%)
platform 0.839 ms (0.34%)
_wmi 0.115 ms (0.05%)
ddtrace.ext 0.295 ms (0.12%)
ddtrace.settings._core 3.356 ms (1.37%)
envier 1.652 ms (0.67%)
envier.env 1.378 ms (0.56%)
ddtrace.internal.native 0.869 ms (0.35%)
ddtrace.internal.native._native 0.558 ms (0.23%)
ddtrace.settings._otel_remapper 0.377 ms (0.15%)
ddtrace._trace.pin 3.970 ms (1.62%)
wrapt 3.255 ms (1.33%)
wrapt.__wrapt__ 1.284 ms (0.52%)
wrapt.wrappers 0.561 ms (0.23%)
wrapt._wrappers 0.422 ms (0.17%)
wrapt.decorators 0.689 ms (0.28%)
wrapt.arguments 0.252 ms (0.10%)
wrapt.importer 0.329 ms (0.13%)
wrapt.weakrefs 0.326 ms (0.13%)
wrapt.patches 0.308 ms (0.13%)
ddtrace._trace 0.242 ms (0.10%)
ddtrace.internal.schema 2.298 ms (0.94%)
ddtrace.internal.schema.span_attribute_schema 1.985 ms (0.81%)
ddtrace.settings._inferred_base_service 0.415 ms (0.17%)
ddtrace.settings.integration 0.562 ms (0.23%)
ddtrace.internal.utils.attrdict 0.267 ms (0.11%)
ddtrace.internal.utils.cache 0.342 ms (0.14%)
ddtrace.settings.http 0.307 ms (0.13%)
ddtrace.internal.serverless 0.276 ms (0.11%)
ddtrace._hooks 0.317 ms (0.13%)
ddtrace.settings.exceptions 0.263 ms (0.11%)
ddtrace.internal.utils.formats 0.946 ms (0.39%)
ddtrace.internal.constants 0.566 ms (0.23%)
ddtrace.constants 0.254 ms (0.10%)
ddtrace.internal.compat 0.380 ms (0.15%)
ddtrace.internal.module 42.197 ms (17.19%)
ddtrace.internal.wrapping.context 18.680 ms (7.61%)
ddtrace.internal.wrapping 17.648 ms (7.19%)
bytecode 14.687 ms (5.98%)
bytecode.bytecode 11.573 ms (4.71%)
bytecode.flags 11.031 ms (4.49%)
bytecode.instr 9.947 ms (4.05%)
dataclasses 5.461 ms (2.22%)
inspect 4.632 ms (1.89%)
ast 2.305 ms (0.94%)
_ast 1.205 ms (0.49%)
copy 0.196 ms (0.08%)
dis 0.856 ms (0.35%)
bytecode.utils 0.152 ms (0.06%)
opcode 0.578 ms (0.24%)
_opcode 0.159 ms (0.06%)
bytecode.cfg 2.630 ms (1.07%)
bytecode.concrete 1.311 ms (0.53%)
struct 0.349 ms (0.14%)
_struct 0.211 ms (0.09%)
bytecode.version 0.235 ms (0.10%)
ddtrace.internal.wrapping.asyncs 1.483 ms (0.60%)
ddtrace.internal.wrapping.generators 0.732 ms (0.30%)
ddtrace.internal.assembly 0.377 ms (0.15%)
contextvars 0.279 ms (0.11%)
_contextvars 0.148 ms (0.06%)
pathlib 8.890 ms (3.62%)
fnmatch 4.242 ms (1.73%)
re 3.997 ms (1.63%)
enum 2.007 ms (0.82%)
functools 0.693 ms (0.28%)
_functools 0.063 ms (0.03%)
re._compiler 1.321 ms (0.54%)
re._parser 0.787 ms (0.32%)
re._constants 0.355 ms (0.14%)
re._casefix 0.128 ms (0.05%)
_sre 0.071 ms (0.03%)
copyreg 0.180 ms (0.07%)
urllib.parse 3.331 ms (1.36%)
ipaddress 1.862 ms (0.76%)
math 0.289 ms (0.12%)
urllib 0.130 ms (0.05%)
ntpath 0.481 ms (0.20%)
nt 0.334 ms (0.14%)
_winapi 0.068 ms (0.03%)
errno 0.056 ms (0.02%)
ddtrace.internal.logger 6.333 ms (2.58%)
logging 6.031 ms (2.46%)
traceback 2.777 ms (1.13%)
linecache 1.296 ms (0.53%)
tokenize 1.143 ms (0.47%)
token 0.177 ms (0.07%)
_tokenize 0.038 ms (0.02%)
textwrap 0.929 ms (0.38%)
string 0.674 ms (0.27%)
_string 0.037 ms (0.01%)
threading 0.599 ms (0.24%)
atexit 0.041 ms (0.02%)
typing 3.431 ms (1.40%)
contextlib 0.647 ms (0.26%)
collections.abc 0.173 ms (0.07%)
_typing 0.041 ms (0.02%)
collections 1.764 ms (0.72%)
operator 0.349 ms (0.14%)
_operator 0.070 ms (0.03%)
reprlib 0.188 ms (0.08%)
keyword 0.139 ms (0.06%)
itertools 0.115 ms (0.05%)
_collections 0.066 ms (0.03%)
weakref 0.730 ms (0.30%)
_weakrefset 0.216 ms (0.09%)
importlib.util 0.565 ms (0.23%)
types 0.264 ms (0.11%)
importlib._abc 0.196 ms (0.08%)
ddtrace.internal.utils 0.339 ms (0.14%)
importlib._bootstrap 0.195 ms (0.08%)
importlib 0.171 ms (0.07%)
ddtrace.internal 0.186 ms (0.08%)
importlib.machinery 0.052 ms (0.02%)
ddtrace.internal._file_queue 2.509 ms (1.02%)
secrets 2.207 ms (0.90%)
hmac 1.862 ms (0.76%)
_hashlib 0.891 ms (0.36%)
hashlib 0.650 ms (0.26%)
_blake2 0.309 ms (0.13%)
warnings 0.305 ms (0.12%)
ddtrace.bootstrap.sitecustomize 21.355 ms (8.70%)
ddtrace.bootstrap.preload 11.395 ms (4.64%)
ddtrace.internal.products 9.859 ms (4.02%)
ddtrace.internal.symbol_db.remoteconfig 8.591 ms (3.50%)
multiprocessing 3.721 ms (1.52%)
multiprocessing.context 3.397 ms (1.38%)
multiprocessing.reduction 2.226 ms (0.91%)
pickle 1.804 ms (0.74%)
_compat_pickle 0.442 ms (0.18%)
_pickle 0.396 ms (0.16%)
multiprocessing.process 0.453 ms (0.18%)
ddtrace.internal.remoteconfig._connectors 3.041 ms (1.24%)
ctypes 2.715 ms (1.11%)
_ctypes 0.564 ms (0.23%)
ctypes._endian 0.436 ms (0.18%)
multiprocessing.sharedctypes 1.828 ms (0.74%)
multiprocessing.heap 1.158 ms (0.47%)
multiprocessing.util 0.398 ms (0.16%)
mmap 0.398 ms (0.16%)
ddtrace.internal.remoteconfig.client 1.268 ms (0.52%)
ddtrace.internal.remoteconfig._pubsub 1.268 ms (0.52%)
ddtrace.internal.remoteconfig._subscribers 0.541 ms (0.22%)
ddtrace.internal.remoteconfig.utils 0.232 ms (0.09%)
ddtrace.internal.remoteconfig._publishers 0.449 ms (0.18%)
ddtrace.settings.profiling 1.137 ms (0.46%)
ddtrace.internal.datadog.profiling.ddup 0.569 ms (0.23%)
ddtrace.internal.datadog.profiling.ddup._ddup 0.569 ms (0.23%)
ddtrace.internal.datadog.profiling._types 0.294 ms (0.12%)
ddtrace.internal.datadog.profiling.util 0.275 ms (0.11%)
ddtrace.internal.datadog.profiling 0.568 ms (0.23%)
ddtrace.internal.datadog 0.261 ms (0.11%)
ddtrace.internal.tracemethods 0.399 ms (0.16%)
ddtrace._trace.trace_handlers 9.961 ms (4.06%)
ddtrace._trace.utils_botocore.span_tags 7.313 ms (2.98%)
ddtrace._trace.utils_botocore.aws_payload_tagging 6.735 ms (2.74%)
ddtrace.vendor.jsonpath_ng 4.781 ms (1.95%)
ddtrace.vendor.jsonpath_ng.jsonpath 2.358 ms (0.96%)
ddtrace.vendor.jsonpath_ng.lexer 1.673 ms (0.68%)
ddtrace.vendor.ply.lex 0.953 ms (0.39%)
ddtrace.vendor.ply 0.251 ms (0.10%)
ddtrace.vendor.jsonpath_ng.exceptions 0.306 ms (0.12%)
ddtrace.vendor.jsonpath_ng.parser 2.147 ms (0.87%)
ddtrace.vendor.ply.yacc 1.768 ms (0.72%)
decimal 1.640 ms (0.67%)
_decimal 1.408 ms (0.57%)
numbers 0.586 ms (0.24%)
ddtrace.ext.aws 0.272 ms (0.11%)
ddtrace._trace.utils_botocore.span_pointers 2.647 ms (1.08%)
ddtrace._trace.utils_botocore.span_pointers.dynamodb 1.388 ms (0.57%)
ddtrace._trace.utils_botocore.span_pointers.telemetry 0.267 ms (0.11%)
ddtrace._trace.utils_botocore.span_pointers.s3 0.642 ms (0.26%)
ddtrace._trace.utils_botocore 0.251 ms (0.10%)

The following import paths have disappeared:

ddtrace.auto 127.821 ms (52.07%)
ddtrace 116.818 ms (47.59%)
ddtrace._logger 93.328 ms (38.02%)
ddtrace.internal.telemetry 83.219 ms (33.90%)
ddtrace.internal.telemetry.writer 81.471 ms (33.19%)
ddtrace.internal.utils.version 28.232 ms (11.50%)
ddtrace.vendor.packaging.version 27.597 ms (11.24%)
ddtrace.vendor.packaging 25.241 ms (10.28%)
ddtrace.vendor 11.642 ms (4.74%)
ddtrace.internal.module 11.480 ms (4.68%)
ddtrace.internal.wrapping.context 10.711 ms (4.36%)
ddtrace.internal.wrapping 9.758 ms (3.98%)
bytecode 6.845 ms (2.79%)
bytecode.bytecode 4.091 ms (1.67%)
bytecode.flags 3.476 ms (1.42%)
bytecode.instr 2.981 ms (1.21%)
bytecode.utils 0.124 ms (0.05%)
bytecode.cfg 2.265 ms (0.92%)
bytecode.concrete 0.939 ms (0.38%)
bytecode.version 0.234 ms (0.10%)
ddtrace.internal.wrapping.asyncs 1.459 ms (0.59%)
ddtrace.internal.wrapping.generators 0.710 ms (0.29%)
ddtrace.internal.assembly 0.375 ms (0.15%)
contextvars 0.279 ms (0.11%)
_contextvars 0.154 ms (0.06%)
ddtrace.vendor.packaging._structures 0.302 ms (0.12%)
ddtrace.version 0.243 ms (0.10%)
ddtrace._version 0.233 ms (0.09%)
http.client 21.523 ms (8.77%)
email.parser 13.858 ms (5.65%)
email.feedparser 13.456 ms (5.48%)
email._policybase 12.353 ms (5.03%)
email.utils 9.649 ms (3.93%)
socket 3.068 ms (1.25%)
selectors 0.714 ms (0.29%)
select 0.182 ms (0.07%)
_socket 0.530 ms (0.22%)
array 0.277 ms (0.11%)
errno 0.060 ms (0.02%)
urllib.parse 2.499 ms (1.02%)
ipaddress 1.286 ms (0.52%)
urllib 0.130 ms (0.05%)
email._parseaddr 2.031 ms (0.83%)
calendar 1.785 ms (0.73%)
locale 0.848 ms (0.35%)
_locale 0.076 ms (0.03%)
random 1.204 ms (0.49%)
bisect 0.294 ms (0.12%)
_bisect 0.151 ms (0.06%)
math 0.204 ms (0.08%)
_sha2 0.166 ms (0.07%)
_random 0.155 ms (0.06%)
datetime 0.377 ms (0.15%)
_datetime 0.239 ms (0.10%)
email.header 2.407 ms (0.98%)
email.base64mime 0.699 ms (0.28%)
base64 0.573 ms (0.23%)
struct 0.326 ms (0.13%)
_struct 0.197 ms (0.08%)
email.charset 0.496 ms (0.20%)
email.encoders 0.292 ms (0.12%)
quopri 0.165 ms (0.07%)
binascii 0.299 ms (0.12%)
email.quoprimime 0.239 ms (0.10%)
email.errors 0.576 ms (0.23%)
email 0.142 ms (0.06%)
ssl 4.364 ms (1.78%)
_ssl 1.663 ms (0.68%)
email.message 0.906 ms (0.37%)
email._encoded_words 0.271 ms (0.11%)
email.iterators 0.137 ms (0.06%)
http 0.775 ms (0.32%)
ddtrace.internal.utils.http 15.237 ms (6.21%)
dataclasses 7.143 ms (2.91%)
inspect 6.304 ms (2.57%)
ast 2.322 ms (0.95%)
_ast 1.202 ms (0.49%)
dis 1.483 ms (0.60%)
opcode 0.590 ms (0.24%)
_opcode 0.157 ms (0.06%)
importlib.machinery 0.238 ms (0.10%)
importlib 0.173 ms (0.07%)
copy 0.204 ms (0.08%)
ddtrace.internal.http 5.508 ms (2.24%)
ddtrace.internal.runtime 4.294 ms (1.75%)
ddtrace.internal.forksafe 2.695 ms (1.10%)
wrapt 2.437 ms (0.99%)
wrapt.__wrapt__ 0.894 ms (0.36%)
wrapt.wrappers 0.420 ms (0.17%)
wrapt._wrappers 0.279 ms (0.11%)
wrapt.importer 0.521 ms (0.21%)
importlib.util 0.310 ms (0.13%)
importlib._abc 0.187 ms (0.08%)
wrapt.decorators 0.503 ms (0.20%)
wrapt.arguments 0.122 ms (0.05%)
wrapt.patches 0.171 ms (0.07%)
wrapt.weakrefs 0.152 ms (0.06%)
uuid 1.367 ms (0.56%)
platform 0.597 ms (0.24%)
_wmi 0.076 ms (0.03%)
_uuid 0.264 ms (0.11%)
ddtrace.internal.runtime.container 1.009 ms (0.41%)
ddtrace.internal.utils 0.359 ms (0.15%)
ddtrace.internal.utils.cache 0.226 ms (0.09%)
ddtrace.internal.constants 0.185 ms (0.08%)
ddtrace.internal.uds 0.154 ms (0.06%)
ddtrace.constants 0.146 ms (0.06%)
ddtrace.settings._agent 3.912 ms (1.59%)
ddtrace.settings._core 2.376 ms (0.97%)
envier 1.336 ms (0.54%)
envier.env 1.181 ms (0.48%)
ddtrace.internal.native 0.645 ms (0.26%)
ddtrace.internal.native._native 0.446 ms (0.18%)
ddtrace.settings 0.990 ms (0.40%)
ddtrace.settings.integration 0.298 ms (0.12%)
ddtrace.internal.utils.attrdict 0.124 ms (0.05%)
ddtrace._hooks 0.188 ms (0.08%)
ddtrace.settings.exceptions 0.185 ms (0.08%)
ddtrace.settings.http 0.164 ms (0.07%)
ddtrace.internal.telemetry.data 3.804 ms (1.55%)
ddtrace.internal.packages 2.712 ms (1.10%)
_sysconfigdata__linux_x86_64-linux-gnu 0.593 ms (0.24%)
ddtrace.settings.third_party 0.326 ms (0.13%)
sysconfig 0.510 ms (0.21%)
ddtrace.internal.hostname 0.250 ms (0.10%)
ddtrace.settings._telemetry 2.407 ms (0.98%)
ddtrace.settings._inferred_base_service 1.743 ms (0.71%)
pathlib 1.285 ms (0.52%)
ntpath 0.480 ms (0.20%)
nt 0.321 ms (0.13%)
_winapi 0.069 ms (0.03%)
fnmatch 0.150 ms (0.06%)
ddtrace.internal.encoding 1.620 ms (0.66%)
ddtrace.internal._encoding 0.369 ms (0.15%)
ddtrace.internal.compat 0.300 ms (0.12%)
ddtrace.internal.periodic 1.611 ms (0.66%)
ddtrace.internal._threads 1.032 ms (0.42%)
ddtrace.internal.service 0.316 ms (0.13%)
ddtrace.internal.atexit 1.005 ms (0.41%)
signal 0.559 ms (0.23%)
__future__ 0.154 ms (0.06%)
ddtrace.internal.utils.signals 0.119 ms (0.05%)
ddtrace.internal.telemetry.metrics_namespaces 0.586 ms (0.24%)
ddtrace.internal.telemetry.logging 0.408 ms (0.17%)
ddtrace.internal.utils.time 0.263 ms (0.11%)
ddtrace.internal.telemetry.modules 0.257 ms (0.10%)
ddtrace.internal.telemetry.constants 0.518 ms (0.21%)
ddtrace.settings._otel_remapper 0.394 ms (0.16%)
ddtrace.internal.logger 0.256 ms (0.10%)
logging 7.457 ms (3.04%)
traceback 4.159 ms (1.69%)
contextlib 1.268 ms (0.52%)
linecache 1.188 ms (0.48%)
tokenize 1.038 ms (0.42%)
token 0.176 ms (0.07%)
_tokenize 0.037 ms (0.02%)
textwrap 0.902 ms (0.37%)
collections.abc 0.165 ms (0.07%)
string 0.662 ms (0.27%)
_string 0.036 ms (0.01%)
weakref 0.425 ms (0.17%)
warnings 0.301 ms (0.12%)
atexit 0.044 ms (0.02%)
typing 2.652 ms (1.08%)
_typing 0.040 ms (0.02%)
ddtrace.settings._config 15.440 ms (6.29%)
ddtrace.internal.gitmetadata 7.077 ms (2.88%)
ddtrace.ext.ci 6.757 ms (2.75%)
ddtrace.ext.git 5.877 ms (2.39%)
shutil 3.074 ms (1.25%)
bz2 1.073 ms (0.44%)
_bz2 0.402 ms (0.16%)
_compression 0.324 ms (0.13%)
lzma 0.852 ms (0.35%)
_lzma 0.438 ms (0.18%)
zlib 0.355 ms (0.14%)
subprocess 1.432 ms (0.58%)
fcntl 0.308 ms (0.13%)
_posixsubprocess 0.279 ms (0.11%)
msvcrt 0.111 ms (0.05%)
tempfile 0.597 ms (0.24%)
ddtrace.ext 0.297 ms (0.12%)
ddtrace.internal._file_queue 2.570 ms (1.05%)
secrets 2.253 ms (0.92%)
hmac 2.011 ms (0.82%)
_hashlib 0.938 ms (0.38%)
hashlib 0.665 ms (0.27%)
_blake2 0.311 ms (0.13%)
ddtrace.internal.schema 0.799 ms (0.33%)
ddtrace.internal.schema.span_attribute_schema 0.489 ms (0.20%)
ddtrace.settings.endpoint_config 0.629 ms (0.26%)
ddtrace.internal.utils.retry 0.355 ms (0.14%)
ddtrace.internal.serverless 0.285 ms (0.12%)
ddtrace.internal._unpatched 7.182 ms (2.93%)
json 6.027 ms (2.46%)
json.decoder 6.027 ms (2.46%)
re 6.027 ms (2.46%)
enum 4.083 ms (1.66%)
functools 2.033 ms (0.83%)
collections 1.360 ms (0.55%)
reprlib 0.187 ms (0.08%)
itertools 0.182 ms (0.07%)
keyword 0.134 ms (0.05%)
_collections 0.069 ms (0.03%)
_functools 0.053 ms (0.02%)
operator 0.445 ms (0.18%)
_operator 0.076 ms (0.03%)
types 0.267 ms (0.11%)
re._compiler 1.272 ms (0.52%)
re._parser 0.631 ms (0.26%)
re._constants 0.267 ms (0.11%)
re._casefix 0.209 ms (0.09%)
_sre 0.068 ms (0.03%)
copyreg 0.174 ms (0.07%)
threading 0.967 ms (0.39%)
_weakrefset 0.306 ms (0.12%)
ddtrace.internal 0.188 ms (0.08%)
ddtrace.trace 0.869 ms (0.35%)
ddtrace._trace.pin 0.358 ms (0.15%)
ddtrace._trace.filters 0.275 ms (0.11%)
ddtrace._trace.processor 0.275 ms (0.11%)
ddtrace.internal.writer 0.275 ms (0.11%)
ddtrace.internal.writer.writer 0.275 ms (0.11%)
ddtrace.internal.agent 0.275 ms (0.11%)
ddtrace._trace.context 0.236 ms (0.10%)
ddtrace._trace 0.236 ms (0.10%)
ddtrace.bootstrap.sitecustomize 11.002 ms (4.48%)
ddtrace.bootstrap.preload 10.006 ms (4.08%)
ddtrace.internal.products 8.869 ms (3.61%)
multiprocessing 3.720 ms (1.52%)
multiprocessing.context 3.407 ms (1.39%)
multiprocessing.reduction 2.245 ms (0.91%)
pickle 1.820 ms (0.74%)
_compat_pickle 0.443 ms (0.18%)
_pickle 0.396 ms (0.16%)
multiprocessing.process 0.444 ms (0.18%)
ddtrace.internal.remoteconfig._connectors 2.345 ms (0.96%)
ctypes 1.989 ms (0.81%)
_ctypes 0.627 ms (0.26%)
ctypes._endian 0.432 ms (0.18%)
multiprocessing.sharedctypes 1.823 ms (0.74%)
multiprocessing.heap 1.156 ms (0.47%)
multiprocessing.util 0.404 ms (0.16%)
mmap 0.397 ms (0.16%)
ddtrace.internal.remoteconfig._pubsub 0.651 ms (0.27%)
ddtrace.internal.remoteconfig._subscribers 0.334 ms (0.14%)
ddtrace.internal.remoteconfig._publishers 0.330 ms (0.13%)
ddtrace.settings.crashtracker 1.138 ms (0.46%)
ddtrace.internal.datadog.profiling.crashtracker 0.576 ms (0.23%)
ddtrace.internal.datadog.profiling.crashtracker._crashtracker 0.576 ms (0.23%)
ddtrace.internal.datadog.profiling._types 0.296 ms (0.12%)
ddtrace.internal.datadog.profiling.util 0.280 ms (0.11%)
ddtrace.internal.datadog.profiling 0.562 ms (0.23%)
ddtrace.internal.datadog 0.251 ms (0.10%)
ddtrace.appsec._common_module_patches 0.648 ms (0.26%)
ddtrace.appsec._metrics 0.648 ms (0.26%)
ddtrace.appsec._deduplications 0.282 ms (0.12%)
ddtrace._trace.trace_handlers 0.348 ms (0.14%)
ddtrace.contrib.trace_utils 0.348 ms (0.14%)
ddtrace.contrib.internal.trace_utils 0.348 ms (0.14%)
ddtrace.contrib.internal.trace_utils_base 0.348 ms (0.14%)

The following import paths have grown:

ddtrace.auto 12.752 ms (5.20%)
ddtrace 10.060 ms (4.10%)
ddtrace.internal._unpatched 7.250 ms (2.95%)
json 7.129 ms (2.90%)
json.decoder 6.905 ms (2.81%)
json.scanner 6.807 ms (2.77%)
_json 6.756 ms (2.75%)
json.encoder 0.113 ms (0.05%)
gc 0.078 ms (0.03%)
ddtrace.trace 0.453 ms (0.18%)
ddtrace._trace.tracer 0.206 ms (0.08%)
ddtrace.internal.debug 0.120 ms (0.05%)
ddtrace.internal.dogstatsd 0.087 ms (0.04%)
ddtrace.vendor.dogstatsd 0.087 ms (0.04%)
ddtrace.vendor.dogstatsd.base 0.087 ms (0.04%)
ddtrace.vendor.dogstatsd.container 0.087 ms (0.04%)
ddtrace._trace.filters 0.178 ms (0.07%)
ddtrace._trace.processor 0.178 ms (0.07%)
ddtrace._trace.sampler 0.178 ms (0.07%)
ddtrace._trace.span 0.178 ms (0.07%)
ddtrace._trace._span_pointer 0.105 ms (0.04%)
ddtrace._trace.telemetry 0.105 ms (0.04%)
ddtrace._trace.context 0.069 ms (0.03%)
ddtrace._trace._span_link 0.069 ms (0.03%)
ddtrace._logger 0.242 ms (0.10%)
ddtrace.internal.utils.formats 0.140 ms (0.06%)
ddtrace._monkey 0.156 ms (0.06%)
ddtrace.settings.asm 0.094 ms (0.04%)
ddtrace.appsec 0.063 ms (0.03%)
ddtrace.internal.core 0.063 ms (0.03%)
ddtrace.vendor.debtcollector 0.063 ms (0.03%)
ddtrace.vendor.debtcollector.renames 0.063 ms (0.03%)
ddtrace.bootstrap.sitecustomize 2.692 ms (1.10%)
ddtrace.bootstrap.preload 2.330 ms (0.95%)
ddtrace.settings.profiling 1.243 ms (0.51%)
ddtrace.vendor.psutil 0.786 ms (0.32%)
ddtrace.internal.datadog.profiling.ddup 0.457 ms (0.19%)
ddtrace.internal.datadog.profiling.ddup._ddup 0.457 ms (0.19%)
ddtrace.internal.products 0.289 ms (0.12%)
importlib.metadata 0.141 ms (0.06%)
importlib.abc 0.074 ms (0.03%)
importlib.resources 0.074 ms (0.03%)
importlib.resources._common 0.074 ms (0.03%)
importlib.resources._adapters 0.074 ms (0.03%)
importlib.metadata._adapters 0.067 ms (0.03%)
ddtrace.internal.uwsgi 0.076 ms (0.03%)
ddtrace.internal.symbol_db.remoteconfig 0.072 ms (0.03%)
ddtrace.internal.symbol_db.symbols 0.072 ms (0.03%)
ddtrace.internal.safety 0.072 ms (0.03%)
ddtrace._trace.trace_handlers 0.261 ms (0.11%)
ddtrace.contrib.internal.botocore.constants 0.083 ms (0.03%)
ddtrace.contrib.internal.botocore 0.083 ms (0.03%)
ddtrace.contrib.trace_utils 0.080 ms (0.03%)
ddtrace.contrib.internal.trace_utils 0.080 ms (0.03%)
ddtrace._trace.utils 0.060 ms (0.02%)
ddtrace._trace._inferred_proxy 0.037 ms (0.02%)
ddtrace.appsec._common_module_patches 0.101 ms (0.04%)
ddtrace.appsec._asm_request_context 0.101 ms (0.04%)

The following import paths have shrunk:

ddtrace.auto 8.243 ms (3.36%)
ddtrace.bootstrap.sitecustomize 7.485 ms (3.05%)
ddtrace.bootstrap.preload 7.142 ms (2.91%)
ddtrace.internal.products 5.509 ms (2.24%)
importlib.metadata 0.951 ms (0.39%)
importlib.abc 0.765 ms (0.31%)
importlib.resources 0.765 ms (0.31%)
importlib.resources._common 0.765 ms (0.31%)
csv 0.115 ms (0.05%)
importlib.metadata._collections 0.071 ms (0.03%)
ddtrace.internal.remoteconfig.worker 0.081 ms (0.03%)
ddtrace.internal.symbol_db.remoteconfig 0.065 ms (0.03%)
ddtrace.internal.symbol_db.symbols 0.065 ms (0.03%)
ddtrace.settings.symbol_db 0.065 ms (0.03%)
ddtrace.settings.code_origin 0.029 ms (0.01%)
ddtrace.settings.errortracking 0.023 ms (0.01%)
ddtrace.settings.profiling 0.997 ms (0.41%)
ddtrace.vendor.psutil 0.906 ms (0.37%)
ddtrace.vendor.psutil._common 0.832 ms (0.34%)
ddtrace.vendor.psutil._pslinux 0.074 ms (0.03%)
glob 0.074 ms (0.03%)
ddtrace.internal.datadog.profiling.stack_v2 0.090 ms (0.04%)
ddtrace.internal.datadog.profiling.stack_v2._stack_v2 0.090 ms (0.04%)
ddtrace.settings.crashtracker 0.516 ms (0.21%)
ddtrace.internal.datadog.profiling.crashtracker 0.516 ms (0.21%)
ddtrace.internal.datadog.profiling.crashtracker._crashtracker 0.490 ms (0.20%)
ddtrace.internal.runtime.runtime_metrics 0.120 ms (0.05%)
ddtrace.appsec._common_module_patches 0.173 ms (0.07%)
ddtrace.appsec._asm_request_context 0.173 ms (0.07%)
ddtrace.appsec._utils 0.173 ms (0.07%)
ddtrace 0.758 ms (0.31%)
ddtrace.trace 0.656 ms (0.27%)
ddtrace._trace.filters 0.323 ms (0.13%)
ddtrace._trace.processor 0.323 ms (0.13%)
ddtrace._trace.sampler 0.190 ms (0.08%)
ddtrace._trace.span 0.097 ms (0.04%)
ddtrace.internal.sampling 0.097 ms (0.04%)
ddtrace._trace.sampling_rule 0.097 ms (0.04%)
ddtrace.internal.glob_matching 0.097 ms (0.04%)
ddtrace.internal.writer 0.133 ms (0.05%)
ddtrace.internal.writer.writer 0.133 ms (0.05%)
ddtrace._trace.tracer 0.202 ms (0.08%)
ddtrace.internal.dogstatsd 0.112 ms (0.05%)
ddtrace.vendor.dogstatsd 0.112 ms (0.05%)
ddtrace.vendor.dogstatsd.base 0.112 ms (0.05%)
ddtrace.internal.processor.endpoint_call_counter 0.090 ms (0.04%)
ddtrace._trace.context 0.131 ms (0.05%)
ddtrace._trace.types 0.070 ms (0.03%)
ddtrace._monkey 0.102 ms (0.04%)
ddtrace.appsec 0.102 ms (0.04%)
ddtrace.internal.core 0.102 ms (0.04%)

@pr-commenter
Copy link

pr-commenter bot commented Apr 9, 2025

Benchmarks

Benchmark execution time: 2025-04-09 16:13:28

Comparing candidate commit b62819d in PR branch backport-13030-to-3.3 with baseline commit 4bf3c4d in branch main.

Found 0 performance improvements and 7 performance regressions! Performance is the same for 481 metrics, 2 unstable metrics.

scenario:iast_aspects-ospathbasename_aspect

  • 🟥 execution_time [+1.201µs; +1.232µs] or [+36.439%; +37.380%]

scenario:iast_aspects-ospathdirname_aspect

  • 🟥 execution_time [+1.247µs; +1.279µs] or [+33.185%; +34.056%]

scenario:iast_aspects-ospathjoin_aspect

  • 🟥 execution_time [+1.431µs; +1.471µs] or [+28.009%; +28.780%]

scenario:iast_aspects-ospathnormcase_aspect

  • 🟥 execution_time [+1.220µs; +1.273µs] or [+47.673%; +49.740%]

scenario:iast_aspects-ospathsplit_aspect

  • 🟥 execution_time [+1.318µs; +1.361µs] or [+33.936%; +35.042%]

scenario:iast_aspects-ospathsplitdrive_aspect

  • 🟥 execution_time [+1.244µs; +1.275µs] or [+44.211%; +45.318%]

scenario:iast_aspects-ospathsplitext_aspect

  • 🟥 execution_time [+1.292µs; +1.325µs] or [+35.235%; +36.117%]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants