Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@opentelemetry/instrumentation-express - incorrect route set to span attributes #2678

Open
DmytryS opened this issue Jan 23, 2025 · 0 comments · May be fixed by #2245
Open

@opentelemetry/instrumentation-express - incorrect route set to span attributes #2678

DmytryS opened this issue Jan 23, 2025 · 0 comments · May be fixed by #2245
Labels
bug Something isn't working

Comments

@DmytryS
Copy link

DmytryS commented Jan 23, 2025

What version of OpenTelemetry are you using?

{
    "@opentelemetry/api": "1.9.0",
    "@opentelemetry/api-logs": "0.56.0",
    "@opentelemetry/core": "1.29.0",
    "@opentelemetry/exporter-logs-otlp-http": "0.56.0",
    "@opentelemetry/exporter-metrics-otlp-http": "0.56.0",
    "@opentelemetry/exporter-trace-otlp-http": "0.56.0",
    "@opentelemetry/instrumentation": "0.56.0",
    "@opentelemetry/auto-instrumentations-node": "0.54.0",
    "@opentelemetry/resources": "1.29.0",
    "@opentelemetry/sdk-logs": "0.56.0",
    "@opentelemetry/sdk-metrics": "1.29.0",
    "@opentelemetry/sdk-node": "0.56.0",
    "@opentelemetry/sdk-trace-base": "1.29.0",
    "@opentelemetry/sdk-trace-node": "1.29.0",
    "@opentelemetry/semantic-conventions": "1.28.0",
    "express": "4.18.2"
}

What version of Node are you using?

v18.20.4

What did you do?

/*
 * otel.js
 */
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { Resource } from '@opentelemetry/resources'
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions'
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
import { registerInstrumentations } from '@opentelemetry/instrumentation'

const exporter = new OTLPTraceExporter({
  url: 'http://localhost/jaeger/v1/traces',
})
const provider = new NodeTracerProvider({
  resource: new Resource({
    [SEMRESATTRS_SERVICE_NAME]: 'api-local',
  }),
})
provider.addSpanProcessor(new SimpleSpanProcessor(exporter))
provider.register()

registerInstrumentations({
  instrumentations: [
    getNodeAutoInstrumentations(),
  ],
})


/*
 * index.js
 */
import './otel.js'
import http from 'http'
import express from 'express'

const app = express()

const { Router } = express
const router = Router()

const workspaceUserRouter = Router({ mergeParams: true })

router.route('/').get(
  (req, res, next) => {
    return res.status(200).json([{email: '[email protected]'}])
  }
)

router.use('/workspaces/:workspaceId/users', workspaceUserRouter)

app.use('/v0/api', router)
const httpServer = http.createServer(app)
httpServer.listen(3000)

What did you expect to see?

Whole endpoint url to be present at root span attributes

Image

What did you see instead?

Only router prefix set to span attributes

Image

Additional context

@DmytryS DmytryS added the bug Something isn't working label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant