-
Notifications
You must be signed in to change notification settings - Fork 26.5k
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
The with-opentelemetry
example doesn't send telemetry data
#61975
Comments
with-opentelemetry
doesn't send telemetry datawith-opentelemetry
example doesn't send telemetry data
I resolved the problem by calling registerOTel as follows. import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-node";
import { registerOTel } from "@vercel/otel";
export function register() {
registerOTel({
serviceName: "next-app",
spanProcessors: [new SimpleSpanProcessor(new OTLPTraceExporter())],
});
} Is this a @vercel/otel issue? Or is it a documentation/example issue? |
I can confirm that I had the same issue, it does not work as described in setup documentation. @YunosukeY solution worked. |
Setting the following env vars worked for me. OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: "http://jaeger-hostname:4318/v1/traces"
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: "http/protobuf" I also found the following env-variable to be immensely useful: OTEL_LOG_LEVEL=debug |
Thanks @iaraknes! In my case, I was able to add the following env var and that worked for me:
I'm surprised this is not used by default, as documented in: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#configuration-options Also, manual instrumentation with @opentelemetry libraries works fine without this env variable. It's only @vercel/otel requiring this env var to be set. |
Which project did you set this in? the collector or the nextjs app? |
Do you have a screenshot on what to expect via jaeger UI? I'm not seeing anything wth the serviceName, so I'm unsure if I just set it up incorrectly |
I set it in the nextjs app. |
I was following the official documentation here: https://nextjs.org/docs/pages/building-your-application/optimizing/open-telemetry#testing-your-instrumentation It didn't work with any newer versions. Only |
Ah okay! I figured it out, so I was using this docker-compose from Vercel (https://github.com/vercel/opentelemetry-collector-dev-setup) and it exposes it on localhost. I changed it to these values and the newer version worked! Thank you! OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="http://localhost:4318/v1/traces"
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"
OTEL_LOG_LEVEL=debug |
I am on |
I should note: the default spans I experienced were in the page router |
Annoyingly using the normal SDK does not report more than 1 span either 😢 |
Tried to follow @YunosukeY 's solution, but got this. Does anyone else experience this?
|
It's being caused by the middleware |
Yes I'm experiencing the same behaviour. Have you found a solution @sudowoodo200? |
I assume this is the case because the instrumentation is running as middleware in the edge runtime. Which doesn't have access to these Node API's. It is also discussed in this issue: #59413 (comment). |
I can also confirm this fixed the issue for me. Thank you! What I don't understand, is why this works when running the Next app outside of Docker. When I run it with next dev in my terminal, I don't need to set these environment variables. |
We had issues sending custom spans, which seemed to be resolved by aligning the
"overrides": {
"@opentelemetry/api": "^1.9.0"
}
export async function register() {
registerOTel({
serviceName: "my-app",
});
} Then custom spans started appearing alongside the base ones using |
So I have the same issue as everyone here. My register looks like this: export function register() {
registerOTel({
serviceName: 'rh-micro-apps',
instrumentationConfig: {
fetch: {
propagateContextUrls: ['example.com'],
},
},
propagators: ['tracecontext', 'baggage'],
traceSampler: 'always_on',
})
} and I used these environment variables for local development and testing: OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317"
OTEL_EXPORTER_OTLP_PROTOCOL="grpc" This setup works with a locally running jaeger all in one and it seems the env vars are registered correctly because I can see inside the jaeger logs that the spans/traces come in via GRPC. I was also able to send them to a remote machine so they definitely work during development. But once I build a production container I will not receive any traces under any circumstances whatsoever. Thanks to @iaraknes I found out about the They work for local The debug log seem to indicate that spans are still send to
The Dockerfile looks like this (which is heavily based on https://github.com/vercel/next.js/blob/main/examples/with-docker/Dockerfile): FROM node:lts-alpine AS base
FROM base AS builder
WORKDIR /app
COPY . .
RUN corepack enable && yarn install
RUN yarn build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
RUN mkdir .next
RUN chown nextjs:nodejs .next
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
CMD ["node", "server.js"]
|
So after a bit more digging around I found out GRPC is actually not supported. If you are using a slightly invalid configuration it will fallback to default only indicated if you turn on
Also do not use the full path for All of this is not visible with the default log level so maybe it would be a good idea to log something like this in warning message instead of debug. |
Verify canary release
Provide environment information
Which example does this report relate to?
with-opentelemetry
What browser are you using? (if relevant)
Microsoft Edge for Business Version 121.0.2277.112 (Official build) (arm64)
How are you deploying your application? (if relevant)
yarn dev
Describe the Bug
The example doesn't send telemetry data.
This looks like a
@vercel/otel
bug.I confirmed by adding
@vercel/otel
to my Next.js application without the example and it didn't send telemetry data as well.https://nextjs.org/docs/app/building-your-application/optimizing/open-telemetry#using-vercelotel
I also confirmed that telemetry data is sent with manual configuration.
In this case default spans are sent.
https://nextjs.org/docs/app/building-your-application/optimizing/open-telemetry#manual-opentelemetry-configuration
Expected Behavior
The example send telemetry data with
@vercel/otel
.To Reproduce
opentelemetry-collector-dev-setup
as a preparation.The text was updated successfully, but these errors were encountered: