Skip to content

Commit

Permalink
Fix examples to work with most recent release. (#251)
Browse files Browse the repository at this point in the history
The CMake version required to build dd-opentracing-cpp was increased
recently, but the examples/ were not updated to use a version of
Ubuntu that had the required version.

This commit updates the Docker base images used in the examples,
as well as tweaks the examples to build faster and a couple of other
conveniences.
  • Loading branch information
dgoffredo authored Nov 2, 2022
1 parent 1581754 commit 4c4677f
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 14 deletions.
6 changes: 3 additions & 3 deletions examples/cpp-tracing/compiled-in/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:18.04
FROM ubuntu:20.04

RUN apt-get update && \
apt-get -y install build-essential cmake wget
DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential cmake wget coreutils

# Download and install dd-opentracing-cpp library.
RUN get_latest_release() { \
Expand All @@ -15,7 +15,7 @@ RUN get_latest_release() { \
# Download and install the correct version of opentracing-cpp, & other deps.
../scripts/install_dependencies.sh && \
cmake .. && \
make && \
make -j "$(nproc)" && \
make install

COPY tracer_example.cpp .
Expand Down
7 changes: 5 additions & 2 deletions examples/cpp-tracing/compiled-in/build_and_run_example.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

if [ -z "$DD_API_KEY" ]
then
Expand All @@ -10,4 +10,7 @@ DD_API_KEY=${DD_API_KEY} docker-compose up \
--build \
--abort-on-container-exit \
--exit-code-from dd-opentracing-cpp-example
docker rm dd-agent

rcode=$?
docker-compose rm --force dd-agent
exit "$rcode"
1 change: 1 addition & 0 deletions examples/cpp-tracing/compiled-in/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ services:
- '/sys/fs/cgroup/:/host/sys/fs/cgroup:ro'
environment:
- 'DD_APM_ENABLED=true'
- 'DD_LOG_LEVEL=error'
- DD_API_KEY
image: 'datadog/agent'
8 changes: 4 additions & 4 deletions examples/cpp-tracing/dynamic-loading/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:18.04
FROM ubuntu:20.04

RUN apt-get update && \
apt-get -y install build-essential cmake wget
DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential cmake wget coreutils

# Download and install OpenTracing-cpp
RUN get_latest_release() { \
Expand All @@ -14,7 +14,7 @@ RUN get_latest_release() { \
tar zxvf opentracing-cpp.tar.gz -C ./opentracing-cpp/ --strip-components=1 && \
cd opentracing-cpp/.build && \
cmake .. && \
make && \
make -j "$(nproc)" && \
make install && \
# Install dd-opentracing-cpp shared plugin.
wget https://github.com/DataDog/dd-opentracing-cpp/releases/download/${DD_OPENTRACING_CPP_VERSION}/linux-amd64-libdd_opentracing_plugin.so.gz && \
Expand All @@ -23,7 +23,7 @@ RUN get_latest_release() { \

COPY tracer_example.cpp .

RUN g++ -std=c++11 -o tracer_example tracer_example.cpp -lopentracing
RUN g++ -std=c++14 -o tracer_example tracer_example.cpp -lopentracing
# Add /usr/local/lib to LD_LIBRARY_PATH
RUN ldconfig

Expand Down
7 changes: 5 additions & 2 deletions examples/cpp-tracing/dynamic-loading/build_and_run_example.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

if [ -z "$DD_API_KEY" ]
then
Expand All @@ -10,4 +10,7 @@ DD_API_KEY=${DD_API_KEY} docker-compose up \
--build \
--abort-on-container-exit \
--exit-code-from dd-opentracing-cpp-example
docker rm dd-agent

rcode=$?
docker-compose rm --force dd-agent
exit "$rcode"
1 change: 1 addition & 0 deletions examples/cpp-tracing/dynamic-loading/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
- '/sys/fs/cgroup/:/host/sys/fs/cgroup:ro'
environment:
- 'DD_APM_ENABLED=true'
- 'DD_LOG_LEVEL=error'
- DD_API_KEY
image: 'datadog/agent'
ports:
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp-tracing/unix-domain-socket/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ubuntu:20.04

run apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential cmake wget
run apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential cmake wget coreutils

# Download and install the latest release of the Datadog C++ tracer library.
copy bin/install-latest-dd-opentracing-cpp .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ cd dd-opentracing-cpp/.build
# Download and install the correct version of opentracing-cpp, & other deps.
../scripts/install_dependencies.sh
cmake ..
make
make -j "$(nproc)"
make install
11 changes: 10 additions & 1 deletion examples/cpp-tracing/unix-domain-socket/bin/run
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/bin/sh

if [ -z "$DD_API_KEY" ]; then
>&2 echo "Please set environment variable DD_API_KEY"
exit 1
fi

testdir=$(dirname "$(dirname "$(realpath "$0")")")

docker-compose --file "$testdir/docker-compose.yaml" up --build --remove-orphans
docker-compose --file "$testdir/docker-compose.yaml" up \
--build \
--remove-orphans \
--abort-on-container-exit \
--exit-code-from dd-opentracing-cpp-example-unix-domain-socket
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
- '/sys/fs/cgroup/:/host/sys/fs/cgroup:ro'
environment:
- DD_APM_ENABLED=true
- DD_LOG_LEVEL=error
- DD_API_KEY
- DD_APM_RECEIVER_SOCKET=/var/run/datadog-sockets/datadog-agent.sock
image: 'datadog/agent'
1 change: 1 addition & 0 deletions examples/nginx-tracing/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ services:
environment:
- DD_API_KEY
- DD_APM_ENABLED=true
- DD_LOG_LEVEL=error
- DD_LOGS_ENABLED=true
- DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
- DD_AC_EXCLUDE=name:datadog-agent
Expand Down

0 comments on commit 4c4677f

Please sign in to comment.