Skip to content

bedrockio/instrumentation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@bedrockio/instrumentation

This providers tools to instrumentate your api

For exporting both logging and tracing: The package assumes you are running in a Google Cloud environment (production). Locally its using https://zipkin.io/. If a server is available.

Install

npm install @bedrockio/instrumentation

Usage

Important This should be initalized before any other code is executed / required or it will not work correctly.

const { setupTelemetry } = require("@bedrockio/instrumentation");
if (process.env.NODE_ENV === "production") {
  setupTelemetry();
}
// other code

Development vs Production

When process.env.NODE_ENV != production some features are turned off or swapped out with development friendly solutions:

  • Tracing/Instrumention is turned off (makes boot time faster)
  • Simple output rendering using console
  • Allows silencing output with log levels.

Log Levels

Setting process.env.LOG_LEVEL will set the log level which silences lower level output. The levels are:

  • trace
  • debug
  • info
  • warn
  • error
  • fatal

Methods

setupTelemetry

setup the instrumentations (tracing).

getTracer

Returns a tracer from the global tracer provider

createLogger

createLogger(props): Logger

loggingMiddleware

Http logging middleware

Properties

logger

logger.info("Hello", { "foo": "bar" })

The default logger

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published