From 5a610cc4e2efff5f7527ac4d13c027bb750e7ff4 Mon Sep 17 00:00:00 2001 From: "Gabriele N. Tornetta" Date: Tue, 22 Oct 2024 13:23:22 +0100 Subject: [PATCH 1/6] refactor: configuration telemetry reporting We refactor the implementation of the telemetry configuration reporting to use new API exposed by the latest release of envier. We also implement a configuration class that automatically reports configuration telemetry after the environment variables have been parsed and validated. --- .riot/requirements/1215c62.txt | 47 ++++++++++++++++++ .riot/requirements/132f882.txt | 47 ++++++++++++++++++ .riot/requirements/16af7e0.txt | 49 ------------------- .riot/requirements/1dcfbb2.txt | 47 ++++++++++++++++++ .../requirements/{1aaf6f6.txt => 1e6bfcb.txt} | 46 +++++++++-------- .riot/requirements/1f3d2c7.txt | 49 ------------------- .../requirements/{1fa807e.txt => 1f540f4.txt} | 46 +++++++++-------- .../requirements/{e39f833.txt => 6498eb0.txt} | 24 +++++---- .riot/requirements/bd5e098.txt | 47 ++++++++++++++++++ .../requirements/{edb39c1.txt => c23a971.txt} | 24 +++++---- .riot/requirements/d825572.txt | 49 ------------------- .riot/requirements/dd525d9.txt | 49 ------------------- ddtrace/settings/_core.py | 41 +++++++++++----- ddtrace/settings/dynamic_instrumentation.py | 5 +- hatch.toml | 3 +- min_compatible_versions.csv | 2 +- pyproject.toml | 2 +- riotfile.py | 2 - 18 files changed, 287 insertions(+), 292 deletions(-) create mode 100644 .riot/requirements/1215c62.txt create mode 100644 .riot/requirements/132f882.txt delete mode 100644 .riot/requirements/16af7e0.txt create mode 100644 .riot/requirements/1dcfbb2.txt rename .riot/requirements/{1aaf6f6.txt => 1e6bfcb.txt} (55%) delete mode 100644 .riot/requirements/1f3d2c7.txt rename .riot/requirements/{1fa807e.txt => 1f540f4.txt} (55%) rename .riot/requirements/{e39f833.txt => 6498eb0.txt} (76%) create mode 100644 .riot/requirements/bd5e098.txt rename .riot/requirements/{edb39c1.txt => c23a971.txt} (76%) delete mode 100644 .riot/requirements/d825572.txt delete mode 100644 .riot/requirements/dd525d9.txt diff --git a/.riot/requirements/1215c62.txt b/.riot/requirements/1215c62.txt new file mode 100644 index 00000000000..8906634707c --- /dev/null +++ b/.riot/requirements/1215c62.txt @@ -0,0 +1,47 @@ +# +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: +# +# pip-compile --no-annotate .riot/requirements/1215c62.in +# +aiosqlite==0.20.0 +annotated-types==0.7.0 +attrs==24.2.0 +blinker==1.8.2 +bytecode==0.15.1 +cattrs==22.2.0 +certifi==2024.8.30 +charset-normalizer==3.4.0 +click==8.1.7 +coverage[toml]==7.6.4 +flask==3.0.3 +hypothesis==6.45.0 +idna==3.10 +iniconfig==2.0.0 +iso8601==2.1.0 +itsdangerous==2.2.0 +jinja2==3.1.4 +markupsafe==3.0.2 +mock==5.1.0 +opentracing==2.4.0 +packaging==24.1 +peewee==3.17.7 +pluggy==1.5.0 +pony==0.7.19 +protobuf==5.28.2 +pycryptodome==3.21.0 +pydantic==2.9.2 +pydantic-core==2.23.4 +pypika-tortoise==0.2.1 +pytest==8.3.3 +pytest-cov==5.0.0 +pytest-mock==3.14.0 +pytz==2024.2 +requests==2.32.3 +sortedcontainers==2.4.0 +sqlalchemy==2.0.36 +tortoise-orm==0.21.7 +typing-extensions==4.12.2 +urllib3==2.2.3 +werkzeug==3.0.4 +xmltodict==0.14.2 diff --git a/.riot/requirements/132f882.txt b/.riot/requirements/132f882.txt new file mode 100644 index 00000000000..bafe49562a3 --- /dev/null +++ b/.riot/requirements/132f882.txt @@ -0,0 +1,47 @@ +# +# This file is autogenerated by pip-compile with Python 3.9 +# by the following command: +# +# pip-compile --no-annotate .riot/requirements/132f882.in +# +attrs==24.2.0 +boto3==1.35.45 +botocore==1.35.45 +bytecode==0.15.1 +certifi==2024.8.30 +charset-normalizer==3.4.0 +coverage[toml]==7.6.4 +datadog==0.50.1 +datadog-lambda==6.99.0 +ddtrace==2.14.4 +deprecated==1.2.14 +envier==0.6.1 +exceptiongroup==1.2.2 +hypothesis==6.45.0 +idna==3.10 +importlib-metadata==8.4.0 +iniconfig==2.0.0 +jmespath==1.0.1 +mock==5.1.0 +opentelemetry-api==1.27.0 +opentracing==2.4.0 +packaging==24.1 +pluggy==1.5.0 +protobuf==5.28.2 +pytest==8.3.3 +pytest-asyncio==0.21.1 +pytest-cov==5.0.0 +pytest-mock==3.14.0 +pytest-randomly==3.15.0 +python-dateutil==2.9.0.post0 +requests==2.32.3 +s3transfer==0.10.3 +six==1.16.0 +sortedcontainers==2.4.0 +tomli==2.0.2 +typing-extensions==4.12.2 +ujson==5.10.0 +urllib3==1.26.20 +wrapt==1.16.0 +xmltodict==0.14.2 +zipp==3.20.2 diff --git a/.riot/requirements/16af7e0.txt b/.riot/requirements/16af7e0.txt deleted file mode 100644 index df479a84c64..00000000000 --- a/.riot/requirements/16af7e0.txt +++ /dev/null @@ -1,49 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.9 -# by the following command: -# -# pip-compile --no-annotate --resolver=backtracking .riot/requirements/16af7e0.in -# -attrs==23.2.0 -boto3==1.34.139 -botocore==1.34.139 -bytecode==0.15.1 -cattrs==23.2.3 -certifi==2024.7.4 -charset-normalizer==3.3.2 -coverage[toml]==7.5.4 -datadog==0.49.1 -datadog-lambda==6.96.0 -ddsketch==3.0.1 -ddtrace==2.9.2 -deprecated==1.2.14 -envier==0.5.2 -exceptiongroup==1.2.1 -hypothesis==6.45.0 -idna==3.7 -importlib-metadata==7.1.0 -iniconfig==2.0.0 -jmespath==1.0.1 -mock==5.1.0 -opentelemetry-api==1.26.0 -opentracing==2.4.0 -packaging==24.1 -pluggy==1.5.0 -protobuf==5.27.2 -pytest==8.2.2 -pytest-asyncio==0.21.1 -pytest-cov==5.0.0 -pytest-mock==3.14.0 -pytest-randomly==3.15.0 -python-dateutil==2.9.0.post0 -requests==2.32.3 -s3transfer==0.10.2 -six==1.16.0 -sortedcontainers==2.4.0 -tomli==2.0.1 -typing-extensions==4.12.2 -ujson==5.10.0 -urllib3==1.26.19 -wrapt==1.16.0 -xmltodict==0.13.0 -zipp==3.19.2 diff --git a/.riot/requirements/1dcfbb2.txt b/.riot/requirements/1dcfbb2.txt new file mode 100644 index 00000000000..8ac7a88fe1c --- /dev/null +++ b/.riot/requirements/1dcfbb2.txt @@ -0,0 +1,47 @@ +# +# This file is autogenerated by pip-compile with Python 3.9 +# by the following command: +# +# pip-compile --no-annotate .riot/requirements/1dcfbb2.in +# +attrs==24.2.0 +boto3==1.35.45 +botocore==1.35.45 +bytecode==0.15.1 +certifi==2024.8.30 +charset-normalizer==3.4.0 +coverage[toml]==7.6.4 +datadog==0.50.1 +datadog-lambda==6.99.0 +ddtrace==2.14.4 +deprecated==1.2.14 +envier==0.6.1 +exceptiongroup==1.2.2 +hypothesis==6.45.0 +idna==3.10 +importlib-metadata==8.4.0 +iniconfig==2.0.0 +jmespath==1.0.1 +mock==5.1.0 +opentelemetry-api==1.27.0 +opentracing==2.4.0 +packaging==24.1 +pluggy==1.5.0 +protobuf==5.28.2 +pytest==8.3.3 +pytest-asyncio==0.21.1 +pytest-cov==5.0.0 +pytest-mock==3.14.0 +pytest-randomly==3.15.0 +python-dateutil==2.9.0.post0 +requests==2.32.3 +s3transfer==0.10.3 +six==1.16.0 +sortedcontainers==2.4.0 +tomli==2.0.2 +typing-extensions==4.12.2 +ujson==5.10.0 +urllib3==1.26.20 +wrapt==1.16.0 +xmltodict==0.14.2 +zipp==3.20.2 diff --git a/.riot/requirements/1aaf6f6.txt b/.riot/requirements/1e6bfcb.txt similarity index 55% rename from .riot/requirements/1aaf6f6.txt rename to .riot/requirements/1e6bfcb.txt index 5c36c6f9871..696f9d3801b 100644 --- a/.riot/requirements/1aaf6f6.txt +++ b/.riot/requirements/1e6bfcb.txt @@ -2,48 +2,46 @@ # This file is autogenerated by pip-compile with Python 3.8 # by the following command: # -# pip-compile --no-annotate --resolver=backtracking .riot/requirements/1aaf6f6.in +# pip-compile --no-annotate --resolver=backtracking .riot/requirements/1e6bfcb.in # -attrs==23.2.0 -boto3==1.34.139 -botocore==1.34.139 +attrs==24.2.0 +boto3==1.35.45 +botocore==1.35.45 bytecode==0.15.1 -cattrs==23.2.3 -certifi==2024.7.4 -charset-normalizer==3.3.2 -coverage[toml]==7.5.4 -datadog==0.49.1 -datadog-lambda==6.96.0 -ddsketch==3.0.1 -ddtrace==2.9.2 +certifi==2024.8.30 +charset-normalizer==3.4.0 +coverage[toml]==7.6.1 +datadog==0.50.1 +datadog-lambda==6.99.0 +ddtrace==2.14.4 deprecated==1.2.14 -envier==0.5.2 -exceptiongroup==1.2.1 +envier==0.6.1 +exceptiongroup==1.2.2 hypothesis==6.45.0 -idna==3.7 -importlib-metadata==7.1.0 +idna==3.10 +importlib-metadata==8.4.0 iniconfig==2.0.0 jmespath==1.0.1 mock==5.1.0 -opentelemetry-api==1.26.0 +opentelemetry-api==1.27.0 opentracing==2.4.0 packaging==24.1 pluggy==1.5.0 -protobuf==5.27.2 -pytest==8.2.2 +protobuf==5.28.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 requests==2.32.3 -s3transfer==0.10.2 +s3transfer==0.10.3 six==1.16.0 sortedcontainers==2.4.0 -tomli==2.0.1 +tomli==2.0.2 typing-extensions==4.12.2 ujson==5.10.0 -urllib3==1.26.19 +urllib3==1.26.20 wrapt==1.16.0 -xmltodict==0.13.0 -zipp==3.19.2 +xmltodict==0.14.2 +zipp==3.20.2 diff --git a/.riot/requirements/1f3d2c7.txt b/.riot/requirements/1f3d2c7.txt deleted file mode 100644 index 5d5a92ead13..00000000000 --- a/.riot/requirements/1f3d2c7.txt +++ /dev/null @@ -1,49 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.11 -# by the following command: -# -# pip-compile --no-annotate .riot/requirements/1f3d2c7.in -# -aiosqlite==0.17.0 -annotated-types==0.7.0 -attrs==23.2.0 -blinker==1.8.2 -bytecode==0.15.1 -cattrs==22.2.0 -certifi==2024.7.4 -charset-normalizer==3.3.2 -click==8.1.7 -coverage[toml]==7.6.0 -envier==0.5.2 -flask==3.0.3 -greenlet==3.0.3 -hypothesis==6.45.0 -idna==3.7 -iniconfig==2.0.0 -iso8601==1.1.0 -itsdangerous==2.2.0 -jinja2==3.1.4 -markupsafe==2.1.5 -mock==5.1.0 -opentracing==2.4.0 -packaging==24.1 -peewee==3.17.6 -pluggy==1.5.0 -pony==0.7.17 -protobuf==5.27.2 -pycryptodome==3.20.0 -pydantic==2.8.2 -pydantic-core==2.20.1 -pypika-tortoise==0.1.6 -pytest==8.3.2 -pytest-cov==5.0.0 -pytest-mock==3.14.0 -pytz==2024.1 -requests==2.32.3 -sortedcontainers==2.4.0 -sqlalchemy==2.0.31 -tortoise-orm==0.21.5 -typing-extensions==4.12.2 -urllib3==2.2.2 -werkzeug==3.0.3 -xmltodict==0.13.0 diff --git a/.riot/requirements/1fa807e.txt b/.riot/requirements/1f540f4.txt similarity index 55% rename from .riot/requirements/1fa807e.txt rename to .riot/requirements/1f540f4.txt index ca1c67d95b6..0836dd9eaa2 100644 --- a/.riot/requirements/1fa807e.txt +++ b/.riot/requirements/1f540f4.txt @@ -2,48 +2,46 @@ # This file is autogenerated by pip-compile with Python 3.8 # by the following command: # -# pip-compile --no-annotate --resolver=backtracking .riot/requirements/1fa807e.in +# pip-compile --no-annotate --resolver=backtracking .riot/requirements/1f540f4.in # -attrs==23.2.0 -boto3==1.34.139 -botocore==1.34.139 +attrs==24.2.0 +boto3==1.35.45 +botocore==1.35.45 bytecode==0.15.1 -cattrs==23.2.3 -certifi==2024.7.4 -charset-normalizer==3.3.2 -coverage[toml]==7.5.4 -datadog==0.49.1 -datadog-lambda==6.96.0 -ddsketch==3.0.1 -ddtrace==2.9.2 +certifi==2024.8.30 +charset-normalizer==3.4.0 +coverage[toml]==7.6.1 +datadog==0.50.1 +datadog-lambda==6.99.0 +ddtrace==2.14.4 deprecated==1.2.14 -envier==0.5.2 -exceptiongroup==1.2.1 +envier==0.6.1 +exceptiongroup==1.2.2 hypothesis==6.45.0 -idna==3.7 -importlib-metadata==7.1.0 +idna==3.10 +importlib-metadata==8.4.0 iniconfig==2.0.0 jmespath==1.0.1 mock==5.1.0 -opentelemetry-api==1.26.0 +opentelemetry-api==1.27.0 opentracing==2.4.0 packaging==24.1 pluggy==1.5.0 -protobuf==5.27.2 -pytest==8.2.2 +protobuf==5.28.2 +pytest==8.3.3 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 requests==2.32.3 -s3transfer==0.10.2 +s3transfer==0.10.3 six==1.16.0 sortedcontainers==2.4.0 -tomli==2.0.1 +tomli==2.0.2 typing-extensions==4.12.2 ujson==5.10.0 -urllib3==1.26.19 +urllib3==1.26.20 wrapt==1.16.0 -xmltodict==0.13.0 -zipp==3.19.2 +xmltodict==0.14.2 +zipp==3.20.2 diff --git a/.riot/requirements/e39f833.txt b/.riot/requirements/6498eb0.txt similarity index 76% rename from .riot/requirements/e39f833.txt rename to .riot/requirements/6498eb0.txt index e71709e9da3..7a42bc79998 100644 --- a/.riot/requirements/e39f833.txt +++ b/.riot/requirements/6498eb0.txt @@ -2,25 +2,23 @@ # This file is autogenerated by pip-compile with Python 3.7 # by the following command: # -# pip-compile --no-annotate --resolver=backtracking .riot/requirements/e39f833.in +# pip-compile --no-annotate --resolver=backtracking .riot/requirements/6498eb0.in # -attrs==23.2.0 +attrs==24.2.0 boto3==1.33.13 botocore==1.33.13 bytecode==0.13.0 -cattrs==23.1.2 -certifi==2024.7.4 -charset-normalizer==3.3.2 +certifi==2024.8.30 +charset-normalizer==3.4.0 coverage[toml]==7.2.7 -datadog==0.49.1 +datadog==0.50.1 datadog-lambda==5.85.0 -ddsketch==3.0.1 -ddtrace==2.9.2 +ddtrace==2.14.4 deprecated==1.2.14 -envier==0.5.2 -exceptiongroup==1.2.1 +envier==0.6.1 +exceptiongroup==1.2.2 hypothesis==6.45.0 -idna==3.7 +idna==3.10 importlib-metadata==6.5.0 iniconfig==2.0.0 jmespath==1.0.1 @@ -42,7 +40,7 @@ six==1.16.0 sortedcontainers==2.4.0 tomli==2.0.1 typing-extensions==4.7.1 -urllib3==1.26.19 +urllib3==1.26.20 wrapt==1.16.0 -xmltodict==0.13.0 +xmltodict==0.14.2 zipp==3.15.0 diff --git a/.riot/requirements/bd5e098.txt b/.riot/requirements/bd5e098.txt new file mode 100644 index 00000000000..5e457c989c4 --- /dev/null +++ b/.riot/requirements/bd5e098.txt @@ -0,0 +1,47 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# pip-compile --no-annotate .riot/requirements/bd5e098.in +# +aiosqlite==0.20.0 +annotated-types==0.7.0 +attrs==24.2.0 +blinker==1.8.2 +bytecode==0.15.1 +cattrs==22.2.0 +certifi==2024.8.30 +charset-normalizer==3.4.0 +click==8.1.7 +coverage[toml]==7.6.4 +flask==3.0.3 +hypothesis==6.45.0 +idna==3.10 +iniconfig==2.0.0 +iso8601==2.1.0 +itsdangerous==2.2.0 +jinja2==3.1.4 +markupsafe==3.0.2 +mock==5.1.0 +opentracing==2.4.0 +packaging==24.1 +peewee==3.17.7 +pluggy==1.5.0 +pony==0.7.19 +protobuf==5.28.2 +pycryptodome==3.21.0 +pydantic==2.9.2 +pydantic-core==2.23.4 +pypika-tortoise==0.2.1 +pytest==8.3.3 +pytest-cov==5.0.0 +pytest-mock==3.14.0 +pytz==2024.2 +requests==2.32.3 +sortedcontainers==2.4.0 +sqlalchemy==2.0.36 +tortoise-orm==0.21.7 +typing-extensions==4.12.2 +urllib3==2.2.3 +werkzeug==3.0.4 +xmltodict==0.14.2 diff --git a/.riot/requirements/edb39c1.txt b/.riot/requirements/c23a971.txt similarity index 76% rename from .riot/requirements/edb39c1.txt rename to .riot/requirements/c23a971.txt index 667e74f25cd..458ab589c40 100644 --- a/.riot/requirements/edb39c1.txt +++ b/.riot/requirements/c23a971.txt @@ -2,25 +2,23 @@ # This file is autogenerated by pip-compile with Python 3.7 # by the following command: # -# pip-compile --no-annotate --resolver=backtracking .riot/requirements/edb39c1.in +# pip-compile --no-annotate --resolver=backtracking .riot/requirements/c23a971.in # -attrs==23.2.0 +attrs==24.2.0 boto3==1.33.13 botocore==1.33.13 bytecode==0.13.0 -cattrs==23.1.2 -certifi==2024.7.4 -charset-normalizer==3.3.2 +certifi==2024.8.30 +charset-normalizer==3.4.0 coverage[toml]==7.2.7 -datadog==0.49.1 +datadog==0.50.1 datadog-lambda==5.85.0 -ddsketch==3.0.1 -ddtrace==2.9.2 +ddtrace==2.14.4 deprecated==1.2.14 -envier==0.5.2 -exceptiongroup==1.2.1 +envier==0.6.1 +exceptiongroup==1.2.2 hypothesis==6.45.0 -idna==3.7 +idna==3.10 importlib-metadata==6.5.0 iniconfig==2.0.0 jmespath==1.0.1 @@ -42,7 +40,7 @@ six==1.16.0 sortedcontainers==2.4.0 tomli==2.0.1 typing-extensions==4.7.1 -urllib3==1.26.19 +urllib3==1.26.20 wrapt==1.16.0 -xmltodict==0.13.0 +xmltodict==0.14.2 zipp==3.15.0 diff --git a/.riot/requirements/d825572.txt b/.riot/requirements/d825572.txt deleted file mode 100644 index 7ce81023285..00000000000 --- a/.riot/requirements/d825572.txt +++ /dev/null @@ -1,49 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.12 -# by the following command: -# -# pip-compile --no-annotate .riot/requirements/d825572.in -# -aiosqlite==0.17.0 -annotated-types==0.7.0 -attrs==23.2.0 -blinker==1.8.2 -bytecode==0.15.1 -cattrs==22.2.0 -certifi==2024.7.4 -charset-normalizer==3.3.2 -click==8.1.7 -coverage[toml]==7.6.0 -envier==0.5.2 -flask==3.0.3 -greenlet==3.0.3 -hypothesis==6.45.0 -idna==3.7 -iniconfig==2.0.0 -iso8601==1.1.0 -itsdangerous==2.2.0 -jinja2==3.1.4 -markupsafe==2.1.5 -mock==5.1.0 -opentracing==2.4.0 -packaging==24.1 -peewee==3.17.6 -pluggy==1.5.0 -pony==0.7.17 -protobuf==5.27.2 -pycryptodome==3.20.0 -pydantic==2.8.2 -pydantic-core==2.20.1 -pypika-tortoise==0.1.6 -pytest==8.3.2 -pytest-cov==5.0.0 -pytest-mock==3.14.0 -pytz==2024.1 -requests==2.32.3 -sortedcontainers==2.4.0 -sqlalchemy==2.0.31 -tortoise-orm==0.21.5 -typing-extensions==4.12.2 -urllib3==2.2.2 -werkzeug==3.0.3 -xmltodict==0.13.0 diff --git a/.riot/requirements/dd525d9.txt b/.riot/requirements/dd525d9.txt deleted file mode 100644 index 03c376f19df..00000000000 --- a/.riot/requirements/dd525d9.txt +++ /dev/null @@ -1,49 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.9 -# by the following command: -# -# pip-compile --no-annotate --resolver=backtracking .riot/requirements/dd525d9.in -# -attrs==23.2.0 -boto3==1.34.139 -botocore==1.34.139 -bytecode==0.15.1 -cattrs==23.2.3 -certifi==2024.7.4 -charset-normalizer==3.3.2 -coverage[toml]==7.5.4 -datadog==0.49.1 -datadog-lambda==6.96.0 -ddsketch==3.0.1 -ddtrace==2.9.2 -deprecated==1.2.14 -envier==0.5.2 -exceptiongroup==1.2.1 -hypothesis==6.45.0 -idna==3.7 -importlib-metadata==7.1.0 -iniconfig==2.0.0 -jmespath==1.0.1 -mock==5.1.0 -opentelemetry-api==1.26.0 -opentracing==2.4.0 -packaging==24.1 -pluggy==1.5.0 -protobuf==5.27.2 -pytest==8.2.2 -pytest-asyncio==0.21.1 -pytest-cov==5.0.0 -pytest-mock==3.14.0 -pytest-randomly==3.15.0 -python-dateutil==2.9.0.post0 -requests==2.32.3 -s3transfer==0.10.2 -six==1.16.0 -sortedcontainers==2.4.0 -tomli==2.0.1 -typing-extensions==4.12.2 -ujson==5.10.0 -urllib3==1.26.19 -wrapt==1.16.0 -xmltodict==0.13.0 -zipp==3.19.2 diff --git a/ddtrace/settings/_core.py b/ddtrace/settings/_core.py index 15964726749..84f5d13b16d 100644 --- a/ddtrace/settings/_core.py +++ b/ddtrace/settings/_core.py @@ -5,27 +5,44 @@ from typing import Optional # noqa:F401 from typing import Union # noqa:F401 -from envier.env import EnvVariable -from envier.env import _normalized +from envier import Env from ddtrace.internal.telemetry import telemetry_writer -def report_telemetry(env: Any) -> None: - for name, e in list(env.__class__.__dict__.items()): - if isinstance(e, EnvVariable) and not e.private: - env_name = env._full_prefix + _normalized(e.name) - env_val = e(env, env._full_prefix) - raw_val = env.source.get(env_name) - if env_name in env.source and env_val == e._cast(e.type, raw_val, env): +class Config(Env): + """Env-based configuration sub-class for automatic telemetry reporting.""" + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self._report_telemetry() + + def _report_telemetry(self) -> None: + for name, e in type(self).items(recursive=True): + if e.private: + continue + + env_name = e.full_name + + # Get the item value recursively + env_val = self + for p in name.split("."): + env_val = getattr(env_val, p) + + source = "unknown" + if env_name in self.source: source = "env_var" - elif env_val == e.default: - source = "default" else: - source = "unknown" + if env_val == e.default: + source = "default" + telemetry_writer.add_configuration(env_name, env_val, source) +def report_telemetry(env: Env) -> None: + return Config._report_telemetry(env) + + def get_config( envs: Union[str, List[str]], default: Any = None, diff --git a/ddtrace/settings/dynamic_instrumentation.py b/ddtrace/settings/dynamic_instrumentation.py index 27008bec692..77afd89a151 100644 --- a/ddtrace/settings/dynamic_instrumentation.py +++ b/ddtrace/settings/dynamic_instrumentation.py @@ -1,14 +1,12 @@ import re import typing as t -from envier import En - from ddtrace.internal import gitmetadata from ddtrace.internal.agent import get_trace_url from ddtrace.internal.constants import DEFAULT_SERVICE_NAME from ddtrace.internal.utils.config import get_application_name from ddtrace.settings import _config as ddconfig -from ddtrace.settings._core import report_telemetry as _report_telemetry +from ddtrace.settings._core import Config as En from ddtrace.version import get_version @@ -132,4 +130,3 @@ class DynamicInstrumentationConfig(En): config = DynamicInstrumentationConfig() -_report_telemetry(config) diff --git a/hatch.toml b/hatch.toml index 8eef89a6a4e..57d052661c7 100644 --- a/hatch.toml +++ b/hatch.toml @@ -9,7 +9,6 @@ dependencies = [ "bandit==1.7.5", "mypy==0.991", "coverage==7.3.0", - "envier==0.5.2", "types-docutils==0.19.1.1", "types-protobuf==3.20.4.5", "types-PyYAML==6.0.12.2", @@ -83,7 +82,7 @@ dependencies = [ # copied from library dependencies "protobuf>=3", "typing_extensions", "xmltodict>=0.12", - "envier==0.5.2", + "envier==0.6.1", "opentelemetry-api>=1", "opentracing>=2.0.0", "bytecode", diff --git a/min_compatible_versions.csv b/min_compatible_versions.csv index 0928fd308be..11cebfd8f08 100644 --- a/min_compatible_versions.csv +++ b/min_compatible_versions.csv @@ -60,7 +60,7 @@ elasticsearch7,~=7.13.0 elasticsearch7[async],0 elasticsearch8,~=8.0.1 elasticsearch[async],0 -envier,==0.5.2 +envier,==0.6.1 exceptiongroup,0 faiss-cpu,==1.8.0 falcon,~=3.0.0 diff --git a/pyproject.toml b/pyproject.toml index 9c8ff26d223..d3fb499e908 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ dependencies = [ "bytecode>=0.15.0; python_version>='3.12'", "bytecode>=0.14.0; python_version~='3.11.0'", "bytecode>=0.13.0; python_version<'3.11'", - "envier~=0.5", + "envier~=0.6.1", "importlib_metadata<=6.5.0; python_version<'3.8'", "opentelemetry-api>=1", "protobuf>=3", diff --git a/riotfile.py b/riotfile.py index ec4006e3fbe..f400548c7a6 100644 --- a/riotfile.py +++ b/riotfile.py @@ -201,7 +201,6 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION): "tortoise-orm": latest, "peewee": latest, "requests": latest, - "envier": "==0.5.2", "cattrs": "<23.1.1", "protobuf": ">=3", "typing_extensions": latest, @@ -2780,7 +2779,6 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION): "datadog-lambda": [">=4.66.0", latest], "pytest-asyncio": "==0.21.1", "pytest-randomly": latest, - "envier": "==0.5.2", }, ), Venv( From 9bdab981ed067aef050d00c7706bf12fb7d40e7e Mon Sep 17 00:00:00 2001 From: Munir Abdinur Date: Tue, 22 Oct 2024 12:58:18 -0400 Subject: [PATCH 2/6] fix broken peer service telemetry logic ensure recursivzely defined envier items are captured in telemetry --- ddtrace/settings/peer_service.py | 9 +++------ tests/telemetry/test_writer.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ddtrace/settings/peer_service.py b/ddtrace/settings/peer_service.py index 7bc56849a95..2e0af732c3d 100644 --- a/ddtrace/settings/peer_service.py +++ b/ddtrace/settings/peer_service.py @@ -1,10 +1,8 @@ -import os - from ddtrace.ext import SpanKind from ddtrace.internal.schema import SCHEMA_VERSION from ddtrace.internal.utils.formats import asbool from ddtrace.internal.utils.formats import parse_tags_str -from ddtrace.settings._core import report_telemetry as _report_telemetry +from ddtrace.settings._core import get_config as _get_config class PeerServiceConfig(object): @@ -23,7 +21,7 @@ def __init__(self, set_defaults_enabled=None, peer_service_mapping=None): @property def set_defaults_enabled(self): if self._set_defaults_enabled is None: - env_enabled = asbool(os.getenv("DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED", default=False)) + env_enabled = _get_config("DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED", False, asbool) self._set_defaults_enabled = SCHEMA_VERSION == "v1" or (SCHEMA_VERSION == "v0" and env_enabled) return self._set_defaults_enabled @@ -31,11 +29,10 @@ def set_defaults_enabled(self): @property def peer_service_mapping(self): if self._peer_service_mapping is None: - self._unparsed_peer_service_mapping = os.getenv("DD_TRACE_PEER_SERVICE_MAPPING", default="") + self._unparsed_peer_service_mapping = _get_config("DD_TRACE_PEER_SERVICE_MAPPING", "") self._peer_service_mapping = parse_tags_str(self._unparsed_peer_service_mapping) return self._peer_service_mapping _ps_config = PeerServiceConfig() -_report_telemetry(_ps_config) diff --git a/tests/telemetry/test_writer.py b/tests/telemetry/test_writer.py index d90a7351eba..6adfa019cc1 100644 --- a/tests/telemetry/test_writer.py +++ b/tests/telemetry/test_writer.py @@ -289,7 +289,7 @@ def test_app_started_event_configuration_override(test_agent_session, run_python {"name": "DD_API_SECURITY_SAMPLE_DELAY", "origin": "default", "value": 30.0}, {"name": "DD_APPSEC_AUTOMATED_USER_EVENTS_TRACKING", "origin": "default", "value": ""}, {"name": "DD_APPSEC_AUTOMATED_USER_EVENTS_TRACKING_ENABLED", "origin": "default", "value": True}, - {"name": "DD_APPSEC_AUTO_USER_INSTRUMENTATION_MODE", "origin": "default", "value": ""}, + {"name": "DD_APPSEC_AUTO_USER_INSTRUMENTATION_MODE", "origin": "unknown", "value": "identification"}, {"name": "DD_APPSEC_ENABLED", "origin": "env_var", "value": True}, {"name": "DD_APPSEC_MAX_STACK_TRACES", "origin": "default", "value": 2}, {"name": "DD_APPSEC_MAX_STACK_TRACE_DEPTH", "origin": "default", "value": 32}, @@ -386,12 +386,21 @@ def test_app_started_event_configuration_override(test_agent_session, run_python {"name": "DD_PROFILING_ENABLE_ASSERTS", "origin": "default", "value": False}, {"name": "DD_PROFILING_ENABLE_CODE_PROVENANCE", "origin": "default", "value": True}, {"name": "DD_PROFILING_ENDPOINT_COLLECTION_ENABLED", "origin": "default", "value": True}, + {"name": "DD_PROFILING_EXPORT_LIBDD_ENABLED", "origin": "default", "value": False}, + {"name": "DD_PROFILING_HEAP_ENABLED", "origin": "env_var", "value": False}, + {"name": "DD_PROFILING_HEAP_SAMPLE_SIZE", "origin": "default", "value": None}, {"name": "DD_PROFILING_IGNORE_PROFILER", "origin": "default", "value": False}, + {"name": "DD_PROFILING_LOCK_ENABLED", "origin": "env_var", "value": False}, + {"name": "DD_PROFILING_LOCK_NAME_INSPECT_DIR", "origin": "default", "value": True}, {"name": "DD_PROFILING_MAX_EVENTS", "origin": "default", "value": 16384}, {"name": "DD_PROFILING_MAX_FRAMES", "origin": "env_var", "value": 512}, {"name": "DD_PROFILING_MAX_TIME_USAGE_PCT", "origin": "default", "value": 1.0}, + {"name": "DD_PROFILING_MEMORY_ENABLED", "origin": "env_var", "value": False}, + {"name": "DD_PROFILING_MEMORY_EVENTS_BUFFER", "origin": "default", "value": 16}, {"name": "DD_PROFILING_OUTPUT_PPROF", "origin": "default", "value": None}, {"name": "DD_PROFILING_SAMPLE_POOL_CAPACITY", "origin": "default", "value": 4}, + {"name": "DD_PROFILING_STACK_ENABLED", "origin": "env_var", "value": False}, + {"name": "DD_PROFILING_STACK_V2_ENABLED", "origin": "default", "value": False}, {"name": "DD_PROFILING_TAGS", "origin": "default", "value": ""}, {"name": "DD_PROFILING_TIMELINE_ENABLED", "origin": "default", "value": False}, {"name": "DD_PROFILING_UPLOAD_INTERVAL", "origin": "env_var", "value": 10.0}, @@ -435,6 +444,8 @@ def test_app_started_event_configuration_override(test_agent_session, run_python {"name": "DD_TRACE_OTEL_ENABLED", "origin": "env_var", "value": True}, {"name": "DD_TRACE_PARTIAL_FLUSH_ENABLED", "origin": "env_var", "value": False}, {"name": "DD_TRACE_PARTIAL_FLUSH_MIN_SPANS", "origin": "env_var", "value": 3}, + {"name": "DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED", "origin": "default", "value": False}, + {"name": "DD_TRACE_PEER_SERVICE_MAPPING", "origin": "env_var", "value": "default_service:remapped_service"}, {"name": "DD_TRACE_PROPAGATION_EXTRACT_FIRST", "origin": "default", "value": False}, {"name": "DD_TRACE_PROPAGATION_HTTP_BAGGAGE_ENABLED", "origin": "default", "value": False}, {"name": "DD_TRACE_PROPAGATION_STYLE_EXTRACT", "origin": "env_var", "value": "tracecontext"}, From 597e5fbf7c40919791d116c3167faf74f9262fef Mon Sep 17 00:00:00 2001 From: "Gabriele N. Tornetta" Date: Wed, 23 Oct 2024 09:29:18 +0100 Subject: [PATCH 3/6] Update hatch.toml --- hatch.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/hatch.toml b/hatch.toml index 57d052661c7..81f0205f2f5 100644 --- a/hatch.toml +++ b/hatch.toml @@ -9,6 +9,7 @@ dependencies = [ "bandit==1.7.5", "mypy==0.991", "coverage==7.3.0", + "envier==0.6.1", "types-docutils==0.19.1.1", "types-protobuf==3.20.4.5", "types-PyYAML==6.0.12.2", From 2cd3df5724352358a27ca504efb7d912a4f0f916 Mon Sep 17 00:00:00 2001 From: Munir Abdinur Date: Fri, 25 Oct 2024 14:45:54 -0400 Subject: [PATCH 4/6] Apply suggestions from code review --- ddtrace/settings/_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddtrace/settings/_core.py b/ddtrace/settings/_core.py index 84f5d13b16d..a2c4eb9a295 100644 --- a/ddtrace/settings/_core.py +++ b/ddtrace/settings/_core.py @@ -40,7 +40,7 @@ def _report_telemetry(self) -> None: def report_telemetry(env: Env) -> None: - return Config._report_telemetry(env) + Config._report_telemetry(env) def get_config( From b221b6514ee069ffd01054488eb97a36024ec69e Mon Sep 17 00:00:00 2001 From: "Gabriele N. Tornetta" Date: Wed, 13 Nov 2024 10:47:02 +0000 Subject: [PATCH 5/6] remove DI-related change --- ddtrace/settings/dynamic_instrumentation.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ddtrace/settings/dynamic_instrumentation.py b/ddtrace/settings/dynamic_instrumentation.py index 77afd89a151..27008bec692 100644 --- a/ddtrace/settings/dynamic_instrumentation.py +++ b/ddtrace/settings/dynamic_instrumentation.py @@ -1,12 +1,14 @@ import re import typing as t +from envier import En + from ddtrace.internal import gitmetadata from ddtrace.internal.agent import get_trace_url from ddtrace.internal.constants import DEFAULT_SERVICE_NAME from ddtrace.internal.utils.config import get_application_name from ddtrace.settings import _config as ddconfig -from ddtrace.settings._core import Config as En +from ddtrace.settings._core import report_telemetry as _report_telemetry from ddtrace.version import get_version @@ -130,3 +132,4 @@ class DynamicInstrumentationConfig(En): config = DynamicInstrumentationConfig() +_report_telemetry(config) From 43f58426da0b3a4f8b49b5d414f304219af1873a Mon Sep 17 00:00:00 2001 From: Munir Abdinur Date: Tue, 7 Jan 2025 14:07:36 -0500 Subject: [PATCH 6/6] fix failing test --- tests/telemetry/test_writer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/telemetry/test_writer.py b/tests/telemetry/test_writer.py index 2a0643f12e0..9579f35ce04 100644 --- a/tests/telemetry/test_writer.py +++ b/tests/telemetry/test_writer.py @@ -410,6 +410,8 @@ def test_app_started_event_configuration_override(test_agent_session, run_python {"name": "DD_PROFILING_MEMORY_ENABLED", "origin": "env_var", "value": False}, {"name": "DD_PROFILING_MEMORY_EVENTS_BUFFER", "origin": "default", "value": 16}, {"name": "DD_PROFILING_OUTPUT_PPROF", "origin": "default", "value": None}, + {"name": "DD_PROFILING_PYTORCH_ENABLED", "origin": "default", "value": False}, + {"name": "DD_PROFILING_PYTORCH_EVENTS_LIMIT", "origin": "default", "value": 1000000}, {"name": "DD_PROFILING_SAMPLE_POOL_CAPACITY", "origin": "default", "value": 4}, {"name": "DD_PROFILING_STACK_ENABLED", "origin": "env_var", "value": False}, {"name": "DD_PROFILING_STACK_V2_ENABLED", "origin": "default", "value": False},