@platformatic/telemetry 2.52.0 → 2.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,14 +30,11 @@ const { name: moduleName, version: moduleVersion } = require('../package.json')
30
30
  // - zipkin (https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-exporter-zipkin/README.md)
31
31
  // - memory: for testing
32
32
 
33
- const extractRoute = (request) => {
34
- if (request.routeOptions?.url) {
35
- return formatParamUrl(request.routeOptions.url)
33
+ function formatSpanName (request, route) {
34
+ if (route) {
35
+ route = formatParamUrl(route)
36
36
  }
37
- return null
38
- }
39
37
 
40
- function formatSpanName (request, route) {
41
38
  const { method, url } = request
42
39
  return `${method} ${route ?? url}`
43
40
  }
@@ -181,7 +178,7 @@ function setupTelemetry (opts, logger) {
181
178
  fastifyTextMapGetter
182
179
  )
183
180
 
184
- const route = extractRoute(request)
181
+ const route = request.routeOptions?.url ?? null
185
182
  const span = tracer.startSpan(formatSpanName(request, route), {}, context)
186
183
  span.kind = SpanKind.SERVER
187
184
  // Next 2 lines are needed by W3CTraceContextPropagator
@@ -368,6 +365,5 @@ function setupTelemetry (opts, logger) {
368
365
  module.exports = {
369
366
  setupTelemetry,
370
367
  formatSpanName,
371
- formatSpanAttributes,
372
- extractRoute
368
+ formatSpanAttributes
373
369
  }
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const { SpanStatusCode, SpanKind } = require('@opentelemetry/api')
4
- const { formatSpanName, formatSpanAttributes, extractRoute } = require('./telemetry-config')
4
+ const { formatSpanName, formatSpanAttributes } = require('./telemetry-config')
5
5
  const api = require('@opentelemetry/api')
6
6
  const fastUri = require('fast-uri')
7
7
  const packageJson = require('../package.json')
@@ -12,7 +12,7 @@ const createTelemetryThreadInterceptorHooks = () => {
12
12
  const onServerRequest = (req, cb) => {
13
13
  const activeContext = api.propagation.extract(api.context.active(), req.headers)
14
14
 
15
- const route = extractRoute(req)
15
+ const route = req.routeOptions?.url ?? null
16
16
  const span = tracer.startSpan(formatSpanName(req, route), {
17
17
  attributes: formatSpanAttributes.request(req, route),
18
18
  kind: SpanKind.SERVER
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/telemetry",
3
- "version": "2.52.0",
3
+ "version": "2.53.0",
4
4
  "description": "OpenTelemetry integration for Platformatic",
5
5
  "main": "index.js",
6
6
  "author": "Platformatic Inc. <oss@platformatic.dev> (https://platformatic.dev)",
@@ -36,7 +36,7 @@
36
36
  "abstract-logging": "^2.0.1",
37
37
  "fast-uri": "^3.0.0",
38
38
  "fastify-plugin": "^5.0.0",
39
- "@platformatic/config": "2.52.0"
39
+ "@platformatic/config": "2.53.0"
40
40
  },
41
41
  "scripts": {
42
42
  "test": "npm run lint && borp --timeout=120000 --concurrency=1",