-
Notifications
You must be signed in to change notification settings - Fork 806
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
fix(instrumentation): do not import 'path' in browser runtimes #4386
fix(instrumentation): do not import 'path' in browser runtimes #4386
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #4386 +/- ##
=======================================
Coverage 92.24% 92.24%
=======================================
Files 333 334 +1
Lines 9459 9463 +4
Branches 2009 2009
=======================================
+ Hits 8725 8729 +4
Misses 734 734
|
export function normalize(_path: string): string { | ||
throw new Error('Not implemented'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want this to throw? I think just a no-op that returns the input should be fine. Maybe a diag warning that something unexpected happened?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes a warning will also do the trick - I changed it to a no-op, see aa42161
…telemetry#4386) * fix(instrumentation): do not import 'path' in browser runtimes * fix(changelog): clean up and add entry * fix(instrumentation): add missing license header * fix(changelog): formatting * fix(instrumentation): do not throw
Which problem is this PR solving?
Since we now export
InstrumentationNodeModuleDefinition
even if@opentelemetry/instrumentation
is used in a browser context. This PR changes it so that it does not import'path'
anymore which is part of the nodejs core library. As only thenormalize
function is used, I replaced it with a function that throws on runtime should someone useInstrumentationNodeModuleDefinition
in the browser for some reason.Fixes #4373
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
npm pack
ed@opentelemetry/instrumentation
locally, installed it in a local reproducer and packaged it withwebpack
.