Skip to content

Commit

Permalink
Integrate datadog to backend for traces and logs (#1299)
Browse files Browse the repository at this point in the history
Issue #1217 

**Key changes:**

- Add ddtrace library
- Wrap application to datadog serverless-init to collect traces and logs
  • Loading branch information
beastoin authored Nov 14, 2024
2 parents 17286ba + 19da5d0 commit e91a8ef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/gcp_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: ./backend/Dockerfile
file: ./backend/Dockerfile.datadog
push: true
tags: gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}:latest
cache-from: type=registry,ref=gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}:buildcache
Expand Down
23 changes: 23 additions & 0 deletions backend/Dockerfile.datadog
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.11 AS builder

ENV PATH="/opt/venv/bin:$PATH"
RUN python -m venv /opt/venv

COPY backend/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /tmp/requirements.txt

FROM python:3.11-slim

WORKDIR /app
ENV PATH="/opt/venv/bin:$PATH"

RUN apt-get update && apt-get -y install ffmpeg curl unzip && rm -rf /var/lib/apt/lists/* && \
pip install --target /dd_tracer/python/ ddtrace

COPY --from=builder /opt/venv /opt/venv
COPY --from=gcr.io/datadoghq/serverless-init:1 /datadog-init /app/datadog-init
COPY backend/ .

EXPOSE 8080
ENTRYPOINT ["/app/datadog-init"]
CMD ["/dd_tracer/python/bin/ddtrace-run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]

0 comments on commit e91a8ef

Please sign in to comment.