@google-cloud/debug-agent

中文文档
9.0.1发布于 2024/02/02Apache-2.0TypeScriptCommonJS近 30 天下载 5.9万

Stackdriver Debug Agent for Node.js

原始使用文档
文档目录13 节
  1. Project Status: Archived
  2. Quickstart
  3. Before you begin
  4. Installing the client library
  5. Debugger Agent Settings
  6. Using the Debugger
  7. Historical note
  8. Limitations and Requirements
  9. Samples
  10. Supported Node.js Versions
  11. Versioning
  12. Contributing
  13. License

Google Cloud Platform logo

Cloud Debugger: Node.js Client

release level npm version

This module provides Snapshot Debugger support for Node.js applications. Snapshot Debugger is an open source product that lets you debug your applications in production without stopping or pausing your application.

A Firebase Realtime Database instance is used to store your data.

Project Status: Archived

This project has been archived and is no longer supported. There will be no further bug fixes or security patches. The repository can be forked by users if they want to maintain it going forward.

A comprehensive list of changes in each version may be found in the CHANGELOG.

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable the Cloud Debugger API.
  3. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/debug-agent

Debugger Agent Settings

To customize the behaviour of the automatic debugger agent, specify options when starting the agent. The following code sample shows how to pass in a subset of the available options.

require('@google-cloud/debug-agent').start({
  // .. auth settings ..

  // debug agent settings:
  allowExpressions: true,
  serviceContext: {
    service: 'my-service',
    version: 'version-1'
  },
  capture: { maxFrames: 20, maxProperties: 100 }
});

The following options configure the connection to the Firebase database:

  • firebaseDbUrl - https://PROJECT_ID-cdbg.firebaseio.com will be used if not provided. where PROJECT_ID is your project ID.
  • firebaseKeyPath - Default google application credentials are used if not provided.

Some key configuration options are:

  • allowExpressions - Whether or not it is permitted to evaluate epressions. Functionality is limited when this is not set, but there is some risk that malicious expressions can mutate program state.
  • serviceContext - This information is utilized in the UI to identify all the running instances of your service. Set this if you do not like the default values.
  • capture - Configuration options on what is captured on a snapshot. Set this if the default snapshot captures are too limited. Note that relaxing constraints may cause performance impact.

See the agent configuration for a list of possible configuration options.

Using the Debugger

Once your application is running, use the Snapshot Debugger CLI or the VSCode extension to debug your application.

Historical note

Version 6.x and 7.x of this agent supported both the now shutdown Cloud Debugger service (by default) and the Snapshot Debugger (Firebase RTDB backend) by setting the useFirebase flag to true. Version 8.0.0 removed support for the Cloud Debugger service, making the Snapshot Debugger the default. To note the useFirebase flag is now obsolete, but still present for backward compatibility.

Limitations and Requirements

Note: There is a known issue where enabling the agent may trigger memory leaks. See #811

  • Privacy issues can be created by setting snapshot conditions that watch expressions evaluated in the context of your application. You may be able to view sensitive user data when viewing the values of variables.
  • The debug agent tries to ensure that all conditions and watchpoints you add are read-only and have no side effects. It catches, and disallows, all expressions that may have static side effects to prevent accidental state change. However, it presently does not catch expressions that have dynamic side-effects. For example, o.f looks like a property access, but dynamically, it may end up calling a getter function. We presently do NOT detect such dynamic-side effects.
  • The root directory of your application needs to contain a package.json file.

Samples

Samples are in the samples/ directory. Each sample's README.md has instructions for running its sample.

SampleSource CodeTry it
Appsource codeOpen in Cloud Shell
Snippetssource codeOpen in Cloud Shell

The Cloud Debugger Node.js Client API Reference documentation also contains samples.

Supported Node.js Versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js. If you are using an end-of-life version of Node.js, we recommend that you update as soon as possible to an actively supported LTS version.

Google's client libraries support legacy versions of Node.js runtimes on a best-efforts basis with the following warnings:

  • Legacy versions are not tested in continuous integration.
  • Some security patches and features cannot be backported.
  • Dependencies cannot be kept up-to-date.

Client libraries targeting some end-of-life versions of Node.js are available, and can be installed through npm dist-tags. The dist-tags follow the naming convention legacy-(version). For example, npm install @google-cloud/debug-agent@legacy-8 installs client libraries for versions compatible with Node.js 8.

Versioning

This library follows Semantic Versioning.

This library is considered to be stable. The code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against stable libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

Please note that this README.md, the samples/README.md, and a variety of configuration files in this repository (including .nycrc and tsconfig.json) are generated from a central template. To edit one of these files, make an edit to its templates in directory.

License

Apache Version 2.0

See LICENSE

版本与发布记录

@google-cloud/debug-agent 共发布 57 个版本,首次发布于 2017/02/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
9.0.1latest2024/02/022 年前
9.0.02024/01/022 年前
8.0.02023/06/073 年前
7.2.22023/01/173 年前
7.2.12022/12/153 年前
7.2.02022/12/103 年前

其他发布通道:legacy-8 → 4.2.2,legacy-10 → 6.0.1。

关于 @google-cloud/debug-agent 的常见问题

@google-cloud/debug-agent 是什么?

Stackdriver Debug Agent for Node.js

如何安装 @google-cloud/debug-agent?

在项目目录运行 npm install @google-cloud/debug-agent,或使用 pnpm add / yarn add / bun add。

@google-cloud/debug-agent 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@google-cloud/debug-agent 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@google-cloud/debug-agent 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=14.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@google-cloud/debug-agent 可以商用吗?

@google-cloud/debug-agent 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@google-cloud/debug-agent 的下载量有多少?

根据 npm 官方下载统计,@google-cloud/debug-agent 在 2026/10/17 – 2026/11/15 这 30 天内被下载 59,090 次,日均约 1,970 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@google-cloud/debug-agent 还在维护吗?

最新版本 9.0.1 发布于 2024/02/02(2 年前);至今共发布 57 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/02/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。