示例#1
0
def stacktrace(stacktrace, context, **meta):
    assert context["variant"] is None

    if context["hierarchical_grouping"]:
        rv = call_with_variants(
            _single_stacktrace_variant,
            # when app hash is equal to system hash, we do not want to stop it
            # from contributing as it will become a hierarchical hash when
            # renamed to app-depth-max. Therefore we must not make system a
            # mandatory variant ('system' instead of '!system')
            ["system", "app"],
            stacktrace,
            context=context,
            meta=meta,
        )

        full_stacktrace = rv.pop("app")
        rv["app-depth-max"] = full_stacktrace

        for max_frames in range(1, 6):
            stacktrace = full_stacktrace.shallow_copy()
            new_values = []
            ignored_frames = 0

            # cannot update contributes here as this copy is shallow.
            # instead, trim down list
            for component in reversed(stacktrace.values):
                if not component.contributes:
                    continue

                if len(new_values) < max_frames:
                    new_values.append(component)
                else:
                    ignored_frames += 1

            if not new_values or not ignored_frames:
                break

            new_values.reverse()
            stacktrace.update(values=new_values)

            rv[f"app-depth-{max_frames}"] = stacktrace

    else:
        rv = call_with_variants(_single_stacktrace_variant, ["!system", "app"],
                                stacktrace,
                                context=context,
                                meta=meta)

    return rv
示例#2
0
def stacktrace(stacktrace, context, **meta):
    assert context["variant"] is None

    if context["hierarchical_grouping"]:
        with context:
            context["variant"] = "system"
            return _single_stacktrace_variant(stacktrace, context=context, meta=meta)

    else:
        return call_with_variants(
            _single_stacktrace_variant, ["!system", "app"], stacktrace, context=context, meta=meta
        )
示例#3
0
def stacktrace(interface: Stacktrace, event: Event, context: GroupingContext,
               **meta: Any) -> ReturnedVariants:
    assert context["variant"] is None

    if context["hierarchical_grouping"]:
        with context:
            context["variant"] = "system"
            return _single_stacktrace_variant(interface,
                                              event=event,
                                              context=context,
                                              meta=meta)

    else:
        return call_with_variants(
            _single_stacktrace_variant,
            ["!system", "app"],
            interface,
            event=event,
            context=context,
            meta=meta,
        )