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

tests: prevent double publishing of metrics #4960

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ def record_props(request, record_property):
def pytest_runtest_logreport(report):
"""Send general test metrics to CloudWatch"""

# only publish metrics from the main process
worker_id = os.environ.get("PYTEST_XDIST_WORKER")
if worker_id is not None:
return

# The pytest's test protocol has three phases for each test item: setup,
# call and teardown. At the end of each phase, pytest_runtest_logreport()
# is called.
Expand Down Expand Up @@ -135,6 +140,7 @@ def pytest_runtest_logreport(report):
# and global
{},
)
METRICS.set_property("pytest_xdist_worker", worker_id)
METRICS.set_property("result", report.outcome)
METRICS.set_property("location", report.location)
for prop_name, prop_val in report.user_properties:
Expand Down
Loading