Socket
Socket
Sign inDemoInstall

@opentelemetry/instrumentation-koa

Package Overview
Dependencies
Maintainers
4
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-koa - npm Package Compare versions

Comparing version 0.26.0 to 0.27.0

5

build/src/instrumentation.d.ts

@@ -1,7 +0,8 @@

import { InstrumentationBase, InstrumentationConfig, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
import type * as koa from 'koa';
import { KoaInstrumentationConfig } from './types';
/** Koa instrumentation for OpenTelemetry */
export declare class KoaInstrumentation extends InstrumentationBase<typeof koa> {
static readonly component = "koa";
constructor(config?: InstrumentationConfig);
constructor(config?: KoaInstrumentationConfig);
protected init(): InstrumentationNodeModuleDefinition<typeof koa>;

@@ -8,0 +9,0 @@ /**

@@ -99,3 +99,6 @@ "use strict";

_patchLayer(middlewareLayer, isRouter, layerPath) {
if (middlewareLayer[types_1.kLayerPatched] === true)
const layerType = isRouter ? types_1.KoaLayerType.ROUTER : types_1.KoaLayerType.MIDDLEWARE;
// Skip patching layer if its ignored in the config
if (middlewareLayer[types_1.kLayerPatched] === true ||
utils_1.isLayerIgnored(layerType, this._config))
return middlewareLayer;

@@ -102,0 +105,0 @@ middlewareLayer[types_1.kLayerPatched] = true;

@@ -5,2 +5,3 @@ /// <reference types="koa__router" />

import type * as Router from '@koa/router';
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
/**

@@ -16,2 +17,9 @@ * This symbol is used to mark a Koa layer as being already instrumented

export declare type KoaContext = ParameterizedContext<DefaultState, RouterParamContext>;
/**
* Options available for the Koa Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-Instrumentation-koa#koa-Instrumentation-options))
*/
export interface KoaInstrumentationConfig extends InstrumentationConfig {
/** Ignore specific layers based on their type */
ignoreLayersType?: KoaLayerType[];
}
export declare enum KoaLayerType {

@@ -18,0 +26,0 @@ ROUTER = "router",

9

build/src/utils.d.ts

@@ -1,2 +0,2 @@

import { KoaContext, KoaMiddleware } from './types';
import { KoaContext, KoaMiddleware, KoaLayerType, KoaInstrumentationConfig } from './types';
import { SpanAttributes } from '@opentelemetry/api';

@@ -7,2 +7,9 @@ export declare const getMiddlewareMetadata: (context: KoaContext, layer: KoaMiddleware, isRouter: boolean, layerPath?: string | undefined) => {

};
/**
* Check whether the given request is ignored by configuration
* @param [list] List of ignore patterns
* @param [onException] callback for doing something when an exception has
* occurred
*/
export declare const isLayerIgnored: (type: KoaLayerType, config?: KoaInstrumentationConfig | undefined) => boolean;
//# sourceMappingURL=utils.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMiddlewareMetadata = void 0;
exports.isLayerIgnored = exports.getMiddlewareMetadata = void 0;
/*

@@ -45,2 +45,14 @@ * Copyright The OpenTelemetry Authors

exports.getMiddlewareMetadata = getMiddlewareMetadata;
/**
* Check whether the given request is ignored by configuration
* @param [list] List of ignore patterns
* @param [onException] callback for doing something when an exception has
* occurred
*/
const isLayerIgnored = (type, config) => {
var _a;
return !!(Array.isArray(config === null || config === void 0 ? void 0 : config.ignoreLayersType) &&
((_a = config === null || config === void 0 ? void 0 : config.ignoreLayersType) === null || _a === void 0 ? void 0 : _a.includes(type)));
};
exports.isLayerIgnored = isLayerIgnored;
//# sourceMappingURL=utils.js.map

@@ -1,2 +0,2 @@

export declare const VERSION = "0.26.0";
export declare const VERSION = "0.27.0";
//# sourceMappingURL=version.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.26.0';
exports.VERSION = '0.27.0';
//# sourceMappingURL=version.js.map
# Changelog
## [0.27.0](https://www.github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-koa-v0.26.0...instrumentation-koa-v0.27.0) (2021-11-19)
### Features
* **koa:** add a config option to allow layers to be ignored by type ([#646](https://www.github.com/open-telemetry/opentelemetry-js-contrib/issues/646)) ([572ed66](https://www.github.com/open-telemetry/opentelemetry-js-contrib/commit/572ed665ea4ac93082c347f7179d67e9a8fe19b8))
## [0.26.0](https://www.github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-koa-v0.25.0...instrumentation-koa-v0.26.0) (2021-10-22)

@@ -4,0 +11,0 @@

{
"name": "@opentelemetry/instrumentation-koa",
"version": "0.26.0",
"version": "0.27.0",
"description": "OpenTelemetry Koa automatic instrumentation package.",

@@ -53,5 +53,5 @@ "main": "build/src/index.js",

"@opentelemetry/api": "1.0.2",
"@opentelemetry/context-async-hooks": "1.0.0",
"@opentelemetry/sdk-trace-base": "1.0.0",
"@opentelemetry/sdk-trace-node": "1.0.0",
"@opentelemetry/context-async-hooks": "1.0.1",
"@opentelemetry/sdk-trace-base": "1.0.1",
"@opentelemetry/sdk-trace-node": "1.0.1",
"@types/mocha": "7.0.2",

@@ -75,3 +75,3 @@ "@types/node": "14.17.9",

},
"gitHead": "f80834b97bd8e5b1f78923b40fd69d60691c6ff4"
"gitHead": "0463f27863e409b13ce05dc00833183c10d16a29"
}

@@ -46,2 +46,13 @@ # OpenTelemetry Koa Instrumentation for Node.js

### 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

@@ -48,0 +59,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc