Skip to content

chore(telemetry): report tested integration versions #6853

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

Merged
merged 46 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d7aa03a
test
wconti27 Sep 5, 2023
81d0c09
add default region
wconti27 Sep 5, 2023
3e8c2ca
change
wconti27 Sep 6, 2023
80937b8
fix precheck
wconti27 Sep 6, 2023
f0f765e
initial commit trying new way of getting integration and version
wconti27 Sep 6, 2023
ec90abf
reformat PR
wconti27 Sep 11, 2023
1d42e96
fix import errors from python 2
wconti27 Sep 11, 2023
096a5a0
fix py2.7 errors
wconti27 Sep 11, 2023
0c10cda
fix some more tests
wconti27 Sep 11, 2023
84a0431
fix some tests
wconti27 Sep 11, 2023
8878069
fix lint
wconti27 Sep 11, 2023
4bd9dda
fix remaining failures
wconti27 Sep 11, 2023
6d176df
add depencency name to request
wconti27 Oct 2, 2023
7be9143
Merge branch '2.x' into conti/test-integration-versions-branch-2
wconti27 Oct 2, 2023
a0029d7
fix lint
wconti27 Oct 2, 2023
f8a5307
change to error logging
wconti27 Oct 2, 2023
237a5aa
back to debug logging
wconti27 Oct 2, 2023
baca681
fix failing tests
wconti27 Oct 2, 2023
9eabbb5
store tested versions as artifacts
wconti27 Oct 4, 2023
c0c69ed
Merge branch '2.x' into conti/test-integration-versions-branch-2
wconti27 Oct 4, 2023
c7b78a2
add store artifacts
wconti27 Oct 5, 2023
a39b034
change log level back to debug
wconti27 Oct 5, 2023
59d8228
fix according to reviewer comments
wconti27 Oct 6, 2023
55cd6a4
dont run if resp body is empty
wconti27 Oct 6, 2023
66baa8a
fix script
wconti27 Oct 6, 2023
a571265
Merge branch '2.x' into conti/test-integration-versions-branch-2
wconti27 Oct 6, 2023
5235195
Merge branch '2.x' into conti/test-integration-versions-branch-2
wconti27 Oct 10, 2023
925b185
fix elasticsearch
wconti27 Oct 10, 2023
831b489
update elasticsearch dependency name
wconti27 Oct 10, 2023
85e1bb8
Merge branch '2.x' into conti/test-integration-versions-branch-2
wconti27 Oct 11, 2023
a61de75
update test agent image
wconti27 Oct 11, 2023
84ed39d
test again
wconti27 Oct 11, 2023
bc61ae8
Merge branch '2.x' into conti/test-integration-versions-branch-2
wconti27 Oct 12, 2023
fdf8492
update riotfile to run pyramid generated tests
wconti27 Oct 12, 2023
8c1165d
Merge branch '2.x' into conti/test-integration-versions-branch-2
wconti27 Oct 12, 2023
647e635
change file names
wconti27 Oct 12, 2023
46917a5
update test agent images
wconti27 Oct 12, 2023
69c4524
fix according to reviewer comments
wconti27 Oct 16, 2023
99ed2f3
more fixes
wconti27 Oct 16, 2023
c2ffcf4
fix file name
wconti27 Oct 16, 2023
30d4050
fix lint
wconti27 Oct 16, 2023
c03cf5f
fix tests
wconti27 Oct 16, 2023
b26b69a
Merge branch '2.x' into conti/test-integration-versions-branch-2
wconti27 Oct 16, 2023
8e3b663
Merge branch '2.x' into conti/test-integration-versions-branch-2
wconti27 Oct 16, 2023
4065011
Merge branch 'conti/test-integration-versions-branch-2' of github.com…
wconti27 Oct 16, 2023
b2d4ce4
clean up bash code
wconti27 Oct 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .circleci/config.templ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mongo_image: &mongo_image mongo:3.6@sha256:19c11a8f1064fd2bb713ef1270f79a742a184
httpbin_image: &httpbin_image kennethreitz/httpbin@sha256:2c7abc4803080c22928265744410173b6fea3b898872c01c5fd0f0f9df4a59fb
vertica_image: &vertica_image sumitchawla/vertica:latest
rabbitmq_image: &rabbitmq_image rabbitmq:3.7-alpine
testagent_image: &testagent_image ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:v1.11.0
testagent_image: &testagent_image ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:v1.13.1

