Skip to content

Commit d68fdad

Browse files
test(profiling): collector log tests [backport 2.0] (#7445)
Backport 4f8888d from #7415 to 2.0. We improve the logic around log call testing in a profiling collector test to ensure that we ignore non-profiling-related log calls. This fixes recent flakiness probably caused by some extra logging done by other products that would show up in the fixed profiling test. ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [x] 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) - [x] If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. - [x] This PR doesn't touch any of that. Co-authored-by: Gabriele N. Tornetta <[email protected]>
1 parent 88333ad commit d68fdad

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/profiling/test_profiler.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,14 +377,18 @@ def _build_default_exporters(self, *args, **kargs):
377377
err_collector = mock.MagicMock(wraps=ErrCollect(p._recorder))
378378
p._collectors = [err_collector]
379379
p.start()
380-
assert caplog.record_tuples == [
381-
(("ddtrace.profiling.profiler", logging.ERROR, "Failed to start collector %r, disabling." % err_collector))
380+
381+
def profiling_tuples(tuples):
382+
return [t for t in tuples if t[0].startswith("ddtrace.profiling")]
383+
384+
assert profiling_tuples(caplog.record_tuples) == [
385+
("ddtrace.profiling.profiler", logging.ERROR, "Failed to start collector %r, disabling." % err_collector)
382386
]
383387
time.sleep(2)
384388
p.stop()
385389
assert err_collector.snapshot.call_count == 0
386-
assert caplog.record_tuples == [
387-
(("ddtrace.profiling.profiler", logging.ERROR, "Failed to start collector %r, disabling." % err_collector))
390+
assert profiling_tuples(caplog.record_tuples) == [
391+
("ddtrace.profiling.profiler", logging.ERROR, "Failed to start collector %r, disabling." % err_collector)
388392
]
389393

390394

0 commit comments

Comments
 (0)