Skip to content

Fastify instrumentation incorrectly sets middleware span as parent span to route handler with sync hooks #2619

Closed as not planned
@drewcorlin1

Description

@drewcorlin1

What version of OpenTelemetry are you using?

  "dependencies": {
   "@opentelemetry/auto-instrumentations-node": "^0.55.0",
    "@opentelemetry/exporter-trace-otlp-proto": "^0.57.0",
    "@opentelemetry/sdk-node": "^0.57.0",
    "@opentelemetry/sdk-trace-base": "^1.30.0"
  }

What version of Node are you using?

20.18

What did you do?

Repo to reproduce with steps in the README: https://github.com/drewcorlin1/fastify-otel-bug-example

What did you expect to see?

The route handler as a child span of the GET /example from @opentelemetry/instrumentation-http (and thus, jaeger correctly identifying the critical path of the request)

What did you see instead?

The route handler has a child span of the first middleware span middleware - fastify -> @fastify/request-context from @opentelemetry/instrumentation-fastify (and thus jaeger incorrectly identifying the critical path of my trace)

Additional context

Screenshot of what I'm seeing and full JSON of the trace downloaded from jaeger attached
Screenshot 2024-12-30 at 11 12 19 PM

fastify-trace.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpkg-status:unmaintainedThis package is unmaintained. Only bugfixes may be acceped until a new owner has been found.pkg:instrumentation-fastifypriority:p2Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrectstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions