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

Open Telemetry and Docker #315

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/*.jar
/target
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ profiles.clj
.DS_Store
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port
Expand All @@ -19,3 +18,4 @@ pom.xml.asc
/logs
/keystore.jks
/.envrc
/.envrc-docker
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ RUN lein uberjar

FROM gcr.io/distroless/java17-debian12
COPY --from=builder /app/target/eduhub-rio-mapper.jar /eduhub-rio-mapper.jar
COPY --from=builder /app/test/test-clients.json /test-clients.json
# Make sure there is an opentelemetry agent in the workdir in case docker-compose
# starts up a process with -javaagent in the JAVA_TOOL_OPTIONS
COPY --from=builder /app/vendor/opentelemetry-javaagent-2.2.0.jar /opentelemetry-javaagent.jar
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Liever geen binaries in de repo en volgens mij wordt deze al gedownload in de makefile (latest weliswaar maar daar heb ik al overgeklaagd)


WORKDIR /
ENTRYPOINT ["java", "-jar", "/eduhub-rio-mapper.jar"]
remvee marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.PHONY: lint test check clean

lint:
clojure -M:lint

test:
clojure -M:test

check: lint test

clean:
rm -rf classes target

.PHONY: test lint check
32 changes: 32 additions & 0 deletions dev-infra/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
global:
scrape_interval: 15s
evaluation_interval: 30s

external_labels:
monitor: codelab
foo: bar

scrape_configs:
- job_name: scrape-static

honor_labels: true
# scrape_interval is defined by the configured global (15s).
# scrape_timeout is defined by the global default (10s).

# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
scheme: http

static_configs:
- targets: ["localhost:9090"]
labels:
service: prometheus
- targets: ["worker:9464"]
labels:
service: worker
- targets: ["api:3000"]
labels:
service: api
- targets: ["api:9464"]
labels:
service: api
63 changes: 63 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
services:
redis:
image: redis:7-alpine
restart: always
ports:
- '6380:6379'
command: redis-server --save 20 1 --loglevel warning
volumes:
- redis:/data
prometheus:
image: prom/prometheus
ports:
- "9090:9090"
volumes:
- ./dev-infra/prometheus.yml:/etc/prometheus/prometheus.yml
worker:
platform: "linux/amd64"
build: .
env_file:
- .envrc # read environment from local direnv settings
environment:
CLIENTS_INFO_PATH: /test-clients.json
REDIS_URI: redis://redis
OTEL_METRICS_EXPORTER: prometheus
OTEL_EXPORTER_PROMETHEUS_ENDPOINT: http://localhost:9464/metrics
OTEL_SERVICE_NAME: edumapper-worker
OTEL_LOGS_EXPORTER: none
OTEL_TRACES_EXPORTER: none
JAVA_TOOL_OPTIONS: -javaagent:./opentelemetry-javaagent.jar
volumes:
- ./truststore.jks:/truststore.jks
- ./keystore.jks:/keystore.jks
- ./test/test-clients.json:/test/test-clients.json
command: worker
ports:
- "9465:9464"
api:
platform: "linux/amd64"
build: .
env_file:
- .envrc # read environment from local direnv settings
environment:
CLIENTS_INFO_PATH: /test-clients.json
REDIS_URI: redis://redis
OTEL_METRICS_EXPORTER: prometheus
OTEL_EXPORTER_PROMETHEUS_ENDPOINT: http://localhost:9464/metrics
OTEL_SERVICE_NAME: edumapper-api
OTEL_LOGS_EXPORTER: none
OTEL_TRACES_EXPORTER: none
JAVA_TOOL_OPTIONS: -javaagent:./opentelemetry-javaagent.jar
API_HOSTNAME: 0.0.0.0
API_PORT: 3000
volumes:
- ./truststore.jks:/truststore.jks
- ./keystore.jks:/keystore.jks
- ./test/test-clients.json:/test/test-clients.json
ports:
- "3000:3000"
- "9464:9464"
command: serve-api
volumes:
redis:
driver: local
Binary file added vendor/opentelemetry-javaagent-2.2.0.jar
Binary file not shown.