Skip to content

Commit

Permalink
Open telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
mdemare committed Jun 25, 2024
1 parent 09567f5 commit d456dc3
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 4 deletions.
36 changes: 36 additions & 0 deletions .envrc-docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export KEYSTORE_PASSWORD=xxxxxx
#export KEYSTORE_PASSWORD_FILE=/Users/mdemare/proj/jomco/surf/eduhub-rio-mapper/KEYSTORE_PASSWORD_FILE
export TRUSTSTORE=/app/truststore.jks
export TRUSTSTORE_PASSWORD=xxxxxx
export API_HOSTNAME=0.0.0.0
export API_PORT=3000
export WORKER_API_HOSTNAME=0.0.0.0
export WORKER_API_PORT=3001
export CLIENTS_INFO_PATH=/app/test/test-clients.json
export GATEWAY_ROOT_URL=https://gateway.test.surfeduhub.nl/
export GATEWAY_USER=rio-test
export JOB_MAX_RETRIES=2
export JOB_RETRY_WAIT_MS=3000
export KEYSTORE=/app/keystore.jks
export KEYSTORE_ALIAS=test-surf
export OIN_MAPPING_PATH=/app/test-oin-mapping.json
export REDIS_URI=redis://redis:6379/
export RIO_RETRY_ATTEMPTS_SECONDS=5,10,15,20
export RIO_READ_URL=https://vt-webservice.duo.nl:6977/RIO/services/raadplegen4.0
export RIO_UPDATE_URL=https://vt-webservice.duo.nl:6977/RIO/services/beheren4.0

export RIO_SENDER_OIN=0000000700025BE00000
export RIO_RECIPIENT_OIN=00000001800866472000
export SURF_CONEXT_CLIENT_ID=rio-mapper-server-dev.jomco.nl
export SURF_CONEXT_INTROSPECTION_ENDPOINT=https://connect.test.surfconext.nl/oidc/introspect

# For smoketest only; these are needed to retrieve a valid access
# token to the mapper api
export CLIENT_ID=rio-mapper-dev.jomco.nl
export TOKEN_ENDPOINT=https://connect.test.surfconext.nl/oidc/token

# https://proxy.swift.surfsara.nl/v1/KEY_8e0eecf8d38141f7aa98bc3078fc9ccd/rio-mapper-test-suite/
export OS_AUTH_URL=https://proxy.swift.surfsara.nl:5000/v3
export OS_CONTAINER_NAME=rio-mapper-test-suite
export OS_PROJECT_NAME=rio_mapper_test_suite
export OS_USERNAME=rio_mapper_test_suite
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ pom.xml.asc
/logs
/keystore.jks
/.envrc
/opentelemetry-javaagent.jar
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM clojure:temurin-11-lein-2.9.10-alpine as builder
FROM clojure:temurin-17-lein-jammy as builder

RUN mkdir /app
WORKDIR /app
COPY . /app/
RUN lein uberjar

FROM gcr.io/distroless/java:11
COPY --from=builder /app/target/eduhub-rio-mapper.jar /eduhub-rio-mapper.jar
# FROM gcr.io/distroless/java:11
# COPY --from=builder /app/target/eduhub-rio-mapper.jar /eduhub-rio-mapper.jar
# COPY --from=builder /app/opentelemetry-javaagent.jar /opentelemetry-javaagent.jar

ENTRYPOINT ["java", "-jar", "/eduhub-rio-mapper.jar"]
ENTRYPOINT ["java", "-jar", "/app/target/eduhub-rio-mapper.jar"]
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: lint test check clean

lint:
clojure -M:lint

test:
clojure -M:test

check: lint test

clean:
rm -rf classes target

opentelemetry-javaagent.jar:
curl -L https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar -o $@

.PHONY: docker-build test lint check

docker-build: Dockerfile docker-compose.yml opentelemetry-javaagent.jar
docker-compose build
41 changes: 41 additions & 0 deletions dev-infra/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# my global config
global:
scrape_interval: 15s
evaluation_interval: 30s
# scrape_timeout is set to the global default (10s).

external_labels:
monitor: codelab
foo: bar

#rule_files:
# - "first.rules"
# - "my/*.rules"

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: ["host.docker.internal:8080"]
# labels:
# service: eduhub-gateway
- targets: ["worker:9464"]
labels:
service: worker
- targets: ["api:3000"]
labels:
service: api
- targets: ["api:9464"]
labels:
service: api
47 changes: 47 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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:
image: edumapper
env_file:
- .envrc-docker # read environment from local direnv settings
environment:
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
command: worker
ports:
- "9465:9464"
api:
image: edumapper
env_file:
- .envrc-docker # read environment from local direnv settings
environment:
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
ports:
- "3000:3000"
- "9464:9464"
command: serve-api
volumes:
redis:
driver: local

0 comments on commit d456dc3

Please sign in to comment.