Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_j
```

See the
[Google Cloud Profiler Profiler Java profiling doc](https://cloud.google.com/profiler/docs/profiling-java)
[Google Cloud Profiler Java profiling doc](https://cloud.google.com/profiler/docs/profiling-java)
for detailed and most up-to-date guide on installing and using the agent.

## Build from Source
Expand All @@ -30,6 +30,8 @@ commands below.

## To build for Alpine.

**Only Alpine versions 3.11 and later are currently supported.**

**Per thread timers are not available on Alpine.** Since SIGEV_THREAD_ID is not
supported by `timer_create` on Alpine, per thread timers are not implemented and
the flag `-cprof_cpu_use_per_thread_timers` is ignored on this platform.
Expand Down
15 changes: 12 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,23 @@ set -o nounset
#
# Command line arguments: [-d]
# -d: specify the temporary directory for the build.
# -v: the version for this build of the agent.

ALPINE_BUILD="0"
DOCKERFILE="Dockerfile"
FILE_SUFFIX=""
while getopts ":ad:" opt; do
while getopts ":ad:v:" opt; do
case $opt in
a)
ALPINE_BUILD="1"
FILE_SUFFIX="_alpine"
;;
d)
BUILD_TEMP_DIR=$OPTARG
;;
v)
VERSION=$OPTARG
;;
:)
echo "Missing option argument for -$OPTARG" >&2;
exit 1
Expand All @@ -44,6 +49,10 @@ while getopts ":ad:" opt; do
esac
done

if [[ -z "${VERSION-}" ]]; then
VERSION="github${FILE_SUFFIX}:$(git rev-parse HEAD || echo "unknown")"
fi

if [[ -z "${BUILD_TEMP_DIR-}" ]]; then
RUN_ID="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
BUILD_TEMP_DIR="/tmp/${RUN_ID}"
Expand All @@ -66,7 +75,6 @@ mkdir -p "${BUILD_TEMP_DIR}"
if [[ "${ALPINE_BUILD}" = "1" ]]; then
PrintMessage "Building the builder Alpine Docker container..."
DOCKERFILE="Dockerfile.alpine"
FILE_SUFFIX="_alpine"
else
PrintMessage "Building the builder Docker container..."
fi
Expand All @@ -80,7 +88,8 @@ PrintMessage "Building the agent..."
docker run -ti -v "${BUILD_TEMP_DIR}/build":/root/build \
cprof-agent-builder bash \
-c \
"cd ~/build && tar xvf src.tar && make -f Makefile all" \
"cd ~/build && tar xvf src.tar && make -f Makefile all \
AGENT_VERSION=${VERSION}" \
>> "${LOG_FILE}" 2>&1

PrintMessage "Packaging the agent binaries..."
Expand Down
9 changes: 5 additions & 4 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@
#include <jni.h>
#include <jvmti.h>
#include <stdint.h>

#include <unordered_map>

#include "third_party/javaprofiler/jvmti_error.h"
#include "third_party/javaprofiler/stacktraces.h"

#ifndef CLOUD_PROFILER_AGENT_VERSION
#define CLOUD_PROFILER_AGENT_VERSION "unknown"
#endif

#include <glog/logging.h>

#include <string>
Expand All @@ -46,6 +43,10 @@ using std::string; // ALLOW_STD_STRING
TypeName(); \
DISALLOW_COPY_AND_ASSIGN(TypeName)

#ifndef CLOUD_PROFILER_AGENT_VERSION
#define CLOUD_PROFILER_AGENT_VERSION "unknown"
#endif

namespace cloud {
namespace profiler {

Expand Down
Loading