Java memory calculator does not count Datadog JVM agent classes #361
Replies: 3 comments 2 replies
-
Yes, that's likely it. The runtime helpers execute in the same order as the buildpacks, so the Datadog helper won't run till after the memory calculator, which means the memory calculator won't see that the agent is present. The Datadog buildpack is different in this regard compared to some of the other APM buildpacks. It is toggling that at runtime, but others will include it in the JVM options at build time, which is why this memory calculator inspection usually works. I would try setting
when adjusted, that should show up in the output here:
|
Beta Was this translation helpful? Give feedback.
-
Here is the PR that introduce the runtime toggle: paketo-buildpacks/datadog#160. It can give a bit of context about why it was introduce and how (moving from build time injection to runtime).
How would you do that? You would always inject at build time but have the runtime helper to remove it from the
It looks like the Datadog build pack is exposing I would be in favor of fixing the Datadog buildpack rather than trying to solve the memory calculator in a more generic approach, especially since you mention it's a problem specific to the Datadog buildpack as the other APM use build time injection. |
Beta Was this translation helpful? Give feedback.
-
My thought was that if you enabled it at buildtime then it would be permanently enabled for that image. If you don't enable it at buildtime, then you can toggle it on/off at runtime, but you'd have to accept the downside that the memory calculator wouldn't see it and you may need to manually adjust your metaspace limits. The approach you mentioned is interesting. I think it would work, but it would have the downside of over provisioning memory when you disable Datadog at runtime. For example, if we have the buildpack enable the agent at buildtime. The runtime toggle could then remove the agent when you disable it at runtime, however, the memory calculator would have already run at that point so it would have included the agent in it's calculations. I like your approach a little better in that it is more cautious. Slightly over provisioning metaspace doesn't result in a crash, whereas under provisioning it can. The slight adjustment that I would suggest is we make a buildtime default option. So we already have We can then add to the docs, the caveat that the BP_DATADOG_AGENT_ENABLED flag when false causes the memory calculator to underestimate the required metaspace, which may cause app crashes. How does that sound?
Yes, I'm fine with that. I think even if we change things in the memory calculator, we'd still suffer from the buildpack ordering problem. The memory calculator runs before the Datadog agent toggle, so it would not know if you turned that agent on/off. It would only know about what was set at buildtime. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I’m asking for help about a Java application crash when using
paketo-buildpack/datadogdue to the memory calcultor.When using
BP_DATADOG_ENABLEDtoTRUE, Datadog JVM agent is well injected as resource inside the OCI image and as parameter in theJAVA_TOOL_OPTIONSat run time.But I can see when using
BP_DEBUGtoTRUEthat the memory calculator does not take into account the Datadog JVM agent jar file to count its classes:You can see that
agentClassCountis set to0from https://github.com/paketo-buildpacks/libjvm/blob/72a7df779c8ddd1ea128a50b45214e0d1be03307/helper/memory_calculator.go#L131I wonder it could be related to the datadog helper
togglethat append the-javaagent:to theJAVA_TOOL_OPTIONSat runtime? Could it reponsible for the memory calculator to not find out that the Datadog agent is/will be added when the application starts? (sorry I’m not to verse into the buildpack thing, its lifecycle, phases, etc...)But not taking the Datadog JVM agent into account leads to JVM crash when exceeding the MaxMetaspaceSize.
The application I use is a basic (empty) Spring boot application, using Maven as build tool. But that should not have an impact.
Thanks for your help 🙏
Beta Was this translation helpful? Give feedback.
All reactions