Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f2a9144
add all files
vitor-de-araujo Nov 24, 2025
9de090b
sed all the things
vitor-de-araujo Nov 24, 2025
5e8c6c4
too sed
vitor-de-araujo Nov 24, 2025
8853946
curb you enthusiasm
vitor-de-araujo Nov 24, 2025
dad27fb
again
vitor-de-araujo Nov 24, 2025
5fdb869
no vendoring
vitor-de-araujo Nov 24, 2025
26cb392
lint lint
vitor-de-araujo Nov 25, 2025
543e8c3
Merge branch 'main' of github.com:DataDog/dd-trace-py into vitor-de-a…
vitor-de-araujo Nov 25, 2025
915c8ce
--ddtestpy -> --ddtrace; DD_PYTEST_USE_NEW_PLUGIN; lint
vitor-de-araujo Nov 25, 2025
1f856af
remove -p no:ddtrace
vitor-de-araujo Nov 25, 2025
6fea7ab
add riot env
vitor-de-araujo Nov 25, 2025
c9112a6
remove slow mark
vitor-de-araujo Nov 25, 2025
809bfcd
security warnings
vitor-de-araujo Nov 25, 2025
c6866f4
update CODEOWNERS; itr:noskip
vitor-de-araujo Nov 25, 2025
555c938
suitespec?
vitor-de-araujo Nov 25, 2025
4ddf467
codeowners
vitor-de-araujo Nov 25, 2025
8f6797d
rename ddtrace submodule
vitor-de-araujo Nov 25, 2025
b3646ec
use ddtrace version
vitor-de-araujo Nov 25, 2025
aee58e3
ast grep
vitor-de-araujo Nov 25, 2025
a816158
remove duplicated fixture
vitor-de-araujo Nov 25, 2025
5e14b86
remove duplicated codeowners.py file
vitor-de-araujo Nov 25, 2025
bd00435
release note
vitor-de-araujo Nov 25, 2025
0db5f9e
add var to docs
vitor-de-araujo Nov 25, 2025
b96a25e
do not document the var yet
vitor-de-araujo Nov 25, 2025
166e15f
breakpoint
vitor-de-araujo Nov 25, 2025
f1e901f
Merge branch 'main' of github.com:DataDog/dd-trace-py into vitor-de-a…
vitor-de-araujo Nov 26, 2025
e28dd1a
Merge branch 'main' of github.com:DataDog/dd-trace-py into vitor-de-a…
vitor-de-araujo Nov 26, 2025
9c14437
be pytest-randomly-proof
vitor-de-araujo Nov 26, 2025
ad9851d
tracer_api
vitor-de-araujo Nov 26, 2025
f5af2ee
chore(ci_visibility): add telemetry to the new plugin (WIP)
vitor-de-araujo Nov 28, 2025
b98ba8a
lint
vitor-de-araujo Nov 28, 2025
a8fb56d
moar telemetry
vitor-de-araujo Nov 28, 2025
a6ec94f
dig oneself into a hole
vitor-de-araujo Nov 28, 2025
21e1c8e
dig harder
vitor-de-araujo Nov 28, 2025
9f63de4
retries and stuff
vitor-de-araujo Nov 28, 2025
63ac957
handle thy errors
vitor-de-araujo Nov 28, 2025
dcacb5a
actually send telemetry
vitor-de-araujo Nov 28, 2025
df266ef
background thread shutdown
vitor-de-araujo Nov 28, 2025
8bcb481
rename function
vitor-de-araujo Nov 29, 2025
ffb86ed
Merge branch 'main' of github.com:DataDog/dd-trace-py into vitor-de-a…
vitor-de-araujo Dec 2, 2025
5981b08
restore skipif
vitor-de-araujo Dec 2, 2025
db266fa
undo riotfile
vitor-de-araujo Dec 2, 2025
bdc72f4
fix them tests
vitor-de-araujo Dec 2, 2025
8b82b3f
security™
vitor-de-araujo Dec 2, 2025
ed231b8
moar tests
vitor-de-araujo Dec 2, 2025
d6370f4
even moar tests
vitor-de-araujo Dec 2, 2025
a6ce91a
telemetry tests
vitor-de-araujo Dec 2, 2025
9933f23
a
vitor-de-araujo Dec 2, 2025
cc4c5e0
even moar tests
vitor-de-araujo Dec 2, 2025
180ef25
SECURITY NOW!
vitor-de-araujo Dec 2, 2025
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
10 changes: 5 additions & 5 deletions ddtrace/internal/ci_visibility/telemetry/test_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@


