OpenTelemetry Koa automatic instrumentation package.

Usage no npm install needed!

<script type="module">
  import opentelemetryInstrumentationKoa from 'https://cdn.skypack.dev/@opentelemetry/instrumentation-koa';


OpenTelemetry Koa Instrumentation for Node.js

NPM Published Version dependencies devDependencies Apache License

This module provides automatic instrumentation for Koa.

For automatic instrumentation see the @opentelemetry/sdk-trace-node package.

Compatible with OpenTelemetry JS API and SDK 1.0+.


npm install --save @opentelemetry/instrumentation-koa

Supported Versions

  • ^2.0.0


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.

const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { KoaInstrumentation } = require('@opentelemetry/instrumentation-koa');

const provider = new NodeTracerProvider();

  instrumentations: [
    new KoaInstrumentation(),

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

Koa Instrumentation Options

Options Type Example Description
ignoreLayersType KoaLayerType[] ['middleware'] Ignore layers of specified type.

ignoreLayersType accepts an array of KoaLayerType which can take the following string values:

  • router,
  • middleware.

Koa Packages

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

Useful links


Apache 2.0 - See LICENSE for more information.