parameters:
coverage:
Expand Down Expand Up @@ -180,6 +180,28 @@ commands:
path: test-results
- store_artifacts:
path: test-results
- run:
name: "Store Test Agent Supported Integrations Data"
command: |
if [[ -z "$(curl -s << parameters.trace_agent_url >>/test/integrations/tested_versions)" ]]; then
# No integrations were tested. Not saving any artifacts
echo "Response body is empty. Skipping saving integration artifacts."
else
# make temporary files to save response data to
response=$(mktemp) && headers=$(mktemp)
# create artifacts directory if it doesn't exist
[ -d "./artifacts" ] || mkdir -p "./artifacts"
# get tested integrations
curl -o "$response" -D "$headers" << parameters.trace_agent_url >>/test/integrations/tested_versions
# get filename representing the name of the tested integration from headers
filename=$(awk -F': ' '/file-name/{print $2}' "$headers" | tr -d '\r\n')
# copy data to final file and remove temp files
mv "$response" "artifacts/${filename}_supported_versions.csv"
rm "$headers"
fi
- store_artifacts:
path: artifacts
destination: supported-integrations
- save_cache:
key: lastsuccess-{{ .Environment.CIRCLE_BRANCH }}-<<parameters.pattern>>-{{ .Environment.CIRCLE_NODE_INDEX }}-{{ epoch }}
paths:
Expand Down Expand Up @@ -472,6 +494,9 @@ jobs:

test_logging:
<<: *contrib_job
docker:
- image: *ddtrace_dev_image
- *testagent
steps:
- run_test:
pattern: 'test_logging'
Expand Down Expand Up @@ -584,6 +609,9 @@ jobs:

dogpile_cache:
<<: *contrib_job
docker:
- image: *ddtrace_dev_image
- *testagent
steps:
- run_test:
pattern: 'dogpile_cache'
Expand Down Expand Up @@ -770,6 +798,9 @@ jobs:

pytest:
<<: *contrib_job
docker:
- image: *ddtrace_dev_image
- *testagent
steps:
- run_test:
pattern: 'pytest'
Expand Down
6 changes: 3 additions & 3 deletions ddtrace/contrib/elasticsearch/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def _es_modules():
)
for module_name in module_names:
try:
yield import_module(module_name)
module = import_module(module_name)
versions[module_name] = getattr(module, "__versionstr__", "")
yield module
except ImportError:
pass

Expand All @@ -59,8 +61,6 @@ def _es_modules():


def get_version_tuple(elasticsearch):
if getattr(elasticsearch, "__name__", None):
versions[elasticsearch.__name__] = getattr(elasticsearch, "__versionstr__", "")
return getattr(elasticsearch, "__version__", "")


Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/flask_login/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

def get_version():
# type: () -> str
return ""
return flask_login.__version__


class _FlaskLoginUserInfoRetriever(_UserInfoRetriever):
Expand Down
6 changes: 3 additions & 3 deletions ddtrace/contrib/psycopg/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def _psycopg_modules():
)
for module_name in module_names:
try:
yield import_module(module_name)
module = import_module(module_name)
PATCHED_VERSIONS[module_name] = getattr(module, "__version__", "")
yield module
except ImportError:
pass

Expand All @@ -114,8 +116,6 @@ def _patch(psycopg_module):
return
psycopg_module._datadog_patch = True

PATCHED_VERSIONS[psycopg_module.__name__] = getattr(psycopg_module, "__version__", "")

Pin(_config=config.psycopg).onto(psycopg_module)

if psycopg_module.__name__ == "psycopg2":
Expand Down
12 changes: 9 additions & 3 deletions ddtrace/contrib/sqlite3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@
cursor = db.cursor()
cursor.execute("select * from users where id = 1")
"""
from .patch import get_version
from .patch import patch
from ...internal.utils.importlib import require_modules


__all__ = ["patch", "get_version"]
required_modules = ["sqlite3"]

with require_modules(required_modules) as missing_modules:
if not missing_modules:
from .patch import get_version
from .patch import patch

__all__ = ["patch", "get_version"]
8 changes: 7 additions & 1 deletion ddtrace/contrib/unittest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@

Default: ``True``
"""
from ...internal.utils.importlib import require_modules
from .patch import get_version
from .patch import patch
from .patch import unpatch


__all__ = ["patch", "unpatch", "get_version"]
required_modules = ["unittest"]

with require_modules(required_modules) as missing_modules:
if not missing_modules:

__all__ = ["patch", "unpatch", "get_version"]
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ services:
volumes:
- ddagent:/tmp/ddagent:rw
testagent:
image: ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:v1.11.0
image: ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:v1.13.1
ports:
- "127.0.0.1:9126:8126"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion riotfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION):
),
Venv(
name="pyramid",
command="pytest {cmdargs} tests/contrib/pyramid/test_pyramid.py",
command="pytest {cmdargs} tests/contrib/pyramid",
pkgs={
"requests": [latest],
"webtest": [latest],
Expand Down
10 changes: 3 additions & 7 deletions scripts/contrib-patch-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def generate_patch_test_source(contrib):
if not required_modules_node:
print(
f"WARNING: failed to generate patch test for {contrib},"
" required_modules not found in ddtrace.contrib.{contrib}.__init__"
f" required_modules not found in ddtrace.contrib.{contrib}.__init__"
)
return

Expand All @@ -45,7 +45,7 @@ def generate_patch_test_source(contrib):
if not required_modules:
print(
f"WARNING: failed to generate patch test for {contrib},"
" ddtrace.contrib.{contrib}.required_modules could not be parsed"
f" ddtrace.contrib.{contrib}.required_modules could not be parsed"
)
return

Expand Down Expand Up @@ -76,6 +76,7 @@ class Test{contrib.title()}Patch(PatchTestCase.Base):
__module_name__ = "{module}"
__patch_func__ = patch
__unpatch_func__ = unpatch
__get_version__ = get_version

def assert_module_patched(self, {module.replace(".", "_")}):
pass
Expand All @@ -85,11 +86,6 @@ def assert_not_module_patched(self, {module.replace(".", "_")}):

def assert_not_module_double_patched(self, {module.replace(".", "_")}):
pass

def assert_module_implements_get_version(self):
version = get_version()
assert type(version) == str
assert version != ''
"""
).lstrip()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestAiobotocorePatch(PatchTestCase.Base):
__module_name__ = "aiobotocore.client"
__patch_func__ = patch
__unpatch_func__ = unpatch
__get_version__ = get_version

def assert_module_patched(self, aiobotocore_client):
pass
Expand All @@ -28,8 +29,3 @@ def assert_not_module_patched(self, aiobotocore_client):

def assert_not_module_double_patched(self, aiobotocore_client):
pass

def assert_module_implements_get_version(self):
version = get_version()
assert type(version) == str
assert version != ""
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestAiohttpPatch(PatchTestCase.Base):
__module_name__ = "aiohttp"
__patch_func__ = patch
__unpatch_func__ = unpatch
__get_version__ = get_version

def assert_module_patched(self, aiohttp):
pass
Expand All @@ -28,8 +29,3 @@ def assert_not_module_patched(self, aiohttp):

def assert_not_module_double_patched(self, aiohttp):
pass

def assert_module_implements_get_version(self):
version = get_version()
assert type(version) == str
assert version != ""
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestAiohttp_Jinja2Patch(PatchTestCase.Base):
__module_name__ = "aiohttp_jinja2"
__patch_func__ = patch
__unpatch_func__ = unpatch
__get_version__ = get_version

def assert_module_patched(self, aiohttp_jinja2):
pass
Expand All @@ -28,8 +29,3 @@ def assert_not_module_patched(self, aiohttp_jinja2):

def assert_not_module_double_patched(self, aiohttp_jinja2):
pass

def assert_module_implements_get_version(self):
version = get_version()
assert type(version) == str
assert version != ""
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestAiomysqlPatch(PatchTestCase.Base):
__module_name__ = "aiomysql"
__patch_func__ = patch
__unpatch_func__ = unpatch
__get_version__ = get_version

def assert_module_patched(self, aiomysql):
pass
Expand All @@ -28,8 +29,3 @@ def assert_not_module_patched(self, aiomysql):

def assert_not_module_double_patched(self, aiomysql):
pass

def assert_module_implements_get_version(self):
version = get_version()
assert type(version) == str
assert version != ""
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestAiopgPatch(PatchTestCase.Base):
__module_name__ = "aiopg"
__patch_func__ = patch
__unpatch_func__ = unpatch
__get_version__ = get_version

def assert_module_patched(self, aiopg):
pass
Expand All @@ -28,8 +29,3 @@ def assert_not_module_patched(self, aiopg):

def assert_not_module_double_patched(self, aiopg):
pass

def assert_module_implements_get_version(self):
version = get_version()
assert type(version) == str
assert version != ""
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestAioredisPatch(PatchTestCase.Base):
__module_name__ = "aioredis"
__patch_func__ = patch
__unpatch_func__ = unpatch
__get_version__ = get_version

def assert_module_patched(self, aioredis):
pass
Expand All @@ -28,8 +29,3 @@ def assert_not_module_patched(self, aioredis):

def assert_not_module_double_patched(self, aioredis):
pass

def assert_module_implements_get_version(self):
version = get_version()
assert type(version) == str
assert version != ""
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestAlgoliasearchPatch(PatchTestCase.Base):
__module_name__ = "algoliasearch"
__patch_func__ = patch
__unpatch_func__ = unpatch
__get_version__ = get_version

def assert_module_patched(self, algoliasearch):
pass
Expand All @@ -28,8 +29,3 @@ def assert_not_module_patched(self, algoliasearch):

def assert_not_module_double_patched(self, algoliasearch):
pass

def assert_module_implements_get_version(self):
version = get_version()
assert type(version) == str
assert version != ""
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestAredisPatch(PatchTestCase.Base):
__module_name__ = "aredis"
__patch_func__ = patch
__unpatch_func__ = unpatch
__get_version__ = get_version

def assert_module_patched(self, aredis):
pass
Expand All @@ -28,8 +29,3 @@ def assert_not_module_patched(self, aredis):

def assert_not_module_double_patched(self, aredis):
pass

def assert_module_implements_get_version(self):
version = get_version()
assert type(version) == str
assert version != ""
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestAsyncpgPatch(PatchTestCase.Base):
__module_name__ = "asyncpg"
__patch_func__ = patch
__unpatch_func__ = unpatch
__get_version__ = get_version

def assert_module_patched(self, asyncpg):
pass
Expand All @@ -28,8 +29,3 @@ def assert_not_module_patched(self, asyncpg):

def assert_not_module_double_patched(self, asyncpg):
pass

def assert_module_implements_get_version(self):
version = get_version()
assert type(version) == str
assert version != ""
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestBotoPatch(PatchTestCase.Base):
__module_name__ = "boto.connection"
__patch_func__ = patch
__unpatch_func__ = unpatch
__get_version__ = get_version

def assert_module_patched(self, boto_connection):
pass
Expand All @@ -28,8 +29,3 @@ def assert_not_module_patched(self, boto_connection):

def assert_not_module_double_patched(self, boto_connection):
pass

def assert_module_implements_get_version(self):
version = get_version()
assert type(version) == str
assert version != ""
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestBotocorePatch(PatchTestCase.Base):
__module_name__ = "botocore.client"
__patch_func__ = patch
__unpatch_func__ = unpatch
__get_version__ = get_version

def assert_module_patched(self, botocore_client):
pass
Expand All @@ -28,8 +29,3 @@ def assert_not_module_patched(self, botocore_client):

def assert_not_module_double_patched(self, botocore_client):
pass

def assert_module_implements_get_version(self):
version = get_version()
assert type(version) == str
assert version != ""
Loading