Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastify-opentelemetry

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-opentelemetry - npm Package Compare versions

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,

5

package.json
{
"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": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc