Skip to content

Commit

Permalink
Update examples, add docker compose / tilt setup
Browse files Browse the repository at this point in the history
  • Loading branch information
actualwitch committed Oct 26, 2023
1 parent 5579b02 commit 2e9bbb1
Show file tree
Hide file tree
Showing 21 changed files with 1,689 additions and 65 deletions.
10 changes: 9 additions & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
docker_compose('docker-compose.yaml')
docker_compose(['configs/compose/infra.yaml', 'configs/compose/examples.yaml'])

dc_resource('am', labels=["infra"])
dc_resource('grafana', labels=["infra"])
dc_resource('otel-collector', labels=["infra"])
dc_resource('push-gateway', labels=["infra"])
dc_resource('django', labels=["examples"])
dc_resource('fastapi', labels=["examples"])
dc_resource('starlette', labels=["examples"])
44 changes: 44 additions & 0 deletions configs/compose/examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: "3.8"

services:
django:
container_name: django
build:
context: ../..
dockerfile: configs/docker/base.Dockerfile
args:
PORT: 9464
COPY_PATH: examples/django_example
COMMAND: ./run_example.sh
ports:
- "9464:9464"
fastapi:
container_name: fastapi
build:
context: ../..
dockerfile: configs/docker/base.Dockerfile
args:
PORT: 8080
COPY_PATH: examples/fastapi-example.py
COMMAND: poetry run python3 fastapi-example.py
ports:
- "9465:8080"
starlette:
container_name: starlette
build:
context: ../..
dockerfile: configs/docker/base.Dockerfile
args:
PORT: 8080
COPY_PATH: examples/starlette-otel-exemplars.py
COMMAND: poetry run python3 starlette-otel-exemplars.py
ports:
- "9466:8080"
otlp:
container_name: otlp
build:
context: ../..
dockerfile: configs/docker/base.Dockerfile
args:
COPY_PATH: examples/export_metrics/otlp-http.py
COMMAND: poetry run python3 otlp-http.py
48 changes: 48 additions & 0 deletions configs/compose/infra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: "3.8"

volumes:
app-logs: {}
grafana-storage: {}

services:
am:
container_name: am
image: autometrics/am:latest
extra_hosts:
- host.docker.internal:host-gateway
ports:
- "6789:6789"
- "9090:9090"
command: "start http://otel-collector:9464/metrics host.docker.internal:9464 host.docker.internal:9465 host.docker.internal:9466"
environment:
- LISTEN_ADDRESS=0.0.0.0:6789
restart: unless-stopped
volumes:
- app-logs:/var/log
otel-collector:
container_name: otel-collector
image: otel/opentelemetry-collector-contrib:latest
command: ["--config=/etc/otel-collector-config.yaml"]
volumes:
- ../otel-collector-config.yaml:/etc/otel-collector-config.yaml
ports:
- "4317:4317"
- "4318:4318"
- "8888:8888" # expose container metrics in prometheus format
- "55680:55680"
- "55679:55679"
restart: unless-stopped
push-gateway:
container_name: push-gateway
image: ghcr.io/zapier/prom-aggregation-gateway:latest
grafana:
container_name: grafana
image: grafana/grafana-oss
restart: unless-stopped
ports:
- "3000:3000"
volumes:
- grafana-storage:/var/lib/grafana
- ../grafana/config.ini:/etc/grafana/grafana.ini
- ../grafana/dashboards:/var/lib/grafana/dashboards
- ../grafana/provisioning:/etc/grafana/provisioning
17 changes: 17 additions & 0 deletions configs/docker/base.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

FROM python:latest
ARG COPY_PATH
ARG COMMAND
ARG PORT
WORKDIR /app
RUN apt-get update
RUN pip install poetry
COPY pyproject.toml poetry.lock src ./
RUN poetry config virtualenvs.create false
RUN poetry install --no-interaction --no-root --with examples --extras "exporter-otlp-proto-http"
COPY $COPY_PATH ./
ENV OTEL_EXPORTER_OTLP_ENDPOINT http://host.docker.internal:4318
ENV COMMAND $COMMAND
ENV PORT $PORT
EXPOSE $PORT
CMD ["sh", "-c", "$COMMAND"]
4 changes: 4 additions & 0 deletions configs/grafana/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[auth.anonymous]
disable_login_form = true
enabled = true
org_role = Admin
Loading

0 comments on commit 2e9bbb1

Please sign in to comment.