跳转到主要内容

用于处理崩溃统计的工具(https://crash-stats.mozilla.org/)

项目描述

与崩溃统计(https://crash-stats.mozilla.org/)交互的命令行工具和库。

代码::

https://github.com/willkg/crashstats-tools

文档::

查看 README.rst 文件

变更日志::

查看 HISTORY.rst 文件

问题跟踪器::

https://github.com/willkg/crashstats-tools/issues

许可证::

MPLv2

聊天::

#crashreporting matrix channel

社区参与指南::

https://github.com/willkg/crashstats-tools/blob/main/CODE_OF_CONDUCT.md

安装

crashstats-tools可在PyPI上使用。您可以使用pipx安装它

$ pipx install crashstats-tools

要开发crashstats-tools,请克隆Git仓库,创建虚拟环境,然后使用以下命令安装crashstats-tools和dev依赖项

$ pip install -e '.[dev]'

支持

这是一个我投入了一些时间的项目,因为它对我来说和其他人都有帮助。我经常用它来进行崩溃统计调查和重新处理。然而,我不是你!如果你有任何问题,请将问题记录在问题跟踪器中,我会在能够的时候处理它。

如果你使用它,喜欢它,感激它,或者有任何积极的感受,请给它一个GitHub星标。这对我很有帮助

  1. 有一个代理来知道它是否被使用

  2. 优先考虑我在这项项目上的工作时间

  3. 有一个用户列表,以防我需要提问并寻求建议

工具

超级搜索

Usage: supersearch [OPTIONS]

  Performs a basic search on Crash Stats using the Super Search API and outputs
  the results.

  A basic search uses filters and can span multiple pages of results. A basic
  search cannot include facets, aggregations, histograms, or cardinalities. For
  those, use supersearchfacet.

  There are two ways to run this:

  First, you can specify Super Search API fields to generate the query.

  For example:

  $ supersearch --product=Firefox --num=10

  Second, you can pass in a url from a Super Search on Crash Stats. This command
  will then pull out the filter parameters. You can override those parameters
  with command line arguments.

  $ supersearch --supersearch-url='https://crash-stats.mozilla.org/search/...'

  Make sure to use single quotes when specifying values so that your shell
  doesn't expand variables or parse escape sequences.

  You can specify returned fields using the Super Search field "_columns".

  For example:

  $ supersearch --_columns=uuid --_columns=product --_columns=build_id

  Results are tab-delimited by default. You can specify other output formats
  using "--format". Tabs and newlines in output are escaped.

  For list of available fields and Super Search API documentation, see:

  https://crash-stats.mozilla.org/documentation/supersearch/

  https://crash-stats.mozilla.org/documentation/supersearch/api/

  This requires an API token in order to search and get results for protected
  data fields. Using an API token also reduces rate-limiting. Set the
  CRASHSTATS_API_TOKEN environment variable to your API token value:

  CRASHSTATS_API_TOKEN=xyz supersearch ...

  To create an API token for Crash Stats, visit:

  https://crash-stats.mozilla.org/api/tokens/

  Remember to abide by the data access policy when using data from Crash Stats!
  The policy is specified here:

  https://crash-stats.mozilla.org/documentation/protected_data_access/

Options:
  --host TEXT                     host for system to fetch crashids from
                                  [default: https://crash-stats.mozilla.org]
  --supersearch-url TEXT          Super Search url to base query on
  --num TEXT                      number of crash ids you want or "all" for all
                                  of them  [default: 100]
  --headers / --no-headers        whether or not to show table headers
                                  [default: no-headers]
  --format [table|tab|csv|json|markdown]
                                  format to print output  [default: tab]
  --verbose / --no-verbose        whether to print debugging output  [default:
                                  no-verbose]
  --color / --no-color            whether or not to colorize output; note that
                                  color is shut off when stdout is not an
                                  interactive terminal automatically  [default:
                                  color]
  --help                          Show this message and exit.

获取Firefox的10个崩溃ID

$ supersearch --num=10 --product=Firefox

获取所有在modules_in_stack字段中包含libc2.30.so/E22A1E7AEF7C58504AF2C60A5AD3A7AE0的所有崩溃报告

$ supersearch --modules_in_stack=libc2.30.so/E22A1E7AEF6C58504AF2C60A5AD3A7AE0

当你需要在上传我们没有符号的模块的符号后重新处理崩溃报告时,这很有帮助。

获取所有在modules_in_stack字段中包含libgallium_dri.so的所有崩溃报告

$ supersearch --modules_in_stack='^libgallium_dri.so'

获取与超级搜索查询匹配的57个崩溃ID

$ supersearch --num=57 \
    --supersearch-url='https://crash-stats.mozilla.org/search/?release_channel=nightly&version=70.0a1&product=Firefox&_sort=-date'

使用单引号值,这样你的shell就不会进行任何shell扩展。

获取签名中包含“OOM”的崩溃报告的uuid、产品、版本和build_id

$ supersearch --_columns=uuid --_columns=product --_columns=version \
    --_columns=build_id --signature='~OOM'

请注意,这不支持超级搜索聚合——使用supersearchfacet命令来实现。

有关符号和字段的详细信息,请参阅超级搜索API文档

supersearchfacet

Usage: supersearch [OPTIONS]

  Performs a basic search on Crash Stats using the Super Search API and outputs
  the results.

  A basic search uses filters and can span multiple pages of results. A basic
  search cannot include facets, aggregations, histograms, or cardinalities. For
  those, use supersearchfacet.

  There are two ways to run this:

  First, you can specify Super Search API fields to generate the query.

  For example:

  $ supersearch --product=Firefox --num=10

  Second, you can pass in a url from a Super Search on Crash Stats. This command
  will then pull out the filter parameters. You can override those parameters
  with command line arguments.

  $ supersearch --supersearch-url='https://crash-stats.mozilla.org/search/...'

  Make sure to use single quotes when specifying values so that your shell
  doesn't expand variables or parse escape sequences.

  You can specify returned fields using the Super Search field "_columns".

  For example:

  $ supersearch --_columns=uuid --_columns=product --_columns=build_id

  Results are tab-delimited by default. You can specify other output formats
  using "--format". Tabs and newlines in output are escaped.

  For list of available fields and Super Search API documentation, see:

  https://crash-stats.mozilla.org/documentation/supersearch/

  https://crash-stats.mozilla.org/documentation/supersearch/api/

  This requires an API token in order to search and get results for protected
  data fields. Using an API token also reduces rate-limiting. Set the
  CRASHSTATS_API_TOKEN environment variable to your API token value:

  CRASHSTATS_API_TOKEN=xyz supersearch ...

  To create an API token for Crash Stats, visit:

  https://crash-stats.mozilla.org/api/tokens/

  Remember to abide by the data access policy when using data from Crash Stats!
  The policy is specified here:

  https://crash-stats.mozilla.org/documentation/protected_data_access/

Options:
  --host TEXT                     host for system to fetch crashids from
                                  [default: https://crash-stats.mozilla.org]
  --supersearch-url TEXT          Super Search url to base query on
  --num TEXT                      number of crash ids you want or "all" for all
                                  of them  [default: 100]
  --headers / --no-headers        whether or not to show table headers
                                  [default: no-headers]
  --format [table|tab|csv|json|markdown]
                                  format to print output  [default: tab]
  --verbose / --no-verbose        whether to print debugging output  [default:
                                  no-verbose]
  --color / --no-color            whether or not to colorize output; note that
                                  color is shut off when stdout is not an
                                  interactive terminal automatically  [default:
                                  color]
  --help                          Show this message and exit.

查看过去7天内按产品划分的崩溃报告细分

$ supersearchfacet --_facets=product

查看过去7天内按产品和日期划分的崩溃报告细分

$ supersearchfacet --_histogram.date=product --relative=range=7d

可以使用超级搜索过滤器对直方图、方面、聚合和基数进行过滤。查看过去7天内按发布渠道划分的Firefox崩溃报告

$ supersearchfacet \
    --_histogram.date=release_channel \
    --release_channel=nightly \
    --release_channel=beta \
    --release_channel=release \
    --release_channel=esr \
    --product=Firefox \
    --relative-range=7d

获取Markdown表格,以便轻松剪切和粘贴到Markdown中

$ supersearchfacet --_histogram.date=product --relative=range=7d \
    --format=markdown

有关符号和字段的详细信息,请参阅超级搜索API文档

fetch-data

Usage: supersearch [OPTIONS]

  Performs a basic search on Crash Stats using the Super Search API and outputs
  the results.

  A basic search uses filters and can span multiple pages of results. A basic
  search cannot include facets, aggregations, histograms, or cardinalities. For
  those, use supersearchfacet.

  There are two ways to run this:

  First, you can specify Super Search API fields to generate the query.

  For example:

  $ supersearch --product=Firefox --num=10

  Second, you can pass in a url from a Super Search on Crash Stats. This command
  will then pull out the filter parameters. You can override those parameters
  with command line arguments.

  $ supersearch --supersearch-url='https://crash-stats.mozilla.org/search/...'

  Make sure to use single quotes when specifying values so that your shell
  doesn't expand variables or parse escape sequences.

  You can specify returned fields using the Super Search field "_columns".

  For example:

  $ supersearch --_columns=uuid --_columns=product --_columns=build_id

  Results are tab-delimited by default. You can specify other output formats
  using "--format". Tabs and newlines in output are escaped.

  For list of available fields and Super Search API documentation, see:

  https://crash-stats.mozilla.org/documentation/supersearch/

  https://crash-stats.mozilla.org/documentation/supersearch/api/

  This requires an API token in order to search and get results for protected
  data fields. Using an API token also reduces rate-limiting. Set the
  CRASHSTATS_API_TOKEN environment variable to your API token value:

  CRASHSTATS_API_TOKEN=xyz supersearch ...

  To create an API token for Crash Stats, visit:

  https://crash-stats.mozilla.org/api/tokens/

  Remember to abide by the data access policy when using data from Crash Stats!
  The policy is specified here:

  https://crash-stats.mozilla.org/documentation/protected_data_access/

Options:
  --host TEXT                     host for system to fetch crashids from
                                  [default: https://crash-stats.mozilla.org]
  --supersearch-url TEXT          Super Search url to base query on
  --num TEXT                      number of crash ids you want or "all" for all
                                  of them  [default: 100]
  --headers / --no-headers        whether or not to show table headers
                                  [default: no-headers]
  --format [table|tab|csv|json|markdown]
                                  format to print output  [default: tab]
  --verbose / --no-verbose        whether to print debugging output  [default:
                                  no-verbose]
  --color / --no-color            whether or not to colorize output; note that
                                  color is shut off when stdout is not an
                                  interactive terminal automatically  [default:
                                  color]
  --help                          Show this message and exit.

这让你可以从崩溃统计中下载原始崩溃、转储和处理后的崩溃。

获取特定崩溃ID的处理后的崩溃数据

$ fetch-data --no-raw --no-dumps --processed 723cacd6-1684-420e-a1c7-f04240190731

使用超级搜索命令生成崩溃ID来获取原始崩溃数据

$ supersearch --product=Firefox --num=10 | \
    fetch-data --raw --no-dumps --no-processed crashdir

reprocess

Usage: supersearch [OPTIONS]

  Performs a basic search on Crash Stats using the Super Search API and outputs
  the results.

  A basic search uses filters and can span multiple pages of results. A basic
  search cannot include facets, aggregations, histograms, or cardinalities. For
  those, use supersearchfacet.

  There are two ways to run this:

  First, you can specify Super Search API fields to generate the query.

  For example:

  $ supersearch --product=Firefox --num=10

  Second, you can pass in a url from a Super Search on Crash Stats. This command
  will then pull out the filter parameters. You can override those parameters
  with command line arguments.

  $ supersearch --supersearch-url='https://crash-stats.mozilla.org/search/...'

  Make sure to use single quotes when specifying values so that your shell
  doesn't expand variables or parse escape sequences.

  You can specify returned fields using the Super Search field "_columns".

  For example:

  $ supersearch --_columns=uuid --_columns=product --_columns=build_id

  Results are tab-delimited by default. You can specify other output formats
  using "--format". Tabs and newlines in output are escaped.

  For list of available fields and Super Search API documentation, see:

  https://crash-stats.mozilla.org/documentation/supersearch/

  https://crash-stats.mozilla.org/documentation/supersearch/api/

  This requires an API token in order to search and get results for protected
  data fields. Using an API token also reduces rate-limiting. Set the
  CRASHSTATS_API_TOKEN environment variable to your API token value:

  CRASHSTATS_API_TOKEN=xyz supersearch ...

  To create an API token for Crash Stats, visit:

  https://crash-stats.mozilla.org/api/tokens/

  Remember to abide by the data access policy when using data from Crash Stats!
  The policy is specified here:

  https://crash-stats.mozilla.org/documentation/protected_data_access/

Options:
  --host TEXT                     host for system to fetch crashids from
                                  [default: https://crash-stats.mozilla.org]
  --supersearch-url TEXT          Super Search url to base query on
  --num TEXT                      number of crash ids you want or "all" for all
                                  of them  [default: 100]
  --headers / --no-headers        whether or not to show table headers
                                  [default: no-headers]
  --format [table|tab|csv|json|markdown]
                                  format to print output  [default: tab]
  --verbose / --no-verbose        whether to print debugging output  [default:
                                  no-verbose]
  --color / --no-color            whether or not to colorize output; note that
                                  color is shut off when stdout is not an
                                  interactive terminal automatically  [default:
                                  color]
  --help                          Show this message and exit.

重新处理单个崩溃报告

$ reprocess 723cacd6-1684-420e-a1c7-f04240190731

根据超级搜索重新处理崩溃报告

$ supersearch --num=5 | reprocess

API令牌

对于supersearchfetch-data,你需要使用API令牌来

  • 下载包含个人身份信息的资料

  • 下载敏感数据

  • 避免因API使用率过高而受到限制的阴影

你需要API令牌来使用reprocess——没有它是无法工作的。

如果你有权访问,可以在此处生成API令牌

https://crash-stats.mozilla.org/api/tokens/

一旦你拥有了一个,请在使用crashstats-tools命令时设置CRASHSTATS_API_TOKEN环境变量。

记住在使用崩溃统计数据时遵守数据访问政策!政策在此指定

https://crash-stats.mozilla.org/documentation/memory_dump_access/

用例

这些工具在下载分析数据以及测试其他工具时都很有用。

示例1

我想收集一些崩溃报告数据,以便查看Firefox崩溃报告中某个注释的可能值,而这个注释目前在Super Search中不可用。

因为我只关注注释,所以我只需要原始的崩溃报告。

我会这样做

$ mkdir crashdata
$ supersearch --product=Firefox --num=1000 | \
    fetch-data --raw --no-dumps --no-processed crashdata

然后我可以使用 jq 或其他工具来查看 crashdata/raw_crash/ 中的崩溃报告数据。

示例 2

我想测试一个适用于minidump文件的新JIT分析工具。

我会编写一个像这样的脚本

#!/bin/bash

CRASHSTATS_API_TOKEN=foo
DATADIR=./crashdata
CRASHIDS=$(supersearch --product=Firefox --num=1000)

mkdir -p "${DATADIR}"

for crashid in ${CRASHIDS}
do
    echo "crashid ${crashid}"
    fetch-data --raw --dumps --no-processed "${DATADIR}" "${crashid}"

    # Not all crash reports have dumps--we only want to run analysis
    # on the ones that do.
    if [[ -e "crashdata/dump/${crashid}" ]]
    then
        echo "analyze dump ${crashid}..."
        # run my tool on the dump
    fi
done

示例 3

我想获取今天(2019-07-30)存在 DOMFissionEnabled 的崩溃报告的崩溃ID列表。

我会这样做

$ supersearch --date=">=2019-07-30" --date='<2019-07-31' \
    --dom_fission_enabled='!__null__'

示例 4

我想查看在过去14天内,存在 DOMFissionEnabled 的崩溃报告中,按日和按产品划分的崩溃报告数量。

我会这样做

$ supersearchfacet --period=daily --format=markdown --relative-range=14d \
    --dom_fission_enabled='!__null__' --_facets=product

此外,这为一些Crash Stats API端点提供了库接口

crashstats_tools.libcrashstats

get_crash_annotations(crash_id, api_token=None, host=DEFAULT_HOST)

获取给定崩溃报告的崩溃注释。

如果您不提供API令牌,则只会返回标记为公开的崩溃注释。

get_dump(crash_id, dump_name, api_token, host=DEFAULT_HOST)

获取给定崩溃ID的崩溃、内存报告和其他崩溃报告二进制文件。

这需要一个API令牌。

get_processed_crash(crash_id, api_token=None, host=DEFAULT_HOST)

获取给定崩溃ID的处理后的崩溃。

supersearch(params, num_results, host=DEFAULT_HOST, api_token=None, logger=None)

执行超级搜索并返回结果命中项的生成器。

这不会返回面、聚合、基数或直方图数据。如果您需要这些数据,请使用 supersearch_facet

supersearch_facet(params, api_token=None, host=DEFAULT_HOST, logger=None)

执行超级搜索并返回面数据

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源代码分布

crashstats_tools-2.tar.gz (34.0 kB 查看哈希值)

上传时间 源代码

构建分布

crashstats_tools-2.0.0-py3-none-any.whl (32.5 kB 查看哈希值)

上传时间 Python 3

支持