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

@mzahor-test-org/opentelemetry-node-fork

v0.14.0

Published

OpenTelemetry Node SDK provides automatic telemetry (tracing, metrics, etc) for Node.js applications

Downloads

3

Readme

OpenTelemetry Node SDK

Gitter chat NPM Published Version dependencies devDependencies Apache License

This module provides automated instrumentation and tracing for Node.js applications.

For manual instrumentation see the @opentelemetry/tracing package.

How auto instrumentation works

This package exposes a NodeTracerProvider that will automatically hook into the module loader of Node.js.

For this to work, please make sure that NodeTracerProvider is initialized before any other module of your application, (like http or express) is loaded.

OpenTelemetry comes with a growing number of instrumentation plugins for well know modules (see supported modules) and an API to create custom plugins (see the plugin developer guide).

Whenever a module is loaded NodeTracerProvider will check if a matching instrumentation plugin has been installed.

Please note: This module does not bundle any plugins. They need to be installed separately.

If the respective plugin was found, it will be used to patch the original module to add instrumentation code. This is done by wrapping all tracing-relevant functions.

This instrumentation code will automatically

  • extract a trace-context identifier from inbound requests to allow distributed tracing (if applicable)
  • make sure that this current trace-context is propagated while the transaction traverses an application (see @opentelemetry/context-base for an in-depth explanation)
  • add this trace-context identifier to outbound requests to allow continuing the distributed trace on the next hop (if applicable)
  • create and end spans

In short, this means that this module will use provided plugins to automatically instrument your application to produce spans and provide end-to-end tracing by just adding a few lines of code.

Creating custom spans on top of auto-instrumentation

Additionally to automated instrumentation, NodeTracerProvider exposes the same API as @opentelemetry/tracing, allowing creating custom spans if needed.

Installation

npm install --save @opentelemetry/api
npm install --save @opentelemetry/node

# Install instrumentation plugins
npm install --save @opentelemetry/plugin-http
npm install --save @opentelemetry/plugin-https

Usage

The following code will configure the NodeTracerProvider to instrument http (and any other installed supported modules) using @opentelemetry/plugin-http.

const { NodeTracerProvider } = require('@opentelemetry/node');

// Create and configure NodeTracerProvider
const provider = new NodeTracerProvider();

// Initialize the provider
provider.register()

// Your application code - http will automatically be instrumented if
// @opentelemetry/plugin-http is present
const http = require('http');

Plugin configuration

User supplied plugin configuration is merged with the default plugin configuration. Furthermore, custom plugins that are configured are implicitly enabled just as default plugins are.

In the following example:

  • the default express plugin is disabled
  • the http plugin has a custom config for a requestHook
  • the customPlugin is loaded from the user supplied path
  • all default plugins are still loaded if installed.
const provider = new NodeTracerProvider({
  plugins: {
    express: {
      enabled: false,
    },
    http: {
      requestHook: (span, request) => {
        span.setAttribute("custom request hook attribute", "request");
      },
    },
    customPlugin: {
      path: "/path/to/custom/module",
    },
  },
});

Disable Plugins with Environment Variables

Plugins can be disabled without modifying and redeploying code. OTEL_NO_PATCH_MODULES accepts a comma separated list of module names to disabled specific plugins. The names should match what you use to require the module into your application. For example, OTEL_NO_PATCH_MODULES=pg,https will disable the postgres plugin and the https plugin. To disable all plugins, set the environment variable to *.

Examples

See how to automatically instrument http and gRPC / grpc-js using node-sdk.

Useful links

License

Apache 2.0 - See LICENSE for more information.