From c46f4605273fa04ba11aa960eafd688cc13d4415 Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Wed, 23 Jun 2021 14:22:04 +0100 Subject: [PATCH 1/4] Add cloud profiler to Docker image --- services/git-bridge/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/git-bridge/Dockerfile b/services/git-bridge/Dockerfile index 0c28bfe5fa..fb8e88de48 100644 --- a/services/git-bridge/Dockerfile +++ b/services/git-bridge/Dockerfile @@ -28,6 +28,10 @@ FROM openjdk:11-jre RUN apt-get update && apt-get install -y git sqlite3 procps htop net-tools sockstat \ && rm -rf /var/lib/apt/lists +RUN mkdir -p /opt/cprof && \ + wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent.tar.gz \ + | tar xzv -C /opt/cprof + RUN useradd --create-home node COPY --from=builder /git-bridge.jar / From a469bc673247d12611e068d134f4f8522c833da3 Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Wed, 23 Jun 2021 14:58:25 +0100 Subject: [PATCH 2/4] Add parameters to enable profile agent to startup script --- services/git-bridge/start.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/git-bridge/start.sh b/services/git-bridge/start.sh index bb4dd362be..7dea17df8a 100755 --- a/services/git-bridge/start.sh +++ b/services/git-bridge/start.sh @@ -1,8 +1,13 @@ #!/bin/bash + /opt/envsubst < /envsubst_template.json > /conf/runtime.json if [ "x$GIT_BRIDGE_JVM_ARGS" == "x" ]; then GIT_BRIDGE_JVM_ARGS="-XX:+UseContainerSupport -XX:MaxRAMPercentage=50.0" fi +if [ "$ENABLE_PROFILE_AGENT" == "true" ]; then + GIT_BRIDGE_JVM_ARGS="-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=git-bridge,-cprof_service_version=1.0.0,-cprof_enable_heap_sampling=true ${GIT_BRIDGE_JVM_ARGS}" +fi + exec java $GIT_BRIDGE_JVM_ARGS -jar /git-bridge.jar /conf/runtime.json From 9c8ff2f02221a9c32fcb5c80cac0932969a6cfbd Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Wed, 23 Jun 2021 14:58:49 +0100 Subject: [PATCH 3/4] Add cloud debug agent to Docker image --- services/git-bridge/Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/git-bridge/Dockerfile b/services/git-bridge/Dockerfile index fb8e88de48..9de0342f0b 100644 --- a/services/git-bridge/Dockerfile +++ b/services/git-bridge/Dockerfile @@ -28,10 +28,16 @@ FROM openjdk:11-jre RUN apt-get update && apt-get install -y git sqlite3 procps htop net-tools sockstat \ && rm -rf /var/lib/apt/lists +# Install Google Cloud Profiler agent RUN mkdir -p /opt/cprof && \ wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent.tar.gz \ | tar xzv -C /opt/cprof +# Install Google Cloud Debugger agent +RUN mkdir /opt/cdbg && \ + wget -qO- https://storage.googleapis.com/cloud-debugger/compute-java/debian-wheezy/cdbg_java_agent_gce.tar.gz | \ + tar xvz -C /opt/cdbg + RUN useradd --create-home node COPY --from=builder /git-bridge.jar / From 72233ec334185545f2ddd903d7a4ab35bc513eb6 Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Wed, 23 Jun 2021 15:05:21 +0100 Subject: [PATCH 4/4] Add parameters to enable debug agent to startup script --- services/git-bridge/start.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/git-bridge/start.sh b/services/git-bridge/start.sh index 7dea17df8a..47547ae8b6 100755 --- a/services/git-bridge/start.sh +++ b/services/git-bridge/start.sh @@ -10,4 +10,8 @@ if [ "$ENABLE_PROFILE_AGENT" == "true" ]; then GIT_BRIDGE_JVM_ARGS="-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=git-bridge,-cprof_service_version=1.0.0,-cprof_enable_heap_sampling=true ${GIT_BRIDGE_JVM_ARGS}" fi +if [ "$ENABLE_DEBUG_AGENT" == "true" ]; then + GIT_BRIDGE_JVM_ARGS="-agentpath:/opt/cdbg/cdbg_java_agent.so -Dcom.google.cdbg.module=git-bridge -Dcom.google.cdbg.version=$(date +%y%m%d%H%M%S) ${GIT_BRIDGE_JVM_ARGS}" +fi + exec java $GIT_BRIDGE_JVM_ARGS -jar /git-bridge.jar /conf/runtime.json