MCPcopy Create free account
hub / github.com/getsentry/sentry / find_stack_frames

Function find_stack_frames

src/sentry/utils/event_frames.py:201–239  ·  view source on GitHub ↗

See: https://develop.sentry.dev/sdk/event-payloads/#core-interfaces for event data payload format. Waterfall logic for searching for stack frames in an event: - `exception` interface for any 'stacktrace' frames. - 'stacktrace' interface - 'threads' interface for the relevant 'c

(
    event_data: PathSearchable, consume_frame: Callable[[Any], None] = lambda _: None
)

Source from the content-addressed store, hash-verified

199
200
201def find_stack_frames(
202 event_data: PathSearchable, consume_frame: Callable[[Any], None] = lambda _: None
203) -> Sequence[Mapping[str, Any]]:
204 """
205 See: https://develop.sentry.dev/sdk/event-payloads/#core-interfaces for event data payload format.
206
207 Waterfall logic for searching for stack frames in an event:
208 - `exception` interface for any 'stacktrace' frames.
209 - 'stacktrace' interface
210 - 'threads' interface for the relevant 'crashing' thread stack frames
211 """
212
213 frames = []
214 stacktrace_in_exception = False
215 for exc in get_path(event_data, "exception", "values", filter=True) or ():
216 for frame in get_path(exc, "stacktrace", "frames", filter=True) or ():
217 consume_frame(frame)
218 frames.append(frame)
219 stacktrace_in_exception = True
220
221 if not stacktrace_in_exception:
222 # according to: https://develop.sentry.dev/sdk/event-payloads/stacktrace/
223 # stacktrace interface shouldn't be a top-level event property, so the next statement could be useless
224 # potentially here for backwards compatibility
225 frames = get_path(event_data, "stacktrace", "frames", filter=True) or []
226 if not frames:
227 threads = get_path(event_data, "threads", "values", filter=True) or get_path(
228 event_data, "threads", filter=True
229 )
230 # Handles edge case where the second call to get_path doesn't return a list of threads
231 if threads == {"values": None}:
232 threads = None
233 thread = get_crashing_thread(threads)
234 if thread is not None:
235 frames = get_path(thread, "stacktrace", "frames", filter=True) or []
236 for frame in frames or ():
237 consume_frame(frame)
238
239 return frames

Calls 3

get_pathFunction · 0.90
get_crashing_threadFunction · 0.85
appendMethod · 0.65