Socket
Socket
Sign inDemoInstall

@opentelemetry/instrumentation-koa

Package Overview
Dependencies
Maintainers
3
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.41.0 to 0.42.0

2

build/src/instrumentation.js

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

init() {
return new instrumentation_1.InstrumentationNodeModuleDefinition('koa', ['^2.0.0'], (module) => {
return new instrumentation_1.InstrumentationNodeModuleDefinition('koa', ['>=2.0.0 <3'], (module) => {
const moduleExports = module[Symbol.toStringTag] === 'Module'

@@ -41,0 +41,0 @@ ? module.default // ESM

/// <reference types="koa__router" />
import type { Middleware, DefaultState } from 'koa';
import { KoaContext } from './types';
import type { Middleware, ParameterizedContext, DefaultState } from 'koa';
import type * as Router from '@koa/router';
export declare type KoaContext = ParameterizedContext<DefaultState, Router.RouterParamContext>;
export declare type KoaMiddleware = Middleware<DefaultState, KoaContext> & {

@@ -6,0 +6,0 @@ router?: Router;

@@ -1,4 +0,1 @@

/// <reference types="koa__router" />
import type { Middleware, ParameterizedContext, DefaultState } from 'koa';
import type { RouterParamContext } from '@koa/router';
import { Span } from '@opentelemetry/api';

@@ -10,6 +7,26 @@ import { InstrumentationConfig } from '@opentelemetry/instrumentation';

}
export declare type KoaContext = ParameterizedContext<DefaultState, RouterParamContext>;
export declare type KoaRequestInfo = {
context: KoaContext;
middlewareLayer: Middleware<DefaultState, KoaContext>;
/**
* Information about the current Koa middleware layer
* The middleware layer type is any by default.
* One can install koa types packages `@types/koa` and `@types/koa__router`
* with compatible versions to the koa version used in the project
* to get more specific types for the middleware layer property.
*
* Example use in a custom attribute function:
* ```ts
* import type { Middleware, ParameterizedContext, DefaultState } from 'koa';
* import type { RouterParamContext } from '@koa/router';
*
* type KoaContext = ParameterizedContext<DefaultState, RouterParamContext>;
* type KoaMiddleware = Middleware<DefaultState, KoaContext>;
*
* const koaConfig: KoaInstrumentationConfig<KoaContext, KoaMiddleware> = {
* requestHook: (span: Span, info: KoaRequestInfo<KoaContext, KoaMiddleware>) => {
* // custom typescript code that can access the typed into.middlewareLayer and info.context
* }
*
*/
export declare type KoaRequestInfo<KoaContextType = any, KoaMiddlewareType = any> = {
context: KoaContextType;
middlewareLayer: KoaMiddlewareType;
layerType: KoaLayerType;

@@ -22,4 +39,4 @@ };

*/
export interface KoaRequestCustomAttributeFunction {
(span: Span, info: KoaRequestInfo): void;
export interface KoaRequestCustomAttributeFunction<KoaContextType = any, KoaMiddlewareType = any> {
(span: Span, info: KoaRequestInfo<KoaContextType, KoaMiddlewareType>): void;
}

@@ -29,8 +46,8 @@ /**

*/
export interface KoaInstrumentationConfig extends InstrumentationConfig {
export interface KoaInstrumentationConfig<KoaContextType = any, KoaMiddlewareType = any> extends InstrumentationConfig {
/** Ignore specific layers based on their type */
ignoreLayersType?: KoaLayerType[];
/** Function for adding custom attributes to each middleware layer span */
requestHook?: KoaRequestCustomAttributeFunction;
requestHook?: KoaRequestCustomAttributeFunction<KoaContextType, KoaMiddlewareType>;
}
//# sourceMappingURL=types.d.ts.map

@@ -1,3 +0,3 @@

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

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

*/
export declare const isLayerIgnored: (type: KoaLayerType, config?: KoaInstrumentationConfig | undefined) => boolean;
export declare const isLayerIgnored: (type: KoaLayerType, config?: KoaInstrumentationConfig<any, any> | undefined) => boolean;
//# sourceMappingURL=utils.d.ts.map

@@ -1,3 +0,3 @@

export declare const PACKAGE_VERSION = "0.41.0";
export declare const PACKAGE_VERSION = "0.42.0";
export declare const PACKAGE_NAME = "@opentelemetry/instrumentation-koa";
//# sourceMappingURL=version.d.ts.map

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

// this is autogenerated file, see scripts/version-update.js
exports.PACKAGE_VERSION = '0.41.0';
exports.PACKAGE_VERSION = '0.42.0';
exports.PACKAGE_NAME = '@opentelemetry/instrumentation-koa';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/instrumentation-koa",
"version": "0.41.0",
"version": "0.42.0",
"description": "OpenTelemetry instrumentation for `koa` http web application framework",

@@ -15,2 +15,3 @@ "main": "build/src/index.js",

"lint:fix": "eslint . --ext .ts --fix",
"lint:readme": "node ../../../scripts/lint-readme.js",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/instrumentation-koa --include-dependencies",

@@ -56,2 +57,4 @@ "prewatch": "npm run precompile",

"@opentelemetry/sdk-trace-node": "^1.8.0",
"@types/koa": "2.15.0",
"@types/koa__router": "12.0.4",
"@types/mocha": "7.0.2",

@@ -72,8 +75,6 @@ "@types/node": "18.6.5",

"@opentelemetry/instrumentation": "^0.52.0",
"@opentelemetry/semantic-conventions": "^1.22.0",
"@types/koa": "2.14.0",
"@types/koa__router": "12.0.3"
"@opentelemetry/semantic-conventions": "^1.22.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-koa#readme",
"gitHead": "0af1b70f7c3c9763c85ac51fa5e334c1e1512020"
"gitHead": "ad8436d6a4174f2288cb939080cd4e74da94b0d7"
}

@@ -10,2 +10,4 @@ # OpenTelemetry Koa Instrumentation for Node.js

Compatible with OpenTelemetry JS API and SDK `1.0+`.
## Status

@@ -25,4 +27,4 @@

- `koa`: `^2.0.0`
- `@koa/router`: `>=8`
- [`koa`](https://www.npmjs.com/package/koa) versions `>=2.0.0 <3`
- [`@koa/router`](https://www.npmjs.com/package/@koa/router) versions `>=8.0.0`

@@ -68,7 +70,14 @@ ## Usage

```javascript
NOTE: `KoaRequestInfo.context` and `KoaRequestInfo.middlewareLayer` are typed as `any`. If you want type support make sure you have `@types/koa` and `@types/koa__router` installed then you can use the following type definitions:
```typescript
import { KoaInstrumentation } from "@opentelemetry/instrumentation-koa"
import type { Middleware, ParameterizedContext, DefaultState } from 'koa';
import type { RouterParamContext } from '@koa/router';
type KoaContext = ParameterizedContext<DefaultState, RouterParamContext>;
type KoaMiddleware = Middleware<DefaultState, KoaContext>;
const koaInstrumentation = new KoaInstrumentation({
requestHook: function (span: Span, info: KoaRequestInfo) {
requestHook: function (span: Span, info: KoaRequestInfo<KoaContext, KoaMiddleware>) {
span.setAttribute(

@@ -75,0 +84,0 @@ 'http.method',

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

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