-
Notifications
You must be signed in to change notification settings - Fork 394
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
fix(tracing): do not raise exception if partial flush is triggered without any spans #9349
fix(tracing): do not raise exception if partial flush is triggered without any spans #9349
Conversation
Datadog ReportBranch report: ❌ 1 Failed (0 Known Flaky), 169460 Passed, 1077 Skipped, 9h 44m 55.2s Total duration (25m 13.56s time saved) ❌ Failed Tests (1)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a regression test?
the simple case we had should work well:
with tracer.trace("test"):
tracer.configure(partial_flush_enabled=True, partial_flush_min_spans=1)
BenchmarksBenchmark execution time: 2024-06-18 08:06:16 Comparing candidate commit a49062d in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 221 metrics, 9 unstable metrics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to backport this? I would think no since it isn't a bug fix. if there isn't a release note we cannot release a patch with this anyways, so it would have to wait for another change to be backported.
we might want to change this to a fix(tracing): do not raise exception if partial flush is triggered without any spans
, add a release note, and then keep the backports. wdyt?
...asenotes/notes/fix-tracing-dont_raise_exception_on_empty_partial_flush-131cd3268101f255.yaml
Outdated
Show resolved
Hide resolved
...asenotes/notes/fix-tracing-dont_raise_exception_on_empty_partial_flush-131cd3268101f255.yaml
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9349 +/- ##
===========================================
- Coverage 75.61% 10.10% -65.51%
===========================================
Files 1336 1347 +11
Lines 125991 125077 -914
===========================================
- Hits 95271 12643 -82628
- Misses 30720 112434 +81714 ☔ View full report in Codecov by Sentry. |
…artial_flush-131cd3268101f255.yaml Co-authored-by: Brett Langdon <brett.langdon@datadoghq.com>
…y' of github.com:DataDog/dd-trace-py into romain.komorn/AIT-10242/dont_crash_when_spans_list_empty
…y' of github.com:DataDog/dd-trace-py into romain.komorn/AIT-10242/dont_crash_when_spans_list_empty
So after yet another twist and turn... @brettlangdon and I decided that we don't want to alter the behavior of the span aggregator in this PR. Any spans opened prior to forking could end up getting submitted if they're closed in the forked process (which is not currently the case). Deciding whether that's desirable behavior is outside of the scope of this change. I'm leaving in the change to the |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.7 2.7
# Navigate to the new working tree
cd .worktrees/backport-2.7
# Create a new branch
git switch --create backport-9349-to-2.7
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 fffab017cb2de72d10b35585350c7fa65756e785
# Push it to GitHub
git push --set-upstream origin backport-9349-to-2.7
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.7 Then, create a pull request where the |
…thout any spans (#9349) Adds a guard against `on_span_finish()` with partial flushing on running into an `IndexError` because there are no spans to flush (which may happen if `tracer.configure()` was called between the time a span was created and the time it was finished). In practice, this turns into: ``` >>> import ddtrace >>> with ddtrace.tracer.trace("regression"): ... ddtrace.tracer.configure(partial_flush_min_spans=1) ... Partial flush triggered but no spans to flush (was tracer reconfigured?) ``` This also refactors the test for our `os.fork()` wrapper to have the child process unpatch `coverage` (just in case, since it occasionally causes exceptions on exit) and exit cleanly (otherwise it would continue running other tests which is not what we want). ## 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] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [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)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has 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) --------- Co-authored-by: Brett Langdon <brett.langdon@datadoghq.com> Co-authored-by: Federico Mon <federico.mon@datadoghq.com> Co-authored-by: Emmett Butler <723615+emmettbutler@users.noreply.github.com> (cherry picked from commit fffab01)
…thout any spans (#9349) Adds a guard against `on_span_finish()` with partial flushing on running into an `IndexError` because there are no spans to flush (which may happen if `tracer.configure()` was called between the time a span was created and the time it was finished). In practice, this turns into: ``` >>> import ddtrace >>> with ddtrace.tracer.trace("regression"): ... ddtrace.tracer.configure(partial_flush_min_spans=1) ... Partial flush triggered but no spans to flush (was tracer reconfigured?) ``` This also refactors the test for our `os.fork()` wrapper to have the child process unpatch `coverage` (just in case, since it occasionally causes exceptions on exit) and exit cleanly (otherwise it would continue running other tests which is not what we want). ## 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] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [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)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has 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) --------- Co-authored-by: Brett Langdon <brett.langdon@datadoghq.com> Co-authored-by: Federico Mon <federico.mon@datadoghq.com> Co-authored-by: Emmett Butler <723615+emmettbutler@users.noreply.github.com> (cherry picked from commit fffab01)
…thout any spans (#9349) Adds a guard against `on_span_finish()` with partial flushing on running into an `IndexError` because there are no spans to flush (which may happen if `tracer.configure()` was called between the time a span was created and the time it was finished). In practice, this turns into: ``` >>> import ddtrace >>> with ddtrace.tracer.trace("regression"): ... ddtrace.tracer.configure(partial_flush_min_spans=1) ... Partial flush triggered but no spans to flush (was tracer reconfigured?) ``` This also refactors the test for our `os.fork()` wrapper to have the child process unpatch `coverage` (just in case, since it occasionally causes exceptions on exit) and exit cleanly (otherwise it would continue running other tests which is not what we want). ## 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] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [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)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has 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) --------- Co-authored-by: Brett Langdon <brett.langdon@datadoghq.com> Co-authored-by: Federico Mon <federico.mon@datadoghq.com> Co-authored-by: Emmett Butler <723615+emmettbutler@users.noreply.github.com> (cherry picked from commit fffab01)
…thout any spans (#9349) Adds a guard against `on_span_finish()` with partial flushing on running into an `IndexError` because there are no spans to flush (which may happen if `tracer.configure()` was called between the time a span was created and the time it was finished). In practice, this turns into: ``` >>> import ddtrace >>> with ddtrace.tracer.trace("regression"): ... ddtrace.tracer.configure(partial_flush_min_spans=1) ... Partial flush triggered but no spans to flush (was tracer reconfigured?) ``` This also refactors the test for our `os.fork()` wrapper to have the child process unpatch `coverage` (just in case, since it occasionally causes exceptions on exit) and exit cleanly (otherwise it would continue running other tests which is not what we want). - [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] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [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)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has 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) --------- Co-authored-by: Brett Langdon <brett.langdon@datadoghq.com> Co-authored-by: Federico Mon <federico.mon@datadoghq.com> Co-authored-by: Emmett Butler <723615+emmettbutler@users.noreply.github.com> (cherry picked from commit fffab01)
…thout any spans [backport 2.8] (#9574) Backport fffab01 from #9349 to 2.8. Adds a guard against `on_span_finish()` with partial flushing on running into an `IndexError` because there are no spans to flush (which may happen if `tracer.configure()` was called between the time a span was created and the time it was finished). In practice, this turns into: ``` >>> import ddtrace >>> with ddtrace.tracer.trace("regression"): ... ddtrace.tracer.configure(partial_flush_min_spans=1) ... Partial flush triggered but no spans to flush (was tracer reconfigured?) ``` This also refactors the test for our `os.fork()` wrapper to have the child process unpatch `coverage` (just in case, since it occasionally causes exceptions on exit) and exit cleanly (otherwise it would continue running other tests which is not what we want). ## 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] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [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)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has 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) Co-authored-by: Romain Komorn <136473744+romainkomorndatadog@users.noreply.github.com> Co-authored-by: Federico Mon <federico.mon@datadoghq.com>
…thout any spans [backport 2.10] (#9576) Backport fffab01 from #9349 to 2.10. Adds a guard against `on_span_finish()` with partial flushing on running into an `IndexError` because there are no spans to flush (which may happen if `tracer.configure()` was called between the time a span was created and the time it was finished). In practice, this turns into: ``` >>> import ddtrace >>> with ddtrace.tracer.trace("regression"): ... ddtrace.tracer.configure(partial_flush_min_spans=1) ... Partial flush triggered but no spans to flush (was tracer reconfigured?) ``` This also refactors the test for our `os.fork()` wrapper to have the child process unpatch `coverage` (just in case, since it occasionally causes exceptions on exit) and exit cleanly (otherwise it would continue running other tests which is not what we want). ## 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] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [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)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has 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) Co-authored-by: Romain Komorn <136473744+romainkomorndatadog@users.noreply.github.com>
Adds a guard against
on_span_finish()
with partial flushing on running into anIndexError
because there are no spans to flush (which may happen iftracer.configure()
was called between the time a span was created and the time it was finished).In practice, this turns into:
This also refactors the test for our
os.fork()
wrapper to have the child process unpatchcoverage
(just in case, since it occasionally causes exceptions on exit) and exit cleanly (otherwise it would continue running other tests which is not what we want).Checklist
changelog/no-changelog
is set@DataDog/apm-tees
.Reviewer Checklist