mw-0 commented on PR #14231:
URL: https://github.com/apache/cloudstack/pull/14231#issuecomment-7131022962
Hi,
Thanks for this PR. I built it on 4.22 (2 small conflicts) and tested it end
to end on a KVM lab: one management server, then two management servers and two
KVM hosts. We used
OTel Java agent 2.34.0 → Collector → Tempo.
Performance
- With the Java agent attached, every SQL statement becomes a span. They
come from two sources: the agent's JDBC instrumentation, and MySQL
Connector/J's own OpenTelemetry
support, which switches itself on when the agent is present.
- That is ~7,200 spans for one deployVirtualMachine and ~420 for one
listVirtualMachines, about 99 % SQL. An idle management server emits ~36 root
traces/s, mostly background
threads and agent.in/out.* spans with no parent.
- Measured cost vs. no agent (3 rounds; 500 list calls + 10 deploys each):
+13 % API latency, +24 % management server CPU.
- Profiling shows the cost is creating the spans, not exporting them.
- With SQL tracing off (openTelemetry=DISABLED in db.cloud.url.params,
plus OTEL_INSTRUMENTATION_COMMON_DEFAULT_ENABLED=false with only
jetty/servlet/opentelemetry-api/annotations/executors enabled): +2 %
latency, +1 % CPU, with the PR's spans and trace ids kept (the PR alone still
gives 2 traces per deploy,
see below).
Issues found
- A deploy is split into 2 traces. VM work jobs are always started by
AsyncJobMgr-Heartbeat, so each VmWork* becomes a new root. The API job has no
span of its own and hangs
under the already-ended HTTP span.
- Work jobs lose traceid: their async_job.context is NULL. They are
persisted via VmWorkJobDaoImpl, which bypasses the AsyncJobDaoImpl.persist
override.
- Nothing reaches the KVM agent: no spans, and the agent's (traceid:) log
field is always empty. System VMs and the VR get nothing either.
- The trace id is not returned to the caller, and traceid is a different
id from the OTel trace id.
Suggested changes in this PR
1. Store the W3C context (traceparent) with every job, API and work jobs,
at submit. Start a job span with it as an explicit parent at execution, instead
of relying on the
dispatching thread.
2. Document, or ship as the default, the low-overhead configuration above.
Without it, attaching the agent is costly.
3. Don't create agent.in/out.* root spans when there is no parent context.
4. Set traceid to the OTel trace id when a span is active, and return it
(response header / job result).
5. Either drop the agent's (traceid:) log field or populate it.
I have a second PR build on top of this one with fixes above:
- trace context carried in agent Commands, with KVM agent spans for
StartCommand (storage/network/libvirt) and scripts;
- VR script spans, with the trace id in the VR's cloud.log;
- an opt-in Java agent for the SSVM/CPVM, about +80–100 MB RAM each; 512
MB still works;
- context across cluster messages and agent forwarding;
- sampling for background tasks (idle noise 36 → 0.6 traces/s);
- job/agent metrics linked to example traces.
Result: one deployVirtualMachine goes from 2 traces and ~7,200 spans (99 %
SQL, nothing from the agent) to 1 trace of 39 meaningful spans: 15 on the
management server (API job,
work job + queue wait, planner, network, volume, agent commands) and 24 on
the KVM agent (StartCommand breakdown, VR updates, scripts). It works across
management servers, work
jobs, KVM agent, VR and SSVM, also with two management servers and live
migration. Queue waits and slow steps are visible, e.g. a 54 s router start
broken down into the boot
command line, SSH wait and version check. Overhead stays at ~1–2 %. I send
these as small PRs once this one lands, or as patches against your branch if
you prefer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]