Hi,
I’m working on a sentry sdk for C++. Sentry is too eagerly grouping the events that I generate - at least more eagerly than I expect, as sentry groups events with different stacktraces. I don’t have a stacktrace element directly in the event, only as part of the threads interface element. I’ve marked the crashing thread with “crashed”: true, so it seems reasonable that sentry should pick it up from there and use it for grouping.
According to the grouping-by-stacktrace documentation “When Sentry detects a stacktrace in the event data (either directly or as part of an exception) the grouping effectively is based entirely on the stacktrace.“ If this documentation is accurate it explains the behaviour I’m seeing, since my stacktrace elements are parts of thread elements.
My question is whether the documentation is accurate, and if it is, why doesn’t sentry use the stacktrace of the thread that is marked as crashed, if it is there?
Thanks,
Thomas
I’ve looked at the sentry code and can answer the question half-way. The threads interface only participates in grouping if it contains a single thread. This is the code in threads.py:
def get_hash(self, is_processed_data=True):
if len(self.values) != 1:
return []
stacktrace = self.values[0].get('stacktrace')
if not stacktrace:
return []
system_hash = stacktrace.get_hash(system_frames=True, is_processed_data=is_processed_data)
if not system_hash:
return []
app_hash = stacktrace.get_hash(system_frames=False, is_processed_data=is_processed_data)
if system_hash == app_hash or not app_hash:
return [system_hash]
return [system_hash, app_hash]
I still think it should also participate in grouping if one of the threads is marked as crashed. So, instead it would do:
def get_hash(self, is_processed_data=True):
stacktrace = None
if len(self.values) == 1:
stacktrace = self.values[0].get('stacktrace')
else:
crashed_threads = [x for x in self.values if x.get('crashed') == True]
if len(crashed_threads) == 1:
stacktrace = crashed_threads[0].get('stacktrace')
if not stacktrace:
return []
system_hash = stacktrace.get_hash(system_frames=True, is_processed_data=is_processed_data)
if not system_hash:
return []
app_hash = stacktrace.get_hash(system_frames=False, is_processed_data=is_processed_data)
if system_hash == app_hash or not app_hash:
return [system_hash]
return [system_hash, app_hash]
I just wrote the change above directly in this editor, so it may not be valid python, but it should convey the idea.
Thomas
I’ve filed issue #6398 about this.