JSPM

  • Created
  • Published
  • Downloads 10368349
  • Score
    100M100P100Q239314F
  • License Apache-2.0

OpenTelemetry Koa automatic instrumentation package.

Package Exports

  • @opentelemetry/instrumentation-koa

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@opentelemetry/instrumentation-koa) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

OpenTelemetry Koa Instrumentation for Node.js

Gitter chat dependencies devDependencies Apache License

This module provides automatic instrumentation for Koa.

For automatic instrumentation see the @opentelemetry/node package.

Installation

npm install --save @opentelemetry/instrumentation-koa

Supported Versions

  • Koa ^2.0.0

Usage

OpenTelemetry Koa Instrumentation allows the user to automatically collect trace data and export them to their backend of choice, to give observability to distributed systems.

To load all of the default supported plugins, use the below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules.

const { NodeTracerProvider } = require('@opentelemetry/node');
const provider = new NodeTracerProvider();
provider.register();

const { registerInstrumentations } = require('@opentelemetry/instrumentation');
registerInstrumentations({
  tracerProvider: provider,
});

If instead you would just want to load a specific instrumentation only (koa in this case);

const { NodeTracerProvider } = require('@opentelemetry/node');
const { KoaInstrumentation } = require('@opentelemetry/instrumentation-koa');
const provider = new NodeTracerProvider();
provider.register();

const koaInstrumentation = new KoaInstrumentation();
koaInstrumentation.setTracerProvider(provider);

You can combine loading default plugins and KoaInstrumentation at the same time:

const { NodeTracerProvider } = require('@opentelemetry/node');
const { KoaInstrumentation } = require('@opentelemetry/instrumentation-koa');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const provider = new NodeTracerProvider();
provider.register();

registerInstrumentations({
  instrumentations: [
    new KoaInstrumentation(),
  ],
  tracerProvider: provider,
});

See examples/koa for a short example using both Koa and @koa/router

Koa Packages

This package provides automatic tracing for middleware added using either the core Koa package or the @koa/router package.

License

Apache 2.0 - See LICENSE for more information.