fastify-opentelemetry
Advanced tools
Comparing version 1.0.1 to 1.0.2
21
index.js
const fp = require('fastify-plugin') | ||
const get = require('lodash.get') | ||
const attributesNames = { | ||
@@ -17,2 +18,17 @@ FASTIFY_TYPE: 'fastify.type' | ||
function buildRootOption (req, tracePluginOptions) { | ||
const urlForHttp = get(req.raw, 'client.parser.incoming.originalUrl', null) | ||
const urlForHttp2 = get(req.headers, ':path', null) | ||
const url = urlForHttp || urlForHttp2 | ||
const methodForHttp = get(req.raw, 'client.parser.incoming.method', null) | ||
const methodForHttp2 = get(req.headers, ':method', null) | ||
const method = methodForHttp || methodForHttp2 | ||
return { | ||
name: tracePluginOptions.nameOverride ? tracePluginOptions.nameOverride(req) : url, | ||
url, | ||
method | ||
} | ||
} | ||
function initializeOpentelemetry (tracer) { | ||
@@ -46,3 +62,6 @@ return { | ||
if (enabled && tracer) { | ||
const rootSpan = tracer.startSpan(spanNames.ROOT, { parent: tracer.getCurrentSpan() }) | ||
const rootSpanOption = buildRootOption(req, options || {}) | ||
const rootSpan = tracer.startSpan(rootSpanOption.name, { parent: tracer.getCurrentSpan() }) | ||
rootSpan.setAttribute('method', rootSpanOption.method) | ||
rootSpan.setAttribute('url', rootSpanOption.url) | ||
const onRequestSpan = tracer.startSpan(spanNames.ON_REQUEST, { | ||
@@ -49,0 +68,0 @@ parent: rootSpan, |
{ | ||
"name": "fastify-opentelemetry", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "OpenTelemetry fastify automatic instrumentation package.", | ||
@@ -27,3 +27,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"fastify-plugin": "^1.6.1" | ||
"fastify-plugin": "^1.6.1", | ||
"lodash.get": "^4.4.2" | ||
}, | ||
@@ -30,0 +31,0 @@ "devDependencies": { |
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
13836
310
2
+ Addedlodash.get@^4.4.2
+ Addedlodash.get@4.4.2(transitive)