@opentelemetry/hapi-instrumentation
Advanced tools
Comparing version 0.10.0 to 0.11.0
@@ -99,9 +99,10 @@ "use strict"; | ||
return function register(pluginInput, options) { | ||
var _a, _b, _c, _d; | ||
if (Array.isArray(pluginInput)) { | ||
for (const pluginObj of pluginInput) { | ||
instrumentation._wrapRegisterHandler(pluginObj.plugin); | ||
instrumentation._wrapRegisterHandler((_b = (_a = pluginObj.plugin) === null || _a === void 0 ? void 0 : _a.plugin) !== null && _b !== void 0 ? _b : pluginObj.plugin); | ||
} | ||
} | ||
else { | ||
instrumentation._wrapRegisterHandler(pluginInput.plugin); | ||
instrumentation._wrapRegisterHandler((_d = (_c = pluginInput.plugin) === null || _c === void 0 ? void 0 : _c.plugin) !== null && _d !== void 0 ? _d : pluginInput.plugin); | ||
} | ||
@@ -254,2 +255,3 @@ return original.apply(this, [pluginInput, options]); | ||
_wrapRouteHandler(route, pluginName) { | ||
var _a, _b, _c; | ||
const instrumentation = this; | ||
@@ -259,7 +261,7 @@ if (route[types_1.handlerPatched] === true) | ||
route[types_1.handlerPatched] = true; | ||
if (typeof route.handler === 'function') { | ||
const handler = route.handler; | ||
const oldHandler = (_b = (_a = route.options) === null || _a === void 0 ? void 0 : _a.handler) !== null && _b !== void 0 ? _b : route.handler; | ||
if (typeof oldHandler === 'function') { | ||
const newHandler = async function (request, h, err) { | ||
if (instrumentation._tracer.getCurrentSpan() === undefined) { | ||
return await handler(request, h, err); | ||
return await oldHandler(request, h, err); | ||
} | ||
@@ -270,7 +272,12 @@ const metadata = utils_1.getRouteMetadata(route, pluginName); | ||
}); | ||
const res = await handler(request, h, err); | ||
const res = await oldHandler(request, h, err); | ||
span.end(); | ||
return res; | ||
}; | ||
route.handler = newHandler; | ||
if ((_c = route.options) === null || _c === void 0 ? void 0 : _c.handler) { | ||
route.options.handler = newHandler; | ||
} | ||
else { | ||
route.handler = newHandler; | ||
} | ||
} | ||
@@ -277,0 +284,0 @@ return route; |
import type * as Hapi from '@hapi/hapi'; | ||
import { Lifecycle } from '@hapi/hapi'; | ||
export declare const HapiComponentName = "@hapi/hapi"; | ||
@@ -14,4 +15,10 @@ /** | ||
[handlerPatched]?: boolean; | ||
options?: { | ||
handler?: Lifecycle.Method; | ||
}; | ||
}; | ||
export declare type HapiPluginInput<T> = Hapi.ServerRegisterPluginObject<T> | Array<Hapi.ServerRegisterPluginObject<T>>; | ||
export declare type HapiPluginObject<T> = Hapi.ServerRegisterPluginObject<T> & { | ||
plugin: Hapi.ServerRegisterPluginObject<T>; | ||
}; | ||
export declare type HapiPluginInput<T> = HapiPluginObject<T> | Array<HapiPluginObject<T>>; | ||
export declare type RegisterFunction<T> = (plugin: HapiPluginInput<T>, options?: Hapi.ServerRegisterOptions) => Promise<void>; | ||
@@ -18,0 +25,0 @@ export declare type PatchableExtMethod = Hapi.Lifecycle.Method & { |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.10.0"; | ||
export declare const VERSION = "0.11.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.10.0'; | ||
exports.VERSION = '0.11.0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/hapi-instrumentation", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "OpenTelemetry Hapi automatic instrumentation package.", | ||
@@ -44,7 +44,7 @@ "main": "build/src/index.js", | ||
"devDependencies": { | ||
"@hapi/hapi": "^19.2.0", | ||
"@opentelemetry/context-async-hooks": "^0.11.0", | ||
"@opentelemetry/node": "^0.11.0", | ||
"@opentelemetry/tracing": "^0.11.0", | ||
"@types/hapi__hapi": "^19.0.3", | ||
"@hapi/hapi": "20.0.1", | ||
"@opentelemetry/context-async-hooks": "0.12.0", | ||
"@opentelemetry/node": "0.12.0", | ||
"@opentelemetry/tracing": "0.12.0", | ||
"@types/hapi__hapi": "20.0.1", | ||
"@types/mocha": "7.0.2", | ||
@@ -54,4 +54,4 @@ "@types/node": "12.12.47", | ||
"codecov": "3.7.0", | ||
"eslint": "^7.4.0", | ||
"eslint-plugin-header": "^3.0.0", | ||
"eslint": "7.8.1", | ||
"eslint-plugin-header": "3.1.0", | ||
"gts": "2.0.2", | ||
@@ -61,5 +61,5 @@ "mocha": "7.2.0", | ||
"rimraf": "3.0.2", | ||
"semver": "^7.3.2", | ||
"semver": "7.3.2", | ||
"ts-mocha": "7.0.0", | ||
"ts-node": "8.10.2", | ||
"ts-node": "9.0.0", | ||
"tslint-consistent-codestyle": "1.16.0", | ||
@@ -70,8 +70,8 @@ "tslint-microsoft-contrib": "6.2.0", | ||
"dependencies": { | ||
"@opentelemetry/api": "^0.11.0", | ||
"@opentelemetry/core": "^0.11.0", | ||
"@opentelemetry/semantic-conventions": "^0.11.0", | ||
"@opentelemetry/api": "^0.12.0", | ||
"@opentelemetry/core": "^0.12.0", | ||
"@opentelemetry/semantic-conventions": "^0.12.0", | ||
"shimmer": "^1.2.1" | ||
}, | ||
"gitHead": "903ee951bcfe54fb048a76aed5bf1117951605d7" | ||
"gitHead": "f4d1a7120a96476102efeb0ba7aed85ecbfc3a0a" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44865
587
1
+ Added@opentelemetry/api@0.12.0(transitive)
+ Added@opentelemetry/context-base@0.12.0(transitive)
+ Added@opentelemetry/core@0.12.0(transitive)
+ Added@opentelemetry/semantic-conventions@0.12.0(transitive)
- Removed@opentelemetry/api@0.11.0(transitive)
- Removed@opentelemetry/context-base@0.11.0(transitive)
- Removed@opentelemetry/core@0.11.0(transitive)
- Removed@opentelemetry/semantic-conventions@0.11.0(transitive)
Updated@opentelemetry/api@^0.12.0
Updated@opentelemetry/core@^0.12.0