Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples, add docker compose / tilt setup #94

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 10 additions & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
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('otlp', 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