class TEST_MANAGEMENT_TELEMETRY(str, Enum):
REQUEST = "test_management.request"
REQUEST_MS = "test_management.request_ms"
REQUEST_ERRORS = "test_management.request_errors"
RESPONSE_BYTES = "test_management.response_bytes"
RESPONSE_TESTS = "test_management.response_tests"
REQUEST = "test_management_tests.request"
REQUEST_MS = "test_management_tests.request_ms"
REQUEST_ERRORS = "test_management_tests.request_errors"
RESPONSE_BYTES = "test_management_tests.response_bytes"
RESPONSE_TESTS = "test_management_tests.response_tests"


def record_test_management_tests_count(test_management_count: int):
Expand Down
73 changes: 56 additions & 17 deletions ddtrace/testing/internal/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from ddtrace.testing.internal.git import GitTag
from ddtrace.testing.internal.http import BackendConnectorSetup
from ddtrace.testing.internal.http import FileAttachment
from ddtrace.testing.internal.telemetry import TelemetryAPI
from ddtrace.testing.internal.test_data import ITRSkippingLevel
from ddtrace.testing.internal.test_data import ModuleRef
from ddtrace.testing.internal.test_data import SuiteRef
Expand All @@ -30,18 +31,27 @@ def __init__(
itr_skipping_level: ITRSkippingLevel,
configurations: t.Dict[str, str],
connector_setup: BackendConnectorSetup,
telemetry_api: TelemetryAPI,
) -> None:
self.service = service
self.env = env
self.env_tags = env_tags
self.itr_skipping_level = itr_skipping_level
self.configurations = configurations
self.connector = connector_setup.get_connector_for_subdomain("api")
self.telemetry_api = telemetry_api

def close(self) -> None:
self.connector.close()

def get_settings(self) -> Settings:
telemetry = self.telemetry_api.with_request_metric_names(
count="git_requests.settings",
duration="git_requests.settings_ms",
response_bytes=None,
error="git_requests.settings_errors",
)

request_data = {
"data": {
"id": str(uuid.uuid4()),
Expand All @@ -59,15 +69,25 @@ def get_settings(self) -> Settings:
}

try:
response, response_data = self.connector.post_json("/api/v2/libraries/tests/services/setting", request_data)
attributes = response_data["data"]["attributes"]
result = self.connector.post_json(
"/api/v2/libraries/tests/services/setting", request_data, telemetry=telemetry
)
result.on_error_raise_exception()
attributes = result.parsed_response["data"]["attributes"]
return Settings.from_attributes(attributes)

except Exception:
log.exception("Error getting settings from API")
return Settings()

def get_known_tests(self) -> t.Set[TestRef]:
telemetry = self.telemetry_api.with_request_metric_names(
count="known_tests.request",
duration="known_tests.request_ms",
response_bytes="known_tests.response_bytes",
error="known_tests.request_errors",
)

request_data = {
"data": {
"id": str(uuid.uuid4()),
Expand All @@ -82,8 +102,9 @@ def get_known_tests(self) -> t.Set[TestRef]:
}

try:
response, response_data = self.connector.post_json("/api/v2/ci/libraries/tests", request_data)
tests_data = response_data["data"]["attributes"]["tests"]
result = self.connector.post_json("/api/v2/ci/libraries/tests", request_data, telemetry=telemetry)
result.on_error_raise_exception()
tests_data = result.parsed_response["data"]["attributes"]["tests"]
known_test_ids = set()

for module, suites in tests_data.items():
Expand All @@ -100,6 +121,13 @@ def get_known_tests(self) -> t.Set[TestRef]:
return set()

def get_test_management_properties(self) -> t.Dict[TestRef, TestProperties]:
telemetry = self.telemetry_api.with_request_metric_names(
count="test_management_tests.request",
duration="test_management_tests.request_ms",
response_bytes="test_management_tests.response_bytes",
error="test_management_tests.request_errors",
)

request_data = {
"data": {
"id": str(uuid.uuid4()),
Expand All @@ -113,11 +141,12 @@ def get_test_management_properties(self) -> t.Dict[TestRef, TestProperties]:
}

try:
response, response_data = self.connector.post_json(
"/api/v2/test/libraries/test-management/tests", request_data
result = self.connector.post_json(
"/api/v2/test/libraries/test-management/tests", request_data, telemetry=telemetry
)
result.on_error_raise_exception()
test_properties: t.Dict[TestRef, TestProperties] = {}
modules = response_data["data"]["attributes"]["modules"]
modules = result.parsed_response["data"]["attributes"]["modules"]

for module_name, module_data in modules.items():
module_ref = ModuleRef(module_name)
Expand Down Expand Up @@ -149,8 +178,9 @@ def get_known_commits(self, latest_commits: t.List[str]) -> t.List[str]:
}

try:
response, response_data = self.connector.post_json("/api/v2/git/repository/search_commits", request_data)
return [item["id"] for item in response_data["data"] if item["type"] == "commit"]
result = self.connector.post_json("/api/v2/git/repository/search_commits", request_data)
result.on_error_raise_exception()
return [item["id"] for item in result.parsed_response["data"] if item["type"] == "commit"]

except Exception:
log.exception("Failed to parse search_commits data")
Expand All @@ -173,14 +203,21 @@ def send_git_pack_file(self, packfile: Path) -> None:
name="packfile", filename=packfile.name, content_type="application/octet-stream", data=content
),
]
response, response_data = self.connector.post_files(
"/api/v2/git/repository/packfile", files=files, send_gzip=False
)
try:
result = self.connector.post_files("/api/v2/git/repository/packfile", files=files, send_gzip=False)
result.on_error_raise_exception()

if response.status != 204:
log.warning("Failed to upload git pack data: %s %s", response.status, response_data)
except Exception:
log.warning("Failed to upload git pack data")

def get_skippable_tests(self) -> t.Tuple[t.Set[t.Union[SuiteRef, TestRef]], t.Optional[str]]:
telemetry = self.telemetry_api.with_request_metric_names(
count="itr_skippable_tests.request",
duration="itr_skippable_tests.request_ms",
response_bytes="itr_skippable_tests.response_bytes",
error="itr_skippable_tests.request_errors",
)

request_data = {
"data": {
"id": str(uuid.uuid4()),
Expand All @@ -196,10 +233,12 @@ def get_skippable_tests(self) -> t.Tuple[t.Set[t.Union[SuiteRef, TestRef]], t.Op
}
}
try:
response, response_data = self.connector.post_json("/api/v2/ci/tests/skippable", request_data)
result = self.connector.post_json("/api/v2/ci/tests/skippable", request_data, telemetry=telemetry)
result.on_error_raise_exception()

skippable_items: t.Set[t.Union[SuiteRef, TestRef]] = set()

for item in response_data["data"]:
for item in result.parsed_response["data"]:
if item["type"] in ("test", "suite"):
module_ref = ModuleRef(item["attributes"].get("configurations", {}).get("test.bundle", EMPTY_NAME))
suite_ref = SuiteRef(module_ref, item["attributes"].get("suite", EMPTY_NAME))
Expand All @@ -209,7 +248,7 @@ def get_skippable_tests(self) -> t.Tuple[t.Set[t.Union[SuiteRef, TestRef]], t.Op
test_ref = TestRef(suite_ref, item["attributes"].get("name", EMPTY_NAME))
skippable_items.add(test_ref)

correlation_id = response_data["meta"]["correlation_id"]
correlation_id = result.parsed_response["meta"]["correlation_id"]

return skippable_items, correlation_id

Expand Down
Loading
Loading