Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
// (c) Copyright 2023 Supertenant Ltd. - all rights reserved.
// See LICENSE file in project root for license terms.
"use strict";const shimmer=require("shimmer"),requireHook=require("../../../util/requireHook"),httpServer=require("../protocols/httpServer"),cls=require("../../cls");let logger,isActive=(logger=require("../../../logger").getLogger("tracing/hapi",newLogger=>{logger=newLogger}),!1);function instrumentHapiCall(hapiCall){hapiCall.Router&&hapiCall.Router.prototype?shimmer.wrap(hapiCall.Router.prototype,"route",shimRoute):logger.warn("Found @hapi/call module, but it does not export a Router value. Hapi will not be instrumented, calls processed by Hapi will not have a path template.")}function shimRoute(originalFunction){return function(){var routeObject;return isActive&&cls.isTracing()?(annotateHttpEntrySpanWithPathTemplate(routeObject=originalFunction.apply(this,arguments)),routeObject):originalFunction.apply(this,arguments)}}function annotateHttpEntrySpanWithPathTemplate(routeObject){var span;null!=routeObject&&routeObject.route&&"string"==typeof routeObject.route.path&&(span=cls.getCurrentEntrySpan())&&span.n===httpServer.spanName&&!span.pathTplFrozen&&(span.data.http.path_tpl=routeObject.route.path)}exports.init=function(){requireHook.onModuleLoad("@hapi/call",instrumentHapiCall)},exports.activate=function(){isActive=!0},exports.deactivate=function(){isActive=!1};