@dotcom-reliability-kit/app-info

中文文档
5.0.1发布于 2026/07/14MITTypeScriptES Module零依赖近 30 天下载 1.3万

A utility to get application info in a consistent way.

原始使用文档
文档目录16 节
  1. Usage
  2. appInfo.commitHash
  3. appInfo.environment
  4. appInfo.region
  5. appInfo.releaseDate
  6. appInfo.releaseVersion
  7. appInfo.systemCode
  8. appInfo.processType
  9. appInfo.cloudProvider
  10. appInfo.herokuAppId
  11. appInfo.herokuDynoId
  12. appInfo.instanceId
  13. appInfo.semanticConventions
  14. Migrating
  15. Contributing
  16. License

@dotcom-reliability-kit/app-info

A utility to get application information (e.g. the system code) in a consistent way. This module is part of FT.com Reliability Kit.

Usage

Install @dotcom-reliability-kit/app-info as a dependency:

npm install --save @dotcom-reliability-kit/app-info

Include in your code:

import appInfo from '@dotcom-reliability-kit/app-info';

[!TIP] If you're using this package with TypeScript, we recommend using the following settings in your tsconfig.json file to avoid type errors:

{
    "esModuleInterop": true,
    "module": "nodenext",
    "moduleResolution": "nodenext"
}

The appInfo object has several properties which can be used to access application information.

appInfo.commitHash

Get the commit hash that the application last deployed. This will be a string (if process.env.HEROKU_SLUG_COMMIT, process.env.GIT_COMMIT_LONG, or process.env.GIT_COMMIT is defined) or null otherwise.

For Heroku, this relies on the Dyno Metadata labs feature and will not be present in local development.

For AWS Lambda, you can use a plugin like serverless-plugin-git-variables to provide this data or set the GIT_COMMIT environment variable during deployment.

appInfo.environment

Get the application environment, normally either development or production. This will be a string, trying each of the following environment variables in order and defaulting to development:

  • DEPLOYMENT_ENVIRONMENT
  • RELEASE_ENV
  • ENVIRONMENT
  • NODE_ENV

appInfo.region

Get the region that the application is running in. This will be a string (if process.env.REGION or process.env.AWS_REGION is defined) or null otherwise.

appInfo.releaseDate

Get the application Heroku release date. This will be a string (if process.env.HEROKU_RELEASE_CREATED_AT is defined) or null otherwise.

For Heroku, this relies on the Dyno Metadata labs feature and will not be present in local development.

appInfo.releaseVersion

Get the application Heroku release version. This will be a string (if process.env.HEROKU_RELEASE_VERSION or process.env.AWS_LAMBDA_FUNCTION_VERSION is defined) or null otherwise.

For Heroku, this relies on the Dyno Metadata labs feature and will not be present in local development.

appInfo.systemCode

Get the application's Biz Ops system code. This will be a string (if process.env.SYSTEM_CODE is defined), if not then it will be read from the name property of $CWD/package.json, if neither of these exist then it will be set to null.

If the system code is read from the application's package.json file then it will be stripped of any "ft-" prefix – this is a legacy name and our app system codes do not begin with it.

appInfo.processType

Get the type of the running process, which is the name for the current process within an application.

For AWS Lambda, this is the name of the function, read from process.env.AWS_LAMBDA_FUNCTION_NAME.

For Heroku, this is derived from the first part of process.env.DYNO, which is set to by Heroku, e.g. a dyno called web.1 will have processType set to web. The process types in an application are defined by the application's Procfile.

If neither process.env.AWS_LAMBDA_FUNCTION_NAME or process.env.DYNO are set, this property will be null

appInfo.cloudProvider

Get the type of cloud provider which is set to either Heroku or AWS depending on where we think the system is hosted.

This is derived from some environment variables which we have high confidence are defined by only Heroku or AWS/Lambda

appInfo.herokuAppId

Get the process.env.HEROKU_APP_ID which is the unique identifier for the application.e.g "9daa2797-e49b-4624-932f-ec3f9688e3da"

This is derived from the dyno metadata

appInfo.herokuDynoId

Get the process.env.HEROKU_DYNO_ID which is the dyno identifier

This is derived from the dyno metadata

appInfo.instanceId

Get the unique identifier for the instance that's running the application. This will be a different UUID for each running process, including cluster workers.

appInfo.semanticConventions

This object contains aliases for the main appInfo properties that correspond to OpenTelemetry's Semantic Conventions. We use the following mapping:

  • appInfo.semanticConventions.cloud.provider aliases appInfo.cloudProvider
  • appInfo.semanticConventions.cloud.region aliases appInfo.region
  • appInfo.semanticConventions.deployment.environment aliases appInfo.environment
  • appInfo.semanticConventions.service.name aliases appInfo.systemCode
  • appInfo.semanticConventions.service.version aliases appInfo.releaseVersion
  • appInfo.semanticConventions.service.instance.id aliases appInfo.instanceId

[!WARNING] While all other properties default to null if they can't be calculated, the semantic conventions properties default to undefined. This is to ensure better compatibility with OpenTelemetry SDKs.

Migrating

Consult the Migration Guide if you're trying to migrate to a later major version of this package.

Contributing

See the central contributing guide for Reliability Kit.

License

Licensed under the MIT license.
Copyright © 2022, The Financial Times Ltd.

版本与发布记录

@dotcom-reliability-kit/app-info 共发布 26 个版本,首次发布于 2022/08/23;过去 12 个月发布了 3 个版本。

版本发布日期距今
5.0.1latest2026/07/144 个月前
5.0.02026/06/234 个月前
5.0.0-beta.1prerelease2026/06/035 个月前
4.2.12025/10/141.1 年前
4.2.02025/05/081.5 年前
4.1.02025/03/261.6 年前

关于 @dotcom-reliability-kit/app-info 的常见问题

@dotcom-reliability-kit/app-info 是什么?

A utility to get application info in a consistent way.

如何安装 @dotcom-reliability-kit/app-info?

在项目目录运行 npm install @dotcom-reliability-kit/app-info,或使用 pnpm add / yarn add / bun add。

@dotcom-reliability-kit/app-info 支持 TypeScript 吗?

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

@dotcom-reliability-kit/app-info 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dotcom-reliability-kit/app-info 需要什么版本的 Node.js?

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

@dotcom-reliability-kit/app-info 可以商用吗?

@dotcom-reliability-kit/app-info 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dotcom-reliability-kit/app-info 的下载量有多少?

根据 npm 官方下载统计,@dotcom-reliability-kit/app-info 在 2026/10/13 – 2026/11/11 这 30 天内被下载 13,261 次,日均约 442 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dotcom-reliability-kit/app-info 还在维护吗?

最新版本 5.0.1 发布于 2026/07/14(4 个月前);至今共发布 26 个版本,其中过去 12 个月发布了 3 个;首次发布于 2022/08/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。