Skip to content

Commit

Permalink
chore: skip non-user frames in exception replay (#9015)
Browse files Browse the repository at this point in the history
We skip non-user frames when collecting snapshots as part of the
exception replay feature.

## 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

- [ ] Title is accurate
- [ ] All changes are related to the pull request's stated goal
- [ ] Description motivates each change
- [ ] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- [ ] Testing strategy adequately addresses listed risks
- [ ] Change is maintainable (easy to change, telemetry, documentation)
- [ ] Release note makes sense to a user of the library
- [ ] Author has acknowledged and discussed the performance implications
of this PR as reported in the benchmarks PR comment
- [ ] 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)
  • Loading branch information
P403n1x87 authored May 9, 2024
1 parent 0346f71 commit 7e5d79b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ddtrace/debugging/_exception/auto_instrument.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections import deque
from itertools import count
from pathlib import Path
import sys
from threading import current_thread
from types import FrameType
Expand All @@ -16,6 +17,7 @@
from ddtrace.debugging._signal.collector import SignalCollector
from ddtrace.debugging._signal.snapshot import DEFAULT_CAPTURE_LIMITS
from ddtrace.debugging._signal.snapshot import Snapshot
from ddtrace.internal.packages import is_user_code
from ddtrace.internal.rate_limiter import BudgetRateLimiterWithJitter as RateLimiter
from ddtrace.internal.rate_limiter import RateLimitExceeded

Expand Down Expand Up @@ -176,8 +178,8 @@ def on_span_finish(self, span: Span) -> None:
code = frame.f_code
seq_nr = next(seq)

# TODO: Check if it is user code; if not, skip. We still
# generate a sequence number.
if not is_user_code(Path(frame.f_code.co_filename)):
continue

snapshot_id = frame.f_locals.get(SNAPSHOT_KEY, None)
if snapshot_id is None:
Expand Down

0 comments on commit 7e5d79b

Please sign in to comment.