Open ademartini-czi opened 1 month ago
I am seeing this too. since 0.53 incoming/outgoing are not longer instrumented. The opt-opt/in properties appear to not change behaviour. Rolling back to 0.52.0 the span on incoming/outcoming requests work again
At a stab, something in this PR seems to have changed behaviour https://github.com/open-telemetry/opentelemetry-js/pull/4643
RemixInstrumentation Module @remix-run/server-runtime has been loaded before RemixInstrumentation so it might not work, please initialize it before requiring @remix-run/server-runtime
This is most likely the problem. Because Remix is required before the instrumentation is initialized, it is already in the cache. We instrument by intercepting the require
. If we can't do that, there is no way for us to instrument a module reliably.
And @opentelemetry/instrumentation-http doesn't seem to produce anything on its own either. Maybe Remix isn't using node HTTP?
I'm not sure, I don't know anything about Remix. If it used fetch
or undici
it would not use http
. It seems somewhat likely this is the issue. There is an undici
instrumentation that might fix that part.
An option might be to initialize OpenTelemetry in a separate file and then set NODE_OPTIONS="--require ./my-otel-setup-file.js"
.
And @opentelemetry/instrumentation-http doesn't seem to produce anything on its own either. Maybe Remix isn't using node HTTP?
I quickly played with a Remix app (via npx create-remix@latest
).
npm run build
NODE_DEBUG=http npm start
curl -i http://localhost:3000 # to hit the Remix service
Using NODE_DEBUG=http
, you can see that the http
module is being used.
Then I did:
npm install @opentelemetry/auto-instrumentations-node
NODE_OPTIONS=--require=@opentelemetry/auto-instrumentations-node/register OTEL_TRACES_EXPORTER=console OTEL_NODE_DISABLED_INSTRUMENTATIONS=fs OTEL_NODE_RESOURCE_DETECTORS=none npm start
curl -i http://localhost:3000 # to hit the Remix service
(The OTEL_NODE_DISABLED_INSTRUMENTATIONS=fs OTEL_NODE_RESOURCE_DETECTORS=none
is to reduce some of the noise that isn't relevant here.)
The result is that you can see HTTP spans being created, so it is possible here.
Ahh, I just saw this in the package.json
you posted above:
"type": "module",
When running it, do you add the ESM loader hook when calling the node
executable? See this doc for details.
Just to add a little context in case it was missed
Single fetch in remix (whicb will be the default in remix v3/react-router v7, and I’m guessing that’s what the author of this is setup with) you are most certainly using undici under the hood
@trentm I'm guessing the reason you see HTTP being used in your experiment is because you are running a vanilla remix setup and havn’t setup single fetch
Given this, I’m curious what it would actually take to correctly instrument a remix app using undici?
instrument a remix app using undici?
I think this one may be a separate question from the original post, but could be related. For undici there is a specific undici instrumentation that should be used, not just the http instrumentation.
The auto-instrumentations-node package can be used directly to include all packages (getNodeAutoInstrumentations()
) instead of specifying individual instrumentations, which might help see what else gets picked up. Or add in new UndiciInstrumentation()
to the list of instrumentations.
One thing to check is whether this single_fetch is enabled
, which suggests that undici will be used.
@ademartini-czi Is this still an issue for you? If so, if you could provide enough code to fully reproduce what you are seeing, that would help us to identify what you are hitting.
I got Honeycomb working just by placing the telemetry code into app/entry.client.tsx
. You should try there.
What happened?
Steps to Reproduce
Is it possible to automatically instrument HTTP incoming and outgoing spans when using Remix 2? I'm trying to do this with a regular auto-generated Remix 2 app (
npx create-remix@latest
). I'm running the latest (2.12.0) with both"@opentelemetry/instrumentation-http": "^0.53.0"
and"opentelemetry-instrumentation-remix": "^0.7.1"
and it doesn't seem to create any spans. It only works if I start manually making spans in my routes.I know the remix instrumentation library isn't working because it keeps saying:
RemixInstrumentation Module @remix-run/server-runtime has been loaded before RemixInstrumentation so it might not work, please initialize it before requiring @remix-run/server-runtime
. And@opentelemetry/instrumentation-http
doesn't seem to produce anything on its own either. Maybe Remix isn't using node HTTP?Expected Result
It should be possible to automatically create trace spans for incoming/outgoing HTTP without pain using Remix V2.
Actual Result
No spans unless I manually create them.
Additional Details
OpenTelemetry Setup Code
Relevant log output
No response