-
Notifications
You must be signed in to change notification settings - Fork 477
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
Add Node.js support for --import
flag
#3416
base: main
Are you sure you want to change the base?
Changes from 6 commits
6bb45bf
30c7f36
f4e5a79
3b65d65
4421cc0
993d67f
555ddcb
a8e0a47
d6747dd
da2827e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) | ||
component: auto-instrumentation | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add Node.js support for `--import` flag | ||
|
||
# One or more tracking issues related to the change | ||
issues: [3414] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | | ||
The new UseImport configuration overrides the default injected --require flag with an --import flag that supports ESM. | ||
Requires Node.js 18 or later. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,11 @@ type NodeJS struct { | |
// Resources describes the compute resource requirements. | ||
// +optional | ||
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"` | ||
|
||
// UseImport overrides the default injected --require flag with an --import flag that supports ESM. | ||
// Requires Node.js 18 or later. | ||
// +optional | ||
UseImport bool `json:"useImport,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One subtlety that might impact the choice of the config var name. That is actually independent of whether So I wonder if a config name something like There are a few subtleties discussed at open-telemetry/opentelemetry-js#4933, but I don't think you need to read and grok all that. Eventually we'd like it so that there is just the one obvious way to setup OTel -- and that would be via
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ah, I misunderstood the use case then. Using |
||
} | ||
|
||
// Python defines Python SDK and instrumentation configuration. | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,4 @@ | ||||||||||||||||||||
import "./autoinstrumentation.js"; | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @raphael-theriault-swi how does the Related ticket: #3465 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @trentm could you please take a look here? cc) @JamieDanielson There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pavolloffay Are you asking if However, whether to move the operator to using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also add that the The contents of the file could be replaced by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The issue is that, if we keep adding new features here it will be harder to migrate them to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like I mentioned above switching to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pavolloffay Are there any changes you would like to see with regards to the switch |
||||||||||||||||||||
|
||||||||||||||||||||
import { register } from "node:module"; | ||||||||||||||||||||
register("@opentelemetry/instrumentation/hooks.mjs"); | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current code will crash if used on a verison of node that doesn't yet have
An option might be to gracefully warn (untested code):
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the SDK setup a logger for the diag API by default ? If not I'm thinking this should probably be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The NodeSDK sets a DiagConsoleLogger if the Using the diag logger is the intended mechanism for logging by the OTel JS packages, but that doesn't necessarily have to mean that the OTel Operator uses it. I don't have a strong opinion whether the diag logger or |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5666,6 +5666,14 @@ If the former var had been defined, then the other vars would be ignored.<br/> | |
Resources describes the compute resource requirements.<br/> | ||
</td> | ||
<td>false</td> | ||
</tr><tr> | ||
<td><b>useImport</b></td> | ||
<td>boolean</td> | ||
<td> | ||
UseImport overrides the default injected --require flag with an --import flag that supports ESM. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this documentation should be expanded a bit. It is relevant that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's documented in the Dockerfile which is where the related info about |
||
Requires Node.js 18 or later.<br/> | ||
</td> | ||
<td>false</td> | ||
</tr><tr> | ||
<td><b><a href="#instrumentationspecnodejsvolumeclaimtemplate">volumeClaimTemplate</a></b></td> | ||
<td>object</td> | ||
|
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.
The important Node.js feature here is whether
module.register()
is supported and that version range is^18.19.0 || ^20.6.0 || >=22
. It would be good to be specific here, so some user of an earlier minor version of v18 or v20 doesn't expect this to work.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.
Good point