Open dsope05 opened 11 months ago
Hey! I can help with this. May I be assigned?
Hey! I can help with this. May I be assigned?
Great! It's yours, thanks for picking this up :slightly_smiling_face:
Hello, any updates on this issue? I've noticed 2x slow down using open telemetry with node and graphql app
Do you happen to have any updates on this issue?
I've encountered the same and according to a stacktrace the problem might be in the incomingRequest
method:
I am not sure if there's much that can be done as it's parsing the request in the Node internal server and that is for some reason very CPU-hungry.
Looks like it is produce big event loop lag in otl operations, but Im not sure. So I have prometeus metrics on nodejs app, and got screenshot:
In left side tracing enabled, then I just disable it and we see different image on right side. (I have 6 replica of app in kubernates running, that why we see many lines)
Some details about my code. It is Koa app and in Index file I have code like:
if (env.TRACING_ENABLED) {
app.use(async (ctx, next) => {
const tracer = trace.getTracer("myapp");
const span = tracer.startSpan("http_request", {
attributes: {
"http.method": ctx.method,
"http.path": ctx.path,
},
});
try {
await next();
span.setAttribute("http.status_code", ctx.status);
} catch (err) {
span.recordException(err);
span.setAttribute("http.status_code", 500);
throw err;
} finally {
span.end();
}
});
}
My tracing initialization like:
const traceExporter = new OTLPTraceExporter({
url: env.TRACING_URL,
compression: CompressionAlgorithm.GZIP,
});
const sdk = new NodeSDK({
resource: new Resource({
[ATTR_SERVICE_NAME]: env.SERVICE_NAME,
[ATTR_SERVICE_VERSION]: env.VERSION,
}),
traceExporter,
instrumentations: [
getNodeAutoInstrumentations({
"@opentelemetry/instrumentation-koa": {
requestHook: (span, info) => {
info.context.set("X-Request-Id", span.spanContext().traceId);
},
},
}),
new WinstonInstrumentation(),
new BullMQInstrumentation(),
new UndiciInstrumentation(), // for FetchAPI
new SequelizeInstrumentation(),
],
});
try {
sdk.start();
} catch (err) {
console.error(`Error starting OpenTelemetry SDK`, err);
}
Also I think GZIP can affect on load. In next I will try disable GZIP and see what happen.
So yes. Problem in GZIP. I just disable it
@WilixLead nice find but with default configuration, the compression is set to NONE so it's probably not the only thing causing this. See https://github.com/open-telemetry/opentelemetry-js/blob/6515ed8098333646a63a74a8c0150cc2daf520db/experimental/packages/otlp-grpc-exporter-base/src/util.ts#L154
I know :) Just we use example founded in Internet with compression. Copy-paste coding...
I'm not sure the performance issues are limited to HTTP. Seeing as much as a ~40% decrease in requests p/ second on an express.js app. Disabling HTTP doesn't have much of an effect for me.
What happened?
Steps to Reproduce
create a server running on main thread, offloads requests to node worker threads. implement open telemetry on main thread, requests/sec is reduced by 80% when http-instrumentation is applied to the main thread.
Expected Result
http-instrumentation shouldn't decrease performance by 80% when implemented.
Actual Result
http-instrumentation decreases requests/second performance by 80%
Additional Details
OpenTelemetry Setup Code
package.json
Relevant log output
No response