Auto instrumentations using open-telemetry
This providers tools to instrumentate your api
- Expose logger (wrapping https://getpino.io)
- Http logging middleware
- Providers tracing of your application via https://opentelemetry.io/
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.
``bash`
npm install @bedrockio/instrumentation
Important This should be initalized before any other code is executed / required or it will not work correctly.
`javascript`
const { setupTelemetry } = require("@bedrockio/instrumentation");
if (process.env.NODE_ENV === "production") {
setupTelemetry();
}
// other code
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.
Setting process.env.LOG_LEVEL will set the log level which silences lower level output. The levels are:
- trace
- debug
- info
- warn
- error
- fatal
#### setupTelemetry
setup the instrumentations (tracing).
#### getTracer
Returns a tracer from the global tracer provider
#### createLogger
``
createLogger(props): Logger
#### loggingMiddleware
Http logging middleware
#### logger
```
logger.info("Hello", { "foo": "bar" })
The default logger