@opentelemetry/node

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

Package renamed to @opentelemetry/sdk-trace-node
Last updated 4 years ago by dyladan .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @opentelemetry/node 
SYNC missed versions from official npm registry.

OpenTelemetry Node SDK

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. For loading plugins / instrumentations please use registerInstrumentations function from opentelemetry-instrumentation

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

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

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

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/instrumentation-http
# and for example one additional
npm install --save instrumentation-graphql

Usage

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

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

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

// Initialize the provider
provider.register();

// register and load instrumentation and old plugins - old plugins will be loaded automatically as previously
// but instrumentations needs to be added
registerInstrumentations({
  tracerProvider: provider,
});

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

Instrumentation / 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 { GraphQLInstrumentation } = require('@opentelemetry/instrumentation-graphql');

const provider = new NodeTracerProvider();

// register and load instrumentation and old plugins - old plugins will be loaded automatically as previously
// but instrumentations needs to be added
registerInstrumentations({
  tracerProvider: provider,
  instrumentations: [
    new GraphQLInstrumentation(),
    // for older plugins you can just copy paste the old configuration
    {
      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.

Current Tags

  • 0.24.1-alpha.1                                ...           canary (3 years ago)
  • 0.24.0                                ...           latest (3 years ago)
  • 0.24.0                                ...           next (3 years ago)

153 Versions

  • 0.24.1-alpha.1 [deprecated]           ...           3 years ago
  • 0.24.0 [deprecated]           ...           3 years ago
  • 0.24.1-alpha.31 [deprecated]           ...           3 years ago
  • 0.23.1-alpha.28 [deprecated]           ...           3 years ago
  • 0.23.1-alpha.24 [deprecated]           ...           3 years ago
  • 0.23.1-alpha.23 [deprecated]           ...           3 years ago
  • 0.23.1-alpha.16 [deprecated]           ...           3 years ago
  • 0.23.1-alpha.15 [deprecated]           ...           3 years ago
  • 0.23.1-alpha.3 [deprecated]           ...           3 years ago
  • 0.23.1-alpha.18 [deprecated]           ...           3 years ago
  • 0.23.0 [deprecated]           ...           3 years ago
  • 0.23.1-alpha.17 [deprecated]           ...           3 years ago
  • 0.22.1-alpha.16 [deprecated]           ...           3 years ago
  • 0.22.1-alpha.15 [deprecated]           ...           3 years ago
  • 0.22.1-alpha.14 [deprecated]           ...           3 years ago
  • 0.22.1-alpha.13 [deprecated]           ...           3 years ago
  • 0.22.1-alpha.9 [deprecated]           ...           3 years ago
  • 0.22.1-alpha.8 [deprecated]           ...           3 years ago
  • 0.22.1-alpha.3 [deprecated]           ...           3 years ago
  • 0.22.1-alpha.2 [deprecated]           ...           3 years ago
  • 0.22.0 [deprecated]           ...           3 years ago
  • 0.22.1-alpha.5 [deprecated]           ...           3 years ago
  • 0.21.1-alpha.3 [deprecated]           ...           3 years ago
  • 0.21.1-alpha.2 [deprecated]           ...           3 years ago
  • 0.21.1-alpha.1 [deprecated]           ...           3 years ago
  • 0.21.0 [deprecated]           ...           3 years ago
  • 0.21.1-alpha.7 [deprecated]           ...           3 years ago
  • 0.20.1-alpha.4 [deprecated]           ...           3 years ago
  • 0.20.1-alpha.3 [deprecated]           ...           3 years ago
  • 0.20.0 [deprecated]           ...           3 years ago
  • 0.20.1-alpha.49 [deprecated]           ...           3 years ago
  • 0.19.1-alpha.44 [deprecated]           ...           3 years ago
  • 0.19.1-alpha.43 [deprecated]           ...           3 years ago
  • 0.19.1-alpha.41 [deprecated]           ...           3 years ago
  • 0.19.1-alpha.33 [deprecated]           ...           3 years ago
  • 0.19.1-alpha.31 [deprecated]           ...           3 years ago
  • 0.19.1-alpha.29 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.28 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.27 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.26 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.25 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.23 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.22 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.21 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.19 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.18 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.15 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.14 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.13 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.12 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.11 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.9 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.7 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.40 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.39 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.37 [deprecated]           ...           4 years ago
  • 0.19.0 [deprecated]           ...           4 years ago
  • 0.19.1-alpha.36 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.31 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.30 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.29 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.28 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.27 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.25 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.23 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.20 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.18 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.17 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.16 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.15 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.14 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.11 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.10 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.9 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.7 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.5 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.4 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.3 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.1 [deprecated]           ...           4 years ago
  • 0.18.2 [deprecated]           ...           4 years ago
  • 0.18.3-alpha.2 [deprecated]           ...           4 years ago
  • 0.18.2-alpha.1 [deprecated]           ...           4 years ago
  • 0.18.1 [deprecated]           ...           4 years ago
  • 0.18.2-alpha.81 [deprecated]           ...           4 years ago
  • 0.18.1-alpha.26 [deprecated]           ...           4 years ago
  • 0.18.1-alpha.24 [deprecated]           ...           4 years ago
  • 0.18.1-alpha.23 [deprecated]           ...           4 years ago
  • 0.18.1-alpha.21 [deprecated]           ...           4 years ago
  • 0.18.1-alpha.20 [deprecated]           ...           4 years ago
  • 0.18.1-alpha.16 [deprecated]           ...           4 years ago
  • 0.18.1-alpha.13 [deprecated]           ...           4 years ago
  • 0.18.1-alpha.3 [deprecated]           ...           4 years ago
  • 0.18.0 [deprecated]           ...           4 years ago
  • 0.18.1-alpha.12 [deprecated]           ...           4 years ago
  • 0.17.1-alpha.11 [deprecated]           ...           4 years ago
  • 0.17.1-alpha.10 [deprecated]           ...           4 years ago
  • 0.17.1-alpha.8 [deprecated]           ...           4 years ago
  • 0.17.1-alpha.5 [deprecated]           ...           4 years ago
  • 0.17.1-alpha.3 [deprecated]           ...           4 years ago
  • 0.17.1-alpha.2 [deprecated]           ...           4 years ago
  • 0.17.1-alpha.21 [deprecated]           ...           4 years ago
  • 0.17.0 [deprecated]           ...           4 years ago
  • 0.16.1-alpha.20 [deprecated]           ...           4 years ago
  • 0.16.1-alpha.18 [deprecated]           ...           4 years ago
  • 0.16.1-alpha.15 [deprecated]           ...           4 years ago
  • 0.16.1-alpha.14 [deprecated]           ...           4 years ago
  • 0.16.1-alpha.12 [deprecated]           ...           4 years ago
  • 0.16.1-alpha.11 [deprecated]           ...           4 years ago
  • 0.16.1-alpha.10 [deprecated]           ...           4 years ago
  • 0.16.1-alpha.6 [deprecated]           ...           4 years ago
  • 0.16.0 [deprecated]           ...           4 years ago
  • 0.15.0 [deprecated]           ...           4 years ago
  • 0.14.0 [deprecated]           ...           4 years ago
  • 0.13.0 [deprecated]           ...           4 years ago
  • 0.12.1-alpha.7 [deprecated]           ...           4 years ago
  • 0.12.1-alpha.4 [deprecated]           ...           4 years ago
  • 0.12.0 [deprecated]           ...           4 years ago
  • 0.12.1-alpha.54 [deprecated]           ...           4 years ago
  • 0.11.1-alpha.53 [deprecated]           ...           4 years ago
  • 0.11.1-alpha.44 [deprecated]           ...           4 years ago
  • 0.11.1-alpha.36 [deprecated]           ...           4 years ago
  • 0.11.1-alpha.35 [deprecated]           ...           4 years ago
  • 0.11.1-alpha.15 [deprecated]           ...           4 years ago
  • 0.11.0 [deprecated]           ...           4 years ago
  • 0.11.1-alpha.48 [deprecated]           ...           4 years ago
  • 0.10.3-alpha.41 [deprecated]           ...           4 years ago
  • 0.10.3-alpha.40 [deprecated]           ...           4 years ago
  • 0.10.3-alpha.35 [deprecated]           ...           4 years ago
  • 0.10.3-alpha.34 [deprecated]           ...           4 years ago
  • 0.10.3-alpha.28 [deprecated]           ...           4 years ago
  • 0.10.3-canary.0 [deprecated]           ...           4 years ago
  • 0.10.2 [deprecated]           ...           4 years ago
  • 0.10.1 [deprecated]           ...           4 years ago
  • 0.10.0 [deprecated]           ...           4 years ago
  • 0.9.0 [deprecated]           ...           4 years ago
  • 0.8.3 [deprecated]           ...           4 years ago
  • 0.8.2 [deprecated]           ...           4 years ago
  • 0.8.1 [deprecated]           ...           4 years ago
  • 0.8.0 [deprecated]           ...           5 years ago
  • 0.7.0 [deprecated]           ...           5 years ago
  • 0.6.1 [deprecated]           ...           5 years ago
  • 0.6.0 [deprecated]           ...           5 years ago
  • 0.5.2 [deprecated]           ...           5 years ago
  • 0.5.1 [deprecated]           ...           5 years ago
  • 0.5.0 [deprecated]           ...           5 years ago
  • 0.4.0 [deprecated]           ...           5 years ago
  • 0.3.3 [deprecated]           ...           5 years ago
  • 0.3.2 [deprecated]           ...           5 years ago
  • 0.3.1 [deprecated]           ...           5 years ago
  • 0.3.0 [deprecated]           ...           5 years ago
  • 0.2.0 [deprecated]           ...           5 years ago
  • 0.1.1 [deprecated]           ...           5 years ago
  • 0.1.0 [deprecated]           ...           5 years ago
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (17)

© 2010 - cnpmjs.org x YWFE | Home | YWFE