fix(instrumentation): do not import 'path' in browser runtimes - #4386
Merged
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
|
legendecas
approved these changes
Dec 25, 2023
dyladan
reviewed
Jan 2, 2024
Comment on lines
+27
to
+29
| export function normalize(_path: string): string { | ||
| throw new Error('Not implemented'); | ||
| } |
Member
There was a problem hiding this comment.
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?
Member
Author
There was a problem hiding this comment.
Yes a warning will also do the trick - I changed it to a no-op, see aa42161
dyladan
approved these changes
Jan 3, 2024
This was referenced Jan 10, 2024
Zirak
pushed a commit
to Zirak/opentelemetry-js
that referenced
this pull request
Sep 14, 2024
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
Since we now export
InstrumentationNodeModuleDefinitioneven if@opentelemetry/instrumentationis 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 thenormalizefunction is used, I replaced it with a function that throws on runtime should someone useInstrumentationNodeModuleDefinitionin 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 packed@opentelemetry/instrumentationlocally, installed it in a local reproducer and packaged it withwebpack.