npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dotcom-reliability-kit/app-info

v3.3.0

Published

A utility to get application info in a consistent way.

Downloads

40,810

Readme

@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';
// or
const appInfo = require('@dotcom-reliability-kit/app-info');

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.