autotelic / fastify-opentelemetry

A Fastify plugin that utilizes the OpenTelemetry API to provide request tracing.
MIT License
72 stars 12 forks source link

Proposal to remove exposed public dependencies #22

Closed turneand closed 3 years ago

turneand commented 3 years ago

Currently the module exposes two "dependencies":

  "dependencies": {
    "@opentelemetry/api": "^0.18.1",
    "fastify-plugin": "^3.0.0"
  },

However, we've hit issues due to a conflict on the @opentelemetry/api with those brought in by the rest of our tools. Currently we're using 0.18.0 due to issues with the 0.18.1 versions (conflicts where API is now becoming a release candidate). However, due to node permitted multiple versions to be installed, we actually hit an issue where different parts of the code are using different modules.

This causes an issue due to https://github.com/open-telemetry/opentelemetry-js-api/blob/main/src/api/trace.ts whereby a singleton is held in the api object to reference the Tracer. We've initialised the tracer using one library, but the fastify-opentelemetry module is accessing another version.

There's a note under https://github.com/open-telemetry/opentelemetry-js-api/#version-compatibility explaining the issue in better detail than I provide.

So, couple of options as I see 1) Switch the "dependencies" to "peer-dependencies" 2) Move the "dependencies" to "devDependencies", and have an implied relationship 3) Downgrade version to 0.18.0