From 876d4f966f842facdf00a8640ab6e06e3f0337fe Mon Sep 17 00:00:00 2001 From: Kalyana Chadalavada Date: Wed, 8 May 2019 19:31:33 -0700 Subject: [PATCH] Add Stackdriver Profiler Java agent to adservice (#210) * Add Stackdriver Profiler Java agent to adservice. * Add Stackdriver Profiler Java agent to adservice. --- src/adservice/Dockerfile | 11 +++++++++-- src/adservice/build.gradle | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/adservice/Dockerfile b/src/adservice/Dockerfile index 34c6e33..95fb32c 100644 --- a/src/adservice/Dockerfile +++ b/src/adservice/Dockerfile @@ -11,9 +11,16 @@ COPY . . RUN chmod +x gradlew RUN ./gradlew installDist -FROM openjdk:8-alpine +FROM openjdk:8-slim -RUN apk add --no-cache libc6-compat +# Download Stackdriver Profiler Java agent +RUN apt-get -y update && apt-get install -qqy \ + wget \ + && 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 && \ + rm -rf profiler_java_agent.tar.gz RUN GRPC_HEALTH_PROBE_VERSION=v0.2.1 && \ wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ diff --git a/src/adservice/build.gradle b/src/adservice/build.gradle index dde9248..2341951 100644 --- a/src/adservice/build.gradle +++ b/src/adservice/build.gradle @@ -118,7 +118,8 @@ task adService(type: CreateStartScripts) { outputDir = new File(project.buildDir, 'tmp') classpath = jar.outputs.files + project.configurations.runtime defaultJvmOpts = - ["-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector"] + ["-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector", + "-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=adservice,-cprof_service_version=1.0.0"] } task adServiceClient(type: CreateStartScripts) { @@ -127,7 +128,8 @@ task adServiceClient(type: CreateStartScripts) { outputDir = new File(project.buildDir, 'tmp') classpath = jar.outputs.files + project.configurations.runtime defaultJvmOpts = - ["-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector"] + ["-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector", + "-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=adserviceclient,-cprof_service_version=1.0.0"] } applicationDistribution.into('bin') {