diff --git a/.github/workflows/webserver.yml b/.github/workflows/webserver.yml index 30056d47..a03b735e 100644 --- a/.github/workflows/webserver.yml +++ b/.github/workflows/webserver.yml @@ -57,6 +57,76 @@ jobs: rm -rf /tmp/buildx-cache/apache_ubuntu mv /tmp/buildx-cache/apache_ubuntu-new /tmp/buildx-cache/apache_ubuntu + webserver-build-test-ubuntu-arm64: + name: webserver-ubuntu-build-arm64 + runs-on: ubuntu-20.04 + steps: + - name: checkout otel webserver + uses: actions/checkout@v3 + - name: setup qemu + uses: docker/setup-qemu-action@master + - name: setup buildx + id: buildx + uses: docker/setup-buildx-action@master + with: + install: true + platforms: linux/arm64 + - name: cache docker layers + uses: actions/cache@v3 + with: + path: /tmp/buildx-cache/ + key: apache-ubuntu-20.04-${{ github.sha }} + restore-keys: | + apache-ubuntu-20.04 + - name: setup docker image + run: | + cd instrumentation/otel-webserver-module + docker buildx build -t apache_ubuntu_arm64 -f docker/ubuntu20.04-arm64/Dockerfile \ + --cache-from type=local,src=/tmp/buildx-cache/apache_ubuntu_arm64 \ + --cache-to type=local,dest=/tmp/buildx-cache/apache_ubuntu_arm64-new \ + --load . --platform linux/arm64 + - name: build + run: | + docker run -idt --platform linux/arm64 --name apache_ubuntu_container_arm64 apache_ubuntu_arm64 /bin/bash + cd instrumentation/otel-webserver-module + docker exec apache_ubuntu_container_arm64 bash -c \ + 'cd /otel-webserver-module; rm -rf *;' + docker cp . $(docker inspect --format="{{.Id}}" apache_ubuntu_container_arm64):/otel-webserver-module/ + docker exec apache_ubuntu_container_arm64 bash -c \ + 'cd /otel-webserver-module; rm -rf build; \ + cp -r /dependencies /otel-webserver-module/; \ + cp -r /build-dependencies /otel-webserver-module/; \ + + ./gradlew assembleWebServerModule -DtargetSystem=ubuntu' + # - name: unit test + # run: | + # docker exec apache_ubuntu_container_arm64 bash -c \ + # 'cd /otel-webserver-module; ./gradlew runUnitTest' + - name: update cache + run: | + rm -rf /tmp/buildx-cache/apache_ubuntu_arm64 + mv /tmp/buildx-cache/apache_ubuntu_arm64-new /tmp/buildx-cache/apache_ubuntu_arm64 + # - name: copy artifacts + # id: artifacts + # run: | + # cd instrumentation/otel-webserver-module + # mkdir -p /tmp/apache_ubuntu_arm64/ + # docker cp apache_ubuntu_container_arm64:/otel-webserver-module/build/opentelemetry-webserver-sdk-arm64-linux.tgz \ + # /tmp/apache_ubuntu_arm64/ + # - name: upload artifacts + # uses: actions/upload-artifact@v3 + # with: + # name: opentelemetry-webserver-sdk-arm64-linux.tgz + # path: /tmp/apache_ubuntu_arm64/opentelemetry-webserver-sdk-arm64-linux.tgz + # - name: run integrationtest + # run: | + # docker rm -f apache_ubuntu_container_arm64 + # cd instrumentation/otel-webserver-module + # docker compose --profile ubuntu20.04 up -d + # docker ps -a + # sleep 30 + # ./gradlew :test:integration:integrationTests -i + webserver-build-test-centos7: name: webserver-centos7-build runs-on: ubuntu-20.04 @@ -116,7 +186,74 @@ jobs: run: | docker rm -f apache_centos7_container cd instrumentation/otel-webserver-module - docker-compose --profile centos7 up -d + docker compose --profile centos7 up -d + docker ps -a + sleep 30 + ./gradlew :test:integration:integrationTests -i + + webserver-build-test-centos7-arm64: + name: webserver-centos7-build-arm64 + runs-on: ubuntu-20.04 + steps: + - name: checkout otel webserver + uses: actions/checkout@v3 + - name: setup qemu + uses: docker/setup-qemu-action@master + - name: setup buildx + id: buildx + uses: docker/setup-buildx-action@master + with: + install: true + platforms: linux/arm64 + # - name: cache docker layers + # uses: actions/cache@v3 + # with: + # path: /tmp/buildx-cache/ + # key: apache-centos7-${{ github.sha }} + # restore-keys: | + # apache-centos7 + - name: setup docker image + run: | + cd instrumentation/otel-webserver-module + docker buildx build -t apache_centos7_arm64 -f docker/centos7-arm64/Dockerfile \ + --load . --platform linux/arm64 + - name: build + run: | + docker run -idt --platform linux/arm64 --name apache_centos7_container_arm64 apache_centos7_arm64 /bin/bash + cd instrumentation/otel-webserver-module + docker exec apache_centos7_container_arm64 bash -c \ + 'cd /otel-webserver-module; rm -rf *;' + docker cp . $(docker inspect --format="{{.Id}}" apache_centos7_container_arm64):/otel-webserver-module/ + docker exec apache_centos7_container_arm64 bash -c \ + 'cd /otel-webserver-module; rm -rf build; \ + cp -r /dependencies /otel-webserver-module/; \ + cp -r /build-dependencies /otel-webserver-module/; \ + ./gradlew assembleWebServerModule' + - name: unit test + run: | + docker exec apache_centos7_container_arm64 bash -c \ + 'cd /otel-webserver-module; ./gradlew runUnitTest' + # - name: update cache + # run: | + # rm -rf /tmp/buildx-cache/apache_centos7_arm64 + # mv /tmp/buildx-cache/apache_centos7_arm64-new /tmp/buildx-cache/apache_centos7_arm64 + - name: copy artifacts + id: artifacts + run: | + cd instrumentation/otel-webserver-module + mkdir -p /tmp/apache_centos7_arm64/ + docker cp apache_centos7_container_arm64:/otel-webserver-module/build/opentelemetry-webserver-sdk-arm64-linux.tgz \ + /tmp/apache_centos7_arm64/ + - name: upload artifacts + uses: actions/upload-artifact@v3 + with: + name: opentelemetry-webserver-sdk-arm64-linux.tgz + path: /tmp/apache_centos7_arm64/opentelemetry-webserver-sdk-arm64-linux.tgz + - name: run integrationtest + run: | + docker rm -f apache_centos7_container_arm64 + cd instrumentation/otel-webserver-module + docker compose --profile centos7 up -d docker ps -a sleep 30 ./gradlew :test:integration:integrationTests -i diff --git a/instrumentation/otel-webserver-module/build.gradle b/instrumentation/otel-webserver-module/build.gradle index 5f8ea4a4..61c232a3 100644 --- a/instrumentation/otel-webserver-module/build.gradle +++ b/instrumentation/otel-webserver-module/build.gradle @@ -23,7 +23,7 @@ project.ext { ansdkOsName = osName ansdkArch = (osArch == 'x86' ? 'i686' : osArch) - gccArchFlag = (osArch == 'x86' ? '-m32' : '-m64') + gccArchFlag = (osArch == 'x86' ? '-m32' : (osArch == 'arm64' ? '-march=armv8-a' : '-m64')) headSHA1 = "" try { @@ -499,7 +499,7 @@ task gypUnitTest(type: Exec) { ANSDK_DIR: modDepDir, BOOST_LIB: BOOST_LIB, BOOST_INCLUDE: BOOST_INCLUDE, - GTEST_LIB_DIR: target_system == "ubuntu" ? + GTEST_LIB_DIR: target_system == "ubuntu" || osArch == "arm64" ? "${modDepDir}/googletest/1.10.0/lib" : "${modDepDir}/googletest/1.10.0/lib64", LIBRARY_FLAGS: libraryFlags, CPP_SDK_VERSION: cppSDKVersion, @@ -536,7 +536,7 @@ task runApacheServer(type: Exec) { dependsOn assembleApacheModule workingDir 'test' - commandLine './ApacheTesting.sh', "${target_system}" + commandLine './ApacheTesting.sh', "${target_system}", "${osArch}" } // Code Coverage @@ -602,6 +602,9 @@ model { release } platforms { + arm { + architecture "arm64" + } x86 { architecture "x86" } diff --git a/instrumentation/otel-webserver-module/common.gradle b/instrumentation/otel-webserver-module/common.gradle index cc570776..da9323c6 100644 --- a/instrumentation/otel-webserver-module/common.gradle +++ b/instrumentation/otel-webserver-module/common.gradle @@ -8,6 +8,9 @@ defaultTasks 'build' ext { ARCH = '' switch (System.properties['os.arch'].toLowerCase()) { + case "aarch64": + ARCH = "arm64" + break case "amd64": case "x86_64": ARCH = "x64" @@ -42,6 +45,8 @@ ext { osArch = 'x86' } else if (osArch == 'x86_64' || osArch == 'amd64') { osArch = 'x64' + } else if (osArch == 'aarch64') { + osArch = 'arm64' } BUILD_SHA1 = System.getenv('BUILD_SHA') diff --git a/instrumentation/otel-webserver-module/docker-compose.yml b/instrumentation/otel-webserver-module/docker-compose.yml index 6c35ac6a..f6f15104 100644 --- a/instrumentation/otel-webserver-module/docker-compose.yml +++ b/instrumentation/otel-webserver-module/docker-compose.yml @@ -29,6 +29,22 @@ services: - "9004:80" depends_on: - otel-collector + webserver_centos7-arm64: + build: + context: . + dockerfile: docker/centos7-arm64/Dockerfile + platforms: + - "linux/arm64" + image: apache_centos7_arm64 + hostname: webserver + container_name: webserver_centos7_arm64 + command: bash -c " httpd -k start && tail -f /dev/null " + profiles: + - centos7 + ports: + - "9004:80" + depends_on: + - otel-collector webserver_ubuntu: build: context: . @@ -43,6 +59,22 @@ services: - "9000:80" depends_on: - otel-collector + webserver_ubuntu-arm64: + build: + context: . + dockerfile: docker/ubuntu20.04-arm64/Dockerfile + platforms: + - "linux/arm64" + image: apache_ubuntu_arm64 + hostname: webserver + container_name: webserver_ubuntu_arm64 + command: bash -c "apache2ctl -k start && tail -f /dev/null " + profiles: + - ubuntu20.04 + ports: + - "9000:80" + depends_on: + - otel-collector nginx_centos: build: context: . @@ -71,6 +103,22 @@ services: - "8012:80" depends_on: - otel-collector + nginx_centos7-arm64: + build: + context: . + dockerfile: docker/centos7/Dockerfile + platforms: + - "linux/arm64" + image: nginx_centos7_arm64 + hostname: webserver + container_name: nginx_centos7_arm64 + command: bash -c "export LD_LIBRARY_PATH=/opt/opentelemetry-webserver-sdk/sdk_lib/lib && nginx && tail -f /dev/null" + profiles: + - centos7_nginx + ports: + - "8012:80" + depends_on: + - otel-collector nginx_ubuntu: build: context: . @@ -85,6 +133,22 @@ services: - "8016:80" depends_on: - otel-collector + nginx_ubuntu-arm64: + build: + context: . + dockerfile: docker/ubuntu20.04-arm64/Dockerfile + platforms: + - "linux/arm64" + image: nginx_ubuntu_arm64 + hostname: webserver + container_name: nginx_ubuntu_arm64 + command: bash -c "export LD_LIBRARY_PATH=/opt/opentelemetry-webserver-sdk/sdk_lib/lib && nginx && tail -f /dev/null" + profiles: + - ubuntu20.04_nginx + ports: + - "8016:80" + depends_on: + - otel-collector # Collector diff --git a/instrumentation/otel-webserver-module/docker/centos7-arm64/Dockerfile b/instrumentation/otel-webserver-module/docker/centos7-arm64/Dockerfile new file mode 100644 index 00000000..d02fafb1 --- /dev/null +++ b/instrumentation/otel-webserver-module/docker/centos7-arm64/Dockerfile @@ -0,0 +1,304 @@ +FROM centos:7 + +ARG BUILD_NUMBER + +LABEL NAME=apm/build-image-webserver-agent-centos6-arm64 VERSION=$BUILD_NUMBER + +ENV GOSU_ARCH='arm64' +ENV JDK_ARCH='aarch64' + +ARG PYTHON_VERSION="2.7.18" +ARG CMAKE_VERSION="3.20" +ARG CMAKE_0VERSION="3.20.0" +ARG GRPC_VERSION="1.36.4" +ARG OPENTELEMETRY_VERSION="1.2.0" +ARG BOOST_VERSION="1.75.0" +ARG BOOST_FILENAME="boost_1_75_0" +ARG APR_VERSION="1.7.0" +ARG EXPAT_VERSION="2.3.0" +ARG EXPAT_RVERSION="R_2_3_0" +ARG APRUTIL_VERSION="1.6.1" +ARG AUTOCONF_VERSION="2.68" +ARG LIBTOOL_VERSION="2.4.6" +ARG LOG4CXX_VERSION="0.11.0" +ARG GTEST_VERSION="1.10.0" +ARG AUTOMAKE_VERSION="1.16.3" +ARG PERL_VERSION="5.20.2" +ARG PERL_CPANVERSION="5.0" +ARG PCRE_VERSION="8.44" +ARG NGINX_VERSION="1.26.0" + +# create default non-root user +RUN groupadd -r swuser && useradd -u 1000 -g swuser -m -s /sbin/nologin -c "default non-root user" swuser + +RUN chmod -R 777 /opt + +# RUN curl https://www.getpagespeed.com/files/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo + +# install required packages +RUN yum update -y \ + && yum install -y \ + yum install wget -y \ + yum install -y zlib-devel \ + yum install -y openssl-devel \ + yum install java-1.8.0-openjdk -y \ + yum install pcre-devel -y \ + yum install xz -y \ + yum install httpd -y \ + && yum clean all + +# install lcov package +RUN wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ + && yum install ./epel-release-latest-*.noarch.rpm -y \ + && yum install lcov -y \ + && yum clean all + +# install devtoolset toolchain +# RUN curl https://www.getpagespeed.com/files/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo \ +# && curl https://www.getpagespeed.com/files/centos6-epel-eol.repo --output /etc/yum.repos.d/epel.repo \ +RUN yum -y install centos-release-scl \ + # && curl https://www.getpagespeed.com/files/centos6-scl-eol.repo --output /etc/yum.repos.d/CentOS-SCLo-scl.repo \ + # && curl https://www.getpagespeed.com/files/centos6-scl-rh-eol.repo --output /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo \ + && yum install yum-utils -y \ + && yum-config-manager --enable rhel-server-rhscl-7-rpms -y \ + && yum install devtoolset-7 -y \ + && yum clean all +ENV PATH="/opt/rh/devtoolset-7/root/usr/bin:${PATH}" + +# install python +RUN wget http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz \ + && unxz Python-${PYTHON_VERSION}.tar.xz \ + && tar -xf Python-${PYTHON_VERSION}.tar \ + && cd Python-${PYTHON_VERSION} && ./configure --prefix=/usr/local && make && make install \ + && cd .. \ + && rm -rf Python-${PYTHON_VERSION}.tar.xz && rm -rf Python-${PYTHON_VERSION}.tar + +# install gosu for easy step-down from root (from https://github.com/tianon/gosu/blob/master/INSTALL.md#from-centos) +ENV GOSU_VERSION=1.11 +#RUN gpg --keyserver pgp.mit.edu --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ +# && curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-arm64" \ +# && curl -o /usr/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-arm64.asc" \ +# && gpg --verify /usr/bin/gosu.asc \ +# && rm /usr/bin/gosu.asc \ +# && rm -r /root/.gnupg/ \ +RUN curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-arm64" \ + && chmod +x /usr/bin/gosu \ + # Verify that the binary works + && gosu nobody true + +# install git required for grpc +RUN yum install git -y \ + && yum clean all + +# install cmake 3.20 +RUN wget https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_0VERSION}-linux-aarch64.tar.gz \ + && tar -xvf cmake-${CMAKE_0VERSION}-linux-aarch64.tar.gz \ + && cd cmake-${CMAKE_0VERSION}-linux-aarch64 \ + && cp -rf * /usr/local/ \ + && cd .. && rm -rf cmake-${CMAKE_0VERSION}-linux-aarch64.tar.gz + +# install grpc. If planning to upgrade, make sure sed command works +RUN git clone https://github.com/grpc/grpc \ + && cd grpc \ + && git checkout tags/v${GRPC_VERSION} -b v${GRPC_VERSION} \ + && git submodule update --init \ + && sed -i "s/target_link_libraries(bssl ssl crypto)/target_link_libraries(bssl ssl crypto rt)/g" third_party/boringssl-with-bazel/CMakeLists.txt \ + && mkdir -p cmake/build \ + && cd cmake/build \ + && cmake ../.. -DgRPC_INSTALL=ON -DCMAKE_BUILD_TYPE=Release -DgRPC_ABSL_PROVIDER=module -DgRPC_CARES_PROVIDER=module -DgRPC_PROTOBUF_PROVIDER=module -DgRPC_RE2_PROVIDER=module -DgRPC_SSL_PROVIDER=module -DgRPC_ZLIB_PROVIDER=module \ + && make \ + && make install \ + && cd ../../.. + +# Create dependencies folder to store all dependencies. +RUN mkdir -p dependencies + +# install boost version 1.75.0 +RUN wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/${BOOST_FILENAME}_rc1.tar.gz \ + && tar -xvf ${BOOST_FILENAME}_rc1.tar.gz \ + && cd ${BOOST_FILENAME} \ + && ./bootstrap.sh --with-libraries=filesystem,system --prefix=/dependencies/boost/${BOOST_VERSION}/ \ + && ./b2 install define=BOOST_ERROR_CODE_HEADER_ONLY link=static threading=multi cxxflags="-fvisibility=hidden -fPIC" cflags="-fvisibility=hidden -fPIC" \ + && cd .. && rm -rf ${BOOST_FILENAME} && rm ${BOOST_FILENAME}_rc1.tar.gz + +#install Apr +RUN mkdir -p dependencies/apr/${APR_VERSION} \ + && wget https://archive.apache.org/dist/apr/apr-${APR_VERSION}.tar.gz --no-check-certificate \ + && tar -xf apr-${APR_VERSION}.tar.gz \ + && cd apr-${APR_VERSION} \ + && ./configure --prefix=/dependencies/apr/${APR_VERSION} --enable-static=yes --enable-shared=no --with-pic && echo $? \ + && make -j 6 \ + && make install \ + && cd ../ && rm -rf apr-${APR_VERSION} && rm -rf apr-${APR_VERSION}.tar.gz + +# install libexpat +RUN mkdir -p dependencies/expat/${EXPAT_VERSION} \ + && wget https://github.com/libexpat/libexpat/releases/download/${EXPAT_RVERSION}/expat-${EXPAT_VERSION}.tar.gz --no-check-certificate \ + && tar -xf expat-${EXPAT_VERSION}.tar.gz \ + && cd expat-${EXPAT_VERSION} \ + && ./configure --prefix=/dependencies/expat/${EXPAT_VERSION} --enable-static=yes --enable-shared=no --with-pic && echo $? \ + && make -j 6 \ + && make install \ + && cd ../ && rm -rf expat-${EXPAT_VERSION} && rm -rf expat-${EXPAT_VERSION}.tar.gz + +# install Apr-util +RUN mkdir -p dependencies/apr-util/${APRUTIL_VERSION} \ + && wget https://archive.apache.org/dist/apr/apr-util-${APRUTIL_VERSION}.tar.gz --no-check-certificate \ + && tar -xf apr-util-${APRUTIL_VERSION}.tar.gz \ + && cd apr-util-${APRUTIL_VERSION} \ + && ./configure --prefix=/dependencies/apr-util/${APRUTIL_VERSION} --enable-static=yes --enable-shared=no --with-pic --with-apr=/dependencies/apr/${APR_VERSION} --with-expat=/dependencies/expat/${EXPAT_VERSION} && echo $? \ + && make -j 6 \ + && make install \ + && cd ../ && rm -rf apr-util-${APRUTIL_VERSION} && rm -rf apr-util-${APRUTIL_VERSION}.tar.gz + +# install m4 +RUN yum install m4 -y \ + && yum install perl-Data-Dumper -y + +# Update perl version +RUN yum install perl-Thread-Queue.noarch -y \ + && wget http://www.cpan.org/src/${PERL_CPANVERSION}/perl-${PERL_VERSION}.tar.gz \ + && tar -xzf perl-${PERL_VERSION}.tar.gz \ + && cd perl-${PERL_VERSION} \ + && ./Configure -des -Dprefix=$HOME/localperl \ + && make \ + && make test; echo 0 \ + && make install +ENV PATH=$HOME/localperl/bin:$PATH + +# install autoconf +RUN wget --no-check-certificate https://ftp.gnu.org/gnu/autoconf/autoconf-${AUTOCONF_VERSION}.tar.gz \ + && tar xzf autoconf-${AUTOCONF_VERSION}.tar.gz \ + && cd autoconf-${AUTOCONF_VERSION} \ + && ./configure --prefix=/usr/ --build=aarch64-unknown-linux-gnu && make -j && make install && autoconf -V \ + && cd .. && rm -rf autoconf-${AUTOCONF_VERSION}.tar.gz + +# install automake +RUN wget --no-check-certificate https://ftp.gnu.org/gnu/automake/automake-${AUTOMAKE_VERSION}.tar.gz \ + && tar xzf automake-${AUTOMAKE_VERSION}.tar.gz \ + && cd automake-${AUTOMAKE_VERSION} \ + && ./configure --prefix=/usr --libdir=/usr/lib64 \ + && make -j && make install \ + && automake --version \ + && cd .. && rm -rf automake-${AUTOMAKE_VERSION}.tar.gz + +# install libtool +RUN wget --no-check-certificate https://ftpmirror.gnu.org/libtool/libtool-${LIBTOOL_VERSION}.tar.gz \ + && tar xzf libtool-${LIBTOOL_VERSION}.tar.gz \ + && cd libtool-${LIBTOOL_VERSION} \ + && ./configure --prefix=/usr \ + && make -j 6 \ + && make install \ + && libtool --version \ + && cd .. && rm -rf libtool--${LIBTOOL_VERSION}.tar.gz + +#install log4cxx +RUN mkdir -p dependencies/apache-log4cxx/${LOG4CXX_VERSION} \ + && wget https://archive.apache.org/dist/logging/log4cxx/${LOG4CXX_VERSION}/apache-log4cxx-${LOG4CXX_VERSION}.tar.gz --no-check-certificate \ + && tar -xf apache-log4cxx-${LOG4CXX_VERSION}.tar.gz \ + && cd apache-log4cxx-${LOG4CXX_VERSION} \ + && ./configure --prefix=/dependencies/apache-log4cxx/${LOG4CXX_VERSION}/ --enable-static=yes --enable-shared=no --with-pic --with-apr=/dependencies/apr/${APR_VERSION}/ --with-apr-util=/dependencies/apr-util/${APRUTIL_VERSION}/ && echo $? \ + && make -j 6 ; echo 0 \ + && automake --add-missing \ + && make install \ + && cd .. && rm -rf apache-log4cxx-${LOG4CXX_VERSION}.tar.gz && rm -rf apache-log4cxx-${LOG4CXX_VERSION} + +# install opentelemetry +RUN mkdir -p dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/lib \ + && mkdir -p dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/include \ + && git clone https://github.com/open-telemetry/opentelemetry-cpp \ + && cd opentelemetry-cpp/ \ + && git checkout tags/v${OPENTELEMETRY_VERSION} -b v${OPENTELEMETRY_VERSION} \ + && git submodule update --init --recursive \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DWITH_OTLP=ON -DCMAKE_INSTALL_PREFIX=/dependencies/opentelemetry/${OPENTELEMETRY_VERSION} \ + && cmake --build . --target all \ + && cd .. \ + && find . -name "*.so" -type f -exec cp {} /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/lib/ \; \ + && cp build/libopentelemetry_proto.a /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/lib \ + && cp -r api/include/ /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/ \ + && for dir in exporters/*; do if [ -d "$dir" ]; then cp -rf "$dir/include" /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/; fi; done \ + && cp -r sdk/include/ /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/ \ + && cp -r build/generated/third_party/opentelemetry-proto/opentelemetry/proto/ /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/include/opentelemetry/ \ + && cd .. && rm -rf opentelemetry-cpp + +# install googletest +RUN mkdir -p dependencies/googletest/${GTEST_VERSION}/ \ + && wget https://github.com/google/googletest/archive/refs/tags/release-${GTEST_VERSION}.tar.gz --no-check-certificate \ + && tar -xf release-${GTEST_VERSION}.tar.gz \ + && cd googletest-release-${GTEST_VERSION}/ \ + && mkdir build && cd build \ + && cmake .. -DCMAKE_INSTALL_PREFIX=/dependencies/googletest/${GTEST_VERSION}/ \ + && make \ + && make install \ + && cd ../.. && rm -rf release-${GTEST_VERSION}.tar.gz && rm -rf googletest-release-${GTEST_VERSION}/ + +# install pcre +RUN mkdir -p dependencies/pcre/${PCRE_VERSION}/ \ + && wget https://ftp.exim.org/pub/pcre/pcre-${PCRE_VERSION}.tar.gz --no-check-certificate \ + && tar -xvf pcre-${PCRE_VERSION}.tar.gz \ + && cd pcre-${PCRE_VERSION} \ + && ./configure --prefix=/dependencies/pcre/${PCRE_VERSION} --enable-jit \ + && make && make install \ + && cd .. && rm -rf ${PCRE_VERSION}.tar.gz && rm -rf pcre-${PCRE_VERSION} + +#Installing Apache and apr source code +RUN mkdir build-dependencies \ + && wget --no-check-certificate https://archive.apache.org/dist/apr/apr-${APR_VERSION}.tar.gz \ + && tar -xf apr-${APR_VERSION}.tar.gz \ + && mv -f apr-${APR_VERSION} build-dependencies \ + && wget --no-check-certificate https://archive.apache.org/dist/apr/apr-util-${APRUTIL_VERSION}.tar.gz \ + && tar -xf apr-util-${APRUTIL_VERSION}.tar.gz \ + && mv -f apr-util-${APRUTIL_VERSION} build-dependencies \ + && wget --no-check-certificate http://archive.apache.org/dist/httpd/httpd-2.2.31.tar.gz \ + && tar -xf httpd-2.2.31.tar.gz \ + && mv -f httpd-2.2.31 build-dependencies \ + && wget --no-check-certificate http://archive.apache.org/dist/httpd/httpd-2.4.23.tar.gz \ + && tar -xf httpd-2.4.23.tar.gz \ + && mv -f httpd-2.4.23 build-dependencies + +# install nginx +RUN wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \ + && tar -xvf nginx-${NGINX_VERSION}.tar.gz -C /build-dependencies \ + && rm -rf nginx-${NGINX_VERSION}.tar.gz + +# Build Webserver Module +COPY . /otel-webserver-module + +RUN cp -r /dependencies /otel-webserver-module/ \ + && cp -r /build-dependencies /otel-webserver-module/ \ + && cd otel-webserver-module \ + && ./gradlew assembleWebServerModule + +RUN echo '[nginx]' >> /etc/yum.repos.d/nginx.repo \ + && echo 'name=nginx repo' >> /etc/yum.repos.d/nginx.repo \ + && echo 'baseurl=https://nginx.org/packages/centos/7/aarch64' >> /etc/yum.repos.d/nginx.repo \ + && echo 'gpgcheck=0' >> /etc/yum.repos.d/nginx.repo \ + && echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo \ + && yum install nginx-${NGINX_VERSION} -y + +RUN cd /otel-webserver-module/build \ + && tar -xf opentelemetry-webserver-sdk-arm64-linux.tgz \ + && mv -f opentelemetry-webserver-sdk /opt/ \ + && cd ../ \ + && cp opentelemetry_module.conf /etc/httpd/conf/ \ + && sed -i "s/libmod_apache_otel22.so/libmod_apache_otel.so/g" /etc/httpd/conf/opentelemetry_module.conf \ + && echo 'Include conf/opentelemetry_module.conf' >> /etc/httpd/conf/httpd.conf \ + && cd /opt/opentelemetry-webserver-sdk \ + && ./install.sh \ + && cd / + +RUN cp /otel-webserver-module/conf/nginx/opentelemetry_module.conf /opt/ \ + && sed -i '8i load_module /opt/opentelemetry-webserver-sdk/WebServerModule/Nginx/1.26.0/ngx_http_opentelemetry_module.so;' /etc/nginx/nginx.conf \ + && sed -i '33i include /opt/opentelemetry_module.conf;' /etc/nginx/nginx.conf \ + && cd / + +# Remove unwanted files +RUN rm -rf grpc && rm -rf autoconf-${AUTOCONF_VERSION} && rm -rf automake-${AUTOMAKE_VERSION} && rm -rf cmake-${CMAKE_VERSION}-linux-aarch64 \ + && rm -rf libtool-${LIBTOOL_VERSION} && rm -rf Python-${PYTHON_VERSION} \ + && rm -f apr-${APR_VERSION}.tar.gz && rm -f apr-util-${APRUTIL_VERSION}.tar.gz \ + && rm -f httpd-2.2.31.tar.gz && rm -f httpd-2.4.23.tar.gz + +COPY entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file diff --git a/instrumentation/otel-webserver-module/docker/ubuntu20.04-arm64/Dockerfile b/instrumentation/otel-webserver-module/docker/ubuntu20.04-arm64/Dockerfile new file mode 100644 index 00000000..0c9b9544 --- /dev/null +++ b/instrumentation/otel-webserver-module/docker/ubuntu20.04-arm64/Dockerfile @@ -0,0 +1,220 @@ +FROM ubuntu:20.04 +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get -y update && apt-get -y upgrade && apt-get -y dist-upgrade +RUN apt-get install -qq -y --ignore-missing \ + build-essential \ + curl \ + git \ + make \ + pkg-config \ + protobuf-compiler \ + libprotobuf-dev \ + python \ + sudo \ + tar \ + zip \ + unzip \ + wget \ + cmake + +RUN apt-get install -y \ + lcov \ + m4 \ + autoconf \ + automake \ + libtool \ + default-jre + +# The following arguments would be passed from docker-compose.yml +ARG GRPC_VERSION="1.36.4" +ARG OPENTELEMETRY_VERSION="1.2.0" +ARG BOOST_VERSION="1.75.0" +ARG BOOST_FILENAME="boost_1_75_0" +ARG APR_VERSION="1.7.0" +ARG EXPAT_VERSION="2.3.0" +ARG EXPAT_RVERSION="R_2_3_0" +ARG APRUTIL_VERSION="1.6.1" +ARG LOG4CXX_VERSION="0.11.0" +ARG GTEST_VERSION="1.10.0" +ARG PCRE_VERSION="8.44" +ARG NGINX_VERSION="1.26.0" + +# Install GRPC +RUN git clone --shallow-submodules --depth 1 --recurse-submodules -b v${GRPC_VERSION} \ + https://github.com/grpc/grpc \ + && cd grpc \ + && mkdir -p cmake/build \ + && cd cmake/build \ + && cmake \ + -DgRPC_INSTALL=ON \ + -DgRPC_BUILD_TESTS=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF \ + ../.. \ + && make -j2 \ + && make install \ + && cd ../../.. + +# install opentelemetry +RUN mkdir -p dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/lib \ + && mkdir -p dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/include \ + && git clone https://github.com/open-telemetry/opentelemetry-cpp \ + && cd opentelemetry-cpp/ \ + && git checkout tags/v${OPENTELEMETRY_VERSION} -b v${OPENTELEMETRY_VERSION} \ + && git submodule update --init --recursive \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DWITH_OTLP=ON -DCMAKE_INSTALL_PREFIX=/dependencies/opentelemetry/${OPENTELEMETRY_VERSION} \ + && cmake --build . --target all \ + && cd .. \ + && find . -name "*.so" -type f -exec cp {} /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/lib/ \; \ + && cp build/libopentelemetry_proto.a /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/lib \ + && cp -r api/include/ /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/ \ + && for dir in exporters/*; do if [ -d "$dir" ]; then cp -rf "$dir/include" /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/; fi; done \ + && cp -r sdk/include/ /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/ \ + && cp -r build/generated/third_party/opentelemetry-proto/opentelemetry/proto/ /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/include/opentelemetry/ \ + && cd .. && rm -rf opentelemetry-cpp + +#install Apr +RUN mkdir -p dependencies/apr/${APR_VERSION} \ + && wget https://archive.apache.org/dist/apr/apr-${APR_VERSION}.tar.gz --no-check-certificate \ + && tar -xf apr-${APR_VERSION}.tar.gz \ + && cd apr-${APR_VERSION} \ + && ./configure --prefix=/dependencies/apr/${APR_VERSION} --enable-static=yes --enable-shared=no --with-pic && echo $? \ + && make -j 6 \ + && make install \ + && cd ../ && rm -rf apr-${APR_VERSION} && rm -rf apr-${APR_VERSION}.tar.gz + +# install libexpat +RUN mkdir -p dependencies/expat/${EXPAT_VERSION} \ + && wget https://github.com/libexpat/libexpat/releases/download/${EXPAT_RVERSION}/expat-${EXPAT_VERSION}.tar.gz --no-check-certificate \ + && tar -xf expat-${EXPAT_VERSION}.tar.gz \ + && cd expat-${EXPAT_VERSION} \ + && ./configure --prefix=/dependencies/expat/${EXPAT_VERSION} --enable-static=yes --enable-shared=no --with-pic && echo $? \ + && make -j 6 \ + && make install \ + && cd ../ && rm -rf expat-${EXPAT_VERSION} && rm -rf expat-${EXPAT_VERSION}.tar.gz + +# install Apr-util +RUN mkdir -p dependencies/apr-util/${APRUTIL_VERSION} \ + && wget https://archive.apache.org/dist/apr/apr-util-${APRUTIL_VERSION}.tar.gz --no-check-certificate \ + && tar -xf apr-util-${APRUTIL_VERSION}.tar.gz \ + && cd apr-util-${APRUTIL_VERSION} \ + && ./configure --prefix=/dependencies/apr-util/${APRUTIL_VERSION} --enable-static=yes --enable-shared=no --with-pic --with-apr=/dependencies/apr/1.7.0 --with-expat=/dependencies/expat/2.3.0 && echo $? \ + && make -j 6 \ + && make install \ + && cd ../ && rm -rf apr-util-${APRUTIL_VERSION} && rm -rf apr-util-${APRUTIL_VERSION}.tar.gz + + +#install log4cxx +RUN mkdir -p dependencies/apache-log4cxx/${LOG4CXX_VERSION} \ + && wget https://archive.apache.org/dist/logging/log4cxx/${LOG4CXX_VERSION}/apache-log4cxx-${LOG4CXX_VERSION}.tar.gz --no-check-certificate \ + && tar -xf apache-log4cxx-${LOG4CXX_VERSION}.tar.gz \ + && cd apache-log4cxx-${LOG4CXX_VERSION} \ + && ./configure --prefix=/dependencies/apache-log4cxx/${LOG4CXX_VERSION}/ --enable-static=yes --enable-shared=no --with-pic --with-apr=/dependencies/apr/1.7.0/ --with-apr-util=/dependencies/apr-util/1.6.1/ && echo $? \ + && make -j 6 ; echo 0 \ + && automake --add-missing \ + && make install \ + && cd .. && rm -rf apache-log4cxx-${LOG4CXX_VERSION}.tar.gz && rm -rf apache-log4cxx-${LOG4CXX_VERSION} + +# install googletest +RUN mkdir -p dependencies/googletest/${GTEST_VERSION}/ \ + && wget https://github.com/google/googletest/archive/refs/tags/release-${GTEST_VERSION}.tar.gz --no-check-certificate \ + && tar -xf release-${GTEST_VERSION}.tar.gz \ + && cd googletest-release-${GTEST_VERSION}/ \ + && mkdir build && cd build \ + && cmake .. -DCMAKE_INSTALL_PREFIX=/dependencies/googletest/${GTEST_VERSION}/ \ + && make \ + && make install \ + && cd ../.. && rm -rf release-${GTEST_VERSION}.tar.gz && rm -rf googletest-release-${GTEST_VERSION}/ + +#Installing Apache and apr source code +RUN mkdir build-dependencies \ + && wget --no-check-certificate https://archive.apache.org/dist/apr/apr-${APR_VERSION}.tar.gz \ + && tar -xf apr-${APR_VERSION}.tar.gz \ + && mv -f apr-${APR_VERSION} build-dependencies \ + && wget --no-check-certificate https://archive.apache.org/dist/apr/apr-util-${APRUTIL_VERSION}.tar.gz \ + && tar -xf apr-util-${APRUTIL_VERSION}.tar.gz \ + && mv -f apr-util-${APRUTIL_VERSION} build-dependencies \ + && wget --no-check-certificate http://archive.apache.org/dist/httpd/httpd-2.2.31.tar.gz \ + && tar -xf httpd-2.2.31.tar.gz \ + && mv -f httpd-2.2.31 build-dependencies \ + && wget --no-check-certificate http://archive.apache.org/dist/httpd/httpd-2.4.23.tar.gz \ + && tar -xf httpd-2.4.23.tar.gz \ + && mv -f httpd-2.4.23 build-dependencies + +RUN rm -rf apr-util-${APRUTIL_VERSION} && rm -rf apr-util-${APRUTIL_VERSION}.tar.gz \ + && rm -rf httpd-2.4.23.tar.gz && rm -rf httpd-2.2.31.tar.gz \ + && rm -rf grpc \ + && rm -rf apr-${APR_VERSION} && rm -rf apr-${APR_VERSION}.tar.gz + +RUN apt-get install libpcre3 libpcre3-dev -y +RUN apt-get install apache2 -y && a2enmod proxy && a2enmod proxy_http \ + && a2enmod proxy_balancer && a2enmod dav + +#Build and install boost +RUN wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/${BOOST_FILENAME}.tar.gz \ + && tar -xvf ${BOOST_FILENAME}.tar.gz \ + && cd ${BOOST_FILENAME} \ + && ./bootstrap.sh --with-libraries=filesystem,system --prefix=/dependencies/boost/${BOOST_VERSION}/ \ + && ./b2 install define=BOOST_ERROR_CODE_HEADER_ONLY link=static threading=multi cxxflags="-fvisibility=hidden -fPIC" cflags="-fvisibility=hidden -fPIC" \ + && cd .. && rm -rf ${BOOST_FILENAME} && rm ${BOOST_FILENAME}.tar.gz + +# install pcre +RUN mkdir -p dependencies/pcre/${PCRE_VERSION}/ \ + && wget https://ftp.exim.org/pub/pcre/pcre-${PCRE_VERSION}.tar.gz --no-check-certificate \ + && tar -xvf pcre-${PCRE_VERSION}.tar.gz \ + && cd pcre-${PCRE_VERSION} \ + && ./configure --prefix=/dependencies/pcre/${PCRE_VERSION} --enable-jit \ + && make && make install \ + && cd .. && rm -rf ${PCRE_VERSION}.tar.gz && rm -rf pcre-${PCRE_VERSION} + +# install nginx +RUN wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \ + && tar -xvf nginx-${NGINX_VERSION}.tar.gz -C /build-dependencies \ + && rm -rf nginx-${NGINX_VERSION}.tar.gz + +# Install Nginx stable version +RUN apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring -y \ + && curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \ + | tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null \ + && gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg; exit 0 +RUN echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \ + http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \ + | tee /etc/apt/sources.list.d/nginx.list \ + && echo "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \ + | tee /etc/apt/preferences.d/99nginx \ + && apt update -y && apt install nginx -y + +# Build Webserver Module +COPY . /otel-webserver-module + +RUN cp -r /dependencies /otel-webserver-module/ \ + && cp -r /build-dependencies /otel-webserver-module/ \ + && cd otel-webserver-module \ + && ./gradlew assembleWebServerModule -DtargetSystem=ubuntu + +RUN cd /otel-webserver-module/build \ + && tar -xf opentelemetry-webserver-sdk-*-linux.tgz \ + && mv -f opentelemetry-webserver-sdk /opt/ \ + && cd ../ \ + && cp opentelemetry_module.conf /etc/apache2/opentelemetry_module.conf \ + && sed -i "s/libmod_apache_otel22.so/libmod_apache_otel.so/g" /etc/apache2/opentelemetry_module.conf \ + && echo 'Include opentelemetry_module.conf' >> /etc/apache2/apache2.conf \ + && cd /opt/opentelemetry-webserver-sdk \ + && ./install.sh \ + && cd / + +RUN cd /otel-webserver-module/build \ + && cp ../conf/nginx/opentelemetry_module.conf /opt/ \ + && sed -i '5i load_module /opt/opentelemetry-webserver-sdk/WebServerModule/Nginx/1.26.0/ngx_http_opentelemetry_module.so;' /etc/nginx/nginx.conf \ + && sed -i '33i include /opt/opentelemetry_module.conf;' /etc/nginx/nginx.conf \ + && cd /opt/opentelemetry-webserver-sdk \ + && ./install.sh \ + && cd / \ No newline at end of file diff --git a/instrumentation/otel-webserver-module/test/ApacheTesting.sh b/instrumentation/otel-webserver-module/test/ApacheTesting.sh index 171c2ee1..ebf69d8b 100755 --- a/instrumentation/otel-webserver-module/test/ApacheTesting.sh +++ b/instrumentation/otel-webserver-module/test/ApacheTesting.sh @@ -5,6 +5,7 @@ # Extract the agent targetSystem=$1 +platform=$2 OTelApacheModule="/opt/opentelemetry-webserver-sdk/WebServerModule/Apache/libmod_apache_otel22.so" if [ $targetSystem = "ubuntu" ] || [ $targetSystem = "centos7" ]; then @@ -12,7 +13,7 @@ if [ $targetSystem = "ubuntu" ] || [ $targetSystem = "centos7" ]; then fi -tar -xf ../build/opentelemetry-webserver-sdk-x64-linux.tgz -C /opt +tar -xf ../build/opentelemetry-webserver-sdk-$platform-linux.tgz -C /opt cd /opt/opentelemetry-webserver-sdk diff --git a/instrumentation/otel-webserver-module/test/NginxTesting.sh b/instrumentation/otel-webserver-module/test/NginxTesting.sh index 5bc8cf43..2e567987 100755 --- a/instrumentation/otel-webserver-module/test/NginxTesting.sh +++ b/instrumentation/otel-webserver-module/test/NginxTesting.sh @@ -3,7 +3,9 @@ # Bash script for testing Apache Server # Extract the agent -tar -xf ../build/opentelemetry-webserver-sdk-x64-linux.tgz -C /opt +platform=$1 + +tar -xf ../build/opentelemetry-webserver-sdk-$platform-linux.tgz -C /opt cd /opt/opentelemetry-sdk-native diff --git a/instrumentation/otel-webserver-module/test/unit/ApiUtils_test.cpp b/instrumentation/otel-webserver-module/test/unit/ApiUtils_test.cpp index b420dda3..3836f55c 100644 --- a/instrumentation/otel-webserver-module/test/unit/ApiUtils_test.cpp +++ b/instrumentation/otel-webserver-module/test/unit/ApiUtils_test.cpp @@ -421,5 +421,5 @@ TEST(ApiUtils, getSDKInstallPath) { otel::core::ApiUtils apiUtils; auto path = apiUtils.getSDKInstallPath(); - EXPECT_THAT(path.string(), testing::EndsWith("build/linux-x64/opentelemetry-webserver-sdk")); + EXPECT_THAT(path.string(), testing::MatchesRegex(".*build/linux-(x|arm)64/opentelemetry-webserver-sdk")); }