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

otel-console-tracer

v0.0.1

Published

OpenTelemetry Method Trace

Downloads

3

Readme

OpenTelemetry JavaScript/Node Console Tracer

Build Status NPM Version License

NPM package which injects current/active OpenTelemetry trace id and span id along with log level into the logs printed over console logging methods (trace, debug, info, log, warn, error).

  • If the there is no active span in the current context, only log level is injected into the logs.
  • If the level of the console logging method is equal or bigger than configured level, the log is printed, Otherwise, it is ignored.

You can find the supported log levels and their orders in the following table: | Log Level Name | Log Level | | -------------- | ---------- | | NONE | 0 | | TRACE | 1 | | DEBUG | 2 | | INFO | 3 | | LOG | 3 | | WARN | 4 | | ERROR | 5 |

Note: The default log level is NONE and which means that all the logs are printed by default if you don't configure any log level threshold.

Installation

To install the package, you can use NPM (or Yarn):

npm install --save otel-console-tracer

Note: Requires @opentelemetry/api version 1.0.0+

Usage

  • Initialize otel-console-tracer during bootstrap for Node.js app

    • During Bootstrap You can trigger initialization automatically by setting NODE_OPTIONS environment variable to otel-console-tracer bootstrapper (otel-console-tracer/dist/bootstrap) to initialize at startup:

        NODE_OPTIONS="--require otel-console-tracer/dist/bootstrap"
        node app.js

      or by adding the --require option into the Node.js command line options :

      node --require otel-console-tracer/dist/bootstrap app.js
    • In Code In addition to automated initialization without code change described above, you can also initialize otel-console-tracer in your code:

      const { init } = require('otel-console-tracer');
      // or use the following for ES modules
      // import { init } from 'otel-console-tracer';
          
      init();

      This kind of initialization might be useful in cases where configuring bootstrap is not possible (for ex. if you don't have access to the startup script of the Node.js app, so you cannot configure bootstrap options).

  • Optionally, you can configure log level threshold (the default log level is NONE):

    • By environment variable: Set OTEL_CONSOLE_TRACER_LOG_LEVEL environment variable to any supported log level.
      OTEL_CONSOLE_TRACER_LOG_LEVEL=INFO

Examples

You can find examples under examples directory. To be able to run the example, you can run the following command:

npm run example

Roadmap

  • Print traced logs in JSON format
  • Custom log format

Issues and Feedback

Issues Closed issues

Please use GitHub Issues for any bug report, feature request and support.

Contribution

Pull requests Closed pull requests Contributors

If you would like to contribute, please

  • Fork the repository on GitHub and clone your fork.
  • Create a branch for your changes and make your changes on it.
  • Send a pull request by explaining clearly what is your contribution.

Tip: Please check the existing pull requests for similar contributions and consider submit an issue to discuss the proposed feature before writing code.

License

Licensed under MIT License.