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

New resource detectors import "os" which doesn't work in browsers #3003

Closed
blumamir opened this issue May 30, 2022 · 6 comments · Fixed by #3004
Closed

New resource detectors import "os" which doesn't work in browsers #3003

blumamir opened this issue May 30, 2022 · 6 comments · Fixed by #3004
Labels
bug Something isn't working

Comments

@blumamir
Copy link
Member

What version of OpenTelemetry are you using?

1.3.0

What version of Node are you using?

12

Versions 1.3.0 of stable added new resource detectors to @opentelemetry/resources: "OsDetector" and "HostDetector". They both "import {..} from 'os' which makes contrib tests fail with message:

Module not found: Error: Can't resolve 'os' in '/home/runner/work/opentelemetry-js-contrib/opentelemetry-js-contrib/plugins/web/opentelemetry-instrumentation-document-load/node_modules/@opentelemetry/resources/build/esm/detectors'

Are these detectors meant to be used in the browser? As far as I understand, the @opentelemetry/resources package is supposed to be browser compatible, do we need to handle these imports in any way to make it work? or make sure the detectors are not included in a browser distribution?

@jjhuff
Copy link

jjhuff commented Jun 2, 2022

I noticed that I still have to tell webpack to ignore os:

  resolve: {
    fallback: { os: false },

The way I'm reading the code, it looks like the node versions always get imported?

I'm importing Resource like:
import { Resource } from '@opentelemetry/resources';

@blumamir
Copy link
Member Author

blumamir commented Jun 2, 2022

I think the fix is merged but not yet published

@jjhuff
Copy link

jjhuff commented Jun 2, 2022

I think it went out with 0.29.1: #3013

@blumamir
Copy link
Member Author

blumamir commented Jun 2, 2022

I think it went out with 0.29.1: #3013

The version in npm is still 1.3.0: https://www.npmjs.com/package/@opentelemetry/resources

Looks like #3013 released experimental but not stable packages.
@dyladan - should we publish a release for 1.3.1?

@jjhuff
Copy link

jjhuff commented Jun 2, 2022

oh! Yes, I apologize. I was looking at the wrong package

@blumamir
Copy link
Member Author

blumamir commented Jun 2, 2022

@dyladan will publish stable packages later today.
Thank you for reporting

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
Development

Successfully merging a pull request may close this issue.

2 participants