@opentelemetry/instrumentation-fastify
Advanced tools
Comparing version 0.32.2 to 0.32.3
@@ -50,2 +50,3 @@ "use strict"; | ||
return function onRequest(request, reply, done) { | ||
var _a, _b; | ||
if (!instrumentation.isEnabled()) { | ||
@@ -55,4 +56,5 @@ return done(); | ||
instrumentation._wrap(reply, 'send', instrumentation._patchSend()); | ||
const anyRequest = request; | ||
const rpcMetadata = (0, core_1.getRPCMetadata)(api_1.context.active()); | ||
const routeName = request.routerPath; | ||
const routeName = ((_b = (_a = anyRequest.routeOptions) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.url) || request.routerPath; | ||
if (routeName && (rpcMetadata === null || rpcMetadata === void 0 ? void 0 : rpcMetadata.type) === core_1.RPCType.HTTP) { | ||
@@ -71,3 +73,4 @@ rpcMetadata.route = routeName; | ||
} | ||
const spanName = `${AttributeNames_1.FastifyNames.MIDDLEWARE} - ${original.name || exports.ANONYMOUS_NAME}`; | ||
const name = original.name || pluginName || exports.ANONYMOUS_NAME; | ||
const spanName = `${AttributeNames_1.FastifyNames.MIDDLEWARE} - ${name}`; | ||
const reply = args[1]; | ||
@@ -164,13 +167,14 @@ const span = (0, utils_1.startSpan)(reply, instrumentation.tracer, spanName, { | ||
return function preHandler(request, reply, done) { | ||
var _a; | ||
var _a, _b, _c, _d; | ||
if (!instrumentation.isEnabled()) { | ||
return done(); | ||
} | ||
const requestContext = request.context || {}; | ||
const handlerName = (((_a = requestContext.handler) === null || _a === void 0 ? void 0 : _a.name) || '').substr(6); | ||
const spanName = `${AttributeNames_1.FastifyNames.REQUEST_HANDLER} - ${handlerName || exports.ANONYMOUS_NAME}`; | ||
const anyRequest = request; | ||
const handler = ((_a = anyRequest.routeOptions) === null || _a === void 0 ? void 0 : _a.handler) || ((_b = anyRequest.context) === null || _b === void 0 ? void 0 : _b.handler) || {}; | ||
const handlerName = handler === null || handler === void 0 ? void 0 : handler.name.substr(6); | ||
const spanName = `${AttributeNames_1.FastifyNames.REQUEST_HANDLER} - ${handlerName || this.pluginName || exports.ANONYMOUS_NAME}`; | ||
const spanAttributes = { | ||
[AttributeNames_1.AttributeNames.PLUGIN_NAME]: this.pluginName, | ||
[AttributeNames_1.AttributeNames.FASTIFY_TYPE]: AttributeNames_1.FastifyTypes.REQUEST_HANDLER, | ||
[semantic_conventions_1.SemanticAttributes.HTTP_ROUTE]: request.routerPath, | ||
[semantic_conventions_1.SemanticAttributes.HTTP_ROUTE]: ((_d = (_c = anyRequest.routeOptions) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.url) || request.routerPath, | ||
}; | ||
@@ -177,0 +181,0 @@ if (handlerName) { |
@@ -1,2 +0,2 @@ | ||
import { Span, SpanAttributes, Tracer } from '@opentelemetry/api'; | ||
import { Attributes, Span, Tracer } from '@opentelemetry/api'; | ||
import type { PluginFastifyReply } from './internal-types'; | ||
@@ -10,3 +10,3 @@ /** | ||
*/ | ||
export declare function startSpan(reply: PluginFastifyReply, tracer: Tracer, spanName: string, spanAttributes?: SpanAttributes): Span; | ||
export declare function startSpan(reply: PluginFastifyReply, tracer: Tracer, spanName: string, spanAttributes?: Attributes): Span; | ||
/** | ||
@@ -13,0 +13,0 @@ * Ends span |
@@ -32,2 +32,3 @@ "use strict"; | ||
spans.push(span); | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
Object.defineProperty(reply, constants_1.spanRequestSymbol, { | ||
@@ -34,0 +35,0 @@ enumerable: false, |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.32.2"; | ||
export declare const VERSION = "0.32.3"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.32.2'; | ||
exports.VERSION = '0.32.3'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/instrumentation-fastify", | ||
"version": "0.32.2", | ||
"version": "0.32.3", | ||
"description": "OpenTelemetry fastify automatic instrumentation package.", | ||
@@ -16,2 +16,3 @@ "main": "build/src/index.js", | ||
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'", | ||
"test-all-versions": "tav", | ||
"version:update": "node ../../../scripts/version-update.js", | ||
@@ -52,12 +53,13 @@ "prewatch": "npm run precompile", | ||
"@opentelemetry/context-async-hooks": "^1.8.0", | ||
"@opentelemetry/instrumentation-http": "0.41.2", | ||
"@opentelemetry/instrumentation-http": "0.44.0", | ||
"@opentelemetry/sdk-trace-base": "^1.8.0", | ||
"@opentelemetry/sdk-trace-node": "^1.8.0", | ||
"@types/express": "4.17.17", | ||
"@types/express": "4.17.18", | ||
"@types/mocha": "7.0.2", | ||
"@types/node": "18.6.5", | ||
"@types/node": "18.15.3", | ||
"fastify": "4.18.0", | ||
"mocha": "7.2.0", | ||
"nyc": "15.1.0", | ||
"rimraf": "5.0.1", | ||
"rimraf": "5.0.5", | ||
"test-all-versions": "5.0.1", | ||
"ts-mocha": "10.0.0", | ||
@@ -68,7 +70,7 @@ "typescript": "4.4.4" | ||
"@opentelemetry/core": "^1.8.0", | ||
"@opentelemetry/instrumentation": "^0.41.2", | ||
"@opentelemetry/instrumentation": "^0.44.0", | ||
"@opentelemetry/semantic-conventions": "^1.0.0" | ||
}, | ||
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-fastify#readme", | ||
"gitHead": "d1436eb7e4543d92e23cb1ceff15bf5cf6c3c65c" | ||
"gitHead": "a8c225d2febcac561a70ca586d3efd5a84f9f3fa" | ||
} |
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
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
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
69211
526
16
+ Added@opentelemetry/instrumentation@0.44.0(transitive)
- Removed@opentelemetry/instrumentation@0.41.2(transitive)