open-telemetry / opentelemetry-js

OpenTelemetry JavaScript Client
https://opentelemetry.io
Apache License 2.0
2.69k stars 773 forks source link

Wrong import for "OTLPExporterNodeBase" #4794

Open PurpleTape opened 3 months ago

PurpleTape commented 3 months ago

What happened?

Actual Result

When I start the project, I get an import error:

✘ [ERROR] No matching export in "node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js" for import "OTLPExporterNodeBase"

    node_modules/@opentelemetry/exporter-metrics-otlp-proto/build/esm/OTLPMetricExporter.js:44:77:
      44 │ import { appendResourcePathToUrl, appendRootPathToUrlIfNeeded, parseHeaders, OTLPExporterNodeBase, } from '@opentelemetry/otlp-exporter-base';
         ╵                                                                              ~~~~~~~~~~~~~~~~~~~~

Additional Details

OpenTelemetry Setup Code

No response

package.json

"@opentelemetry/api": "^1.9.0",
"@opentelemetry/exporter-metrics-otlp-proto": "^0.52.0",
"@opentelemetry/exporter-trace-otlp-proto": "^0.52.0",
"@opentelemetry/host-metrics": "^0.35.2",
"@opentelemetry/resources": "^1.25.0",
"@opentelemetry/sdk-metrics": "^1.25.0",
"@opentelemetry/sdk-node": "^0.52.0",
"@opentelemetry/semantic-conventions": "^1.25.0",

Relevant log output

No response

pichlermarc commented 3 months ago

@PurpleTape thanks for reaching out. Are you bundling your app? If yes which bundler are you using?

I'd be very interested in a way to reproduce this. I think it's caused by the different named exports for Node.js and Browser we're using in that package and I'm currently working on eliminating those.

PurpleTape commented 3 months ago

Hello, @pichlermarc!

I have prepared a repository with a reproduction of the error. Inside the repository, you can find steps to reproduce the error. I also want to mention that I use Vite to build a backend, not a frontend

https://github.com/PurpleTape/open-telemetry-issue

pichlermarc commented 3 months ago

@PurpleTape thank you for providing the reproducer - I think the repro app does try to bundle it up for the browser, though. The proto-metrics exporter only supports node.js at the moment, see https://github.com/open-telemetry/opentelemetry-js/issues/4098. So I think it's fair to expect that this would not work at the moment.

Is there some extra config that you're using to build your backend app with vite? AFAIK there's usually some extra plugins involved in such a build, right?

PurpleTape commented 3 months ago

@pichlermarc, yes, you're right! I used additional Vite plugins for backend development. Most likely, the current level of development of Vite tools is not enough for stable backend development and I need to choose other tools.

If you are interested, I have updated the repository, bringing it to the form in which backend development is carried out

JamieDanielson commented 2 months ago

@pichlermarc have you had a chance to look at this to determine the priority level, whether it is a bug? Just looking at how best to label it and triage it for now.

pichlermarc commented 2 months ago

@pichlermarc have you had a chance to look at this to determine the priority level, whether it is a bug? Just looking at how best to label it and triage it for now.

@JamieDanielson it is a bug that has a few different layers to it. It's the good old ESM/CJS dual-export issue (#4743) + wrong export naming (differently named exports for nodejs and browser). Once we fix the naming (this will be done via the work I'm doing on #4116), then this issue here will become a duplicate of #3989.

As it causes compile and likely runtime issues, and there are currently no workarounds, I'll label this as P1.

sebastien-comeau commented 3 weeks ago

What's the status of this issue? Still an issue for me. Thanks

pichlermarc commented 3 weeks ago

@sebastien-comeau I moved a lot of the transport code, which was step 1. Now I need to do the same with the config (step 2, currently in progress). Once I'm done with that we can collapse all the exporter base code into all platform agnostic types (step 3).

I'm aiming for this to land in 0.55.0.

sebastien-comeau commented 3 weeks ago

@pichlermarc nice to hear. What's the ETA for version 0.55.0?

pichlermarc commented 2 weeks ago

@sebastien-comeau sometime in the first week of october.