Skip to content

Commit

Permalink
feature: enable metrics and traces with OTEL
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Henrique Medeiros committed Aug 12, 2023
1 parent 00502bf commit a12fa51
Show file tree
Hide file tree
Showing 15 changed files with 532 additions and 68 deletions.
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
.PHONY: clean install test up down upgrade_otel_agent

clean:
@mvn clean
.PHONY: install test version up down restart upgrade_otel_agent

install:
@mvn clean install

test:
@mvn clean test

version:
@mvn versions:set -DgenerateBackupPoms=false -DnewVersion=$1

up:
@docker-compose up -d

down:
@docker-compose down --remove-orphans --volumes

restart:
@docker-compose restart

upgrade_otel_agent:
@echo "Update local version for OTEL Java Agent..."
@mkdir -p agents
@curl -o agents/otel/opentelemetry-javaagent.jar -L https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
@curl -sL https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases | grep -oE 'releases/tag/v[0-9]+\.[0-9]+\.[0-9]+' | cut -d'/' -f3 | sort -V | tail -n 1 > agents/otel/version.txt
@VERSION=$$(cat agents/otel/version.txt) && echo "OTEL Java Agent local was updated to $$VERSION"
@rm -rf agents/otel/version.txt
@curl -o agents/opentelemetry-javaagent.jar -L https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
@curl -sL https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases | grep -oE 'releases/tag/v[0-9]+\.[0-9]+\.[0-9]+' | cut -d'/' -f3 | sort -V | tail -n 1 > agents/version.txt
@VERSION=$$(cat agents/version.txt) && echo "OTEL Java Agent local was updated to $$VERSION"
@rm -rf agents/version.txt
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ make down
Variáveis de ambiente:
```shell
OTEL_TRACES_EXPORTER=jaeger
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:14250
OTEL_METRICS_EXPORTER=none
OTEL_METRICS_EXPORTER=otlp
OTEL_EXPORTER_OTLP_METRICS_COMPRESSION=gzip
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://localhost:4317
OTEL_TRACES_EXPORTER=otlp
OTEL_EXPORTER_OTLP_TRACES_COMPRESSION=gzip
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4317
OTEL_LOGS_EXPORTER=none
OTEL_SERVICE_NAME=billionaire-api
```

Argumentos de VM:
```shell
-javaagent:./agents/otel/opentelemetry-javaagent.jar
-javaagent:./agents/opentelemetry-javaagent.jar
```
Binary file not shown.
23 changes: 0 additions & 23 deletions agents/prometheus/prometheus-configuration.yaml

This file was deleted.

91 changes: 63 additions & 28 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ services:
volumes:
- mysql-data:/bitnami/mysql/data
environment:
- MYSQL_REPLICATION_MODE=master
- MYSQL_REPLICATION_USER=repl_user
- MYSQL_USER=master
- MYSQL_DATABASE=billionaires
- ALLOW_EMPTY_PASSWORD=yes
- MYSQL_ROOT_PASSWORD=root
MYSQL_REPLICATION_MODE: master
MYSQL_REPLICATION_USER: repl_user
MYSQL_USER: master
MYSQL_DATABASE: billionaires
ALLOW_EMPTY_PASSWORD: yes
MYSQL_ROOT_PASSWORD: root
healthcheck:
test: ["CMD", "/opt/bitnami/scripts/mysql/healthcheck.sh"]
interval: 15s
Expand All @@ -36,14 +36,14 @@ services:
depends_on:
- master-db
environment:
- MYSQL_REPLICATION_MODE=slave
- MYSQL_REPLICATION_USER=repl_user
- MYSQL_USER=replica
- MYSQL_DATABASE=billionaires
- MYSQL_MASTER_HOST=master-db
- MYSQL_MASTER_PORT_NUMBER=3306
- MYSQL_MASTER_ROOT_PASSWORD=root
- ALLOW_EMPTY_PASSWORD=yes
MYSQL_REPLICATION_MODE: slave
MYSQL_REPLICATION_USER: repl_user
MYSQL_USER: replica
MYSQL_DATABASE: billionaires
MYSQL_MASTER_HOST: master-db
MYSQL_MASTER_PORT_NUMBER: 3306
MYSQL_MASTER_ROOT_PASSWORD: root
ALLOW_EMPTY_PASSWORD: yes
healthcheck:
test: ["CMD", "/opt/bitnami/scripts/mysql/healthcheck.sh"]
interval: 15s
Expand All @@ -53,7 +53,12 @@ services:
jaeger:
image: jaegertracing/all-in-one:latest
container_name: jaeger
hostname: jaeger
restart: "no"
environment:
COLLECTOR_OTLP_ENABLED: true
METRICS_STORAGE_TYPE: prometheus
PROMETHEUS_SERVER_URL: http://prometheus:9090
ports:
# Agent Zipkin Compact
- "5775:5775/udp"
Expand All @@ -69,37 +74,67 @@ services:
- "14268:14268"
# Collector gRPC
- "14250:14250"
environment:
- METRICS_STORAGE_TYPE=prometheus
- PROMETHEUS_SERVER_URL=http://prometheus:9090
depends_on:
- prometheus
networks:
- multi-data-sources

otel-collector:
image: otel/opentelemetry-collector-contrib:0.68.0
container_name: otel-collector
hostname: otel-collector
restart: "no"
command:
- --config=/etc/otel-collector-config.yaml
ports:
- "4317:4317"
- "4318:4318"
- "8888:8888"
- "9999:9999"
volumes:
- ./otel-dev/otel-collector.yaml:/etc/otel-collector-config.yaml
depends_on:
- jaeger
- prometheus
networks:
- multi-data-sources

prometheus:
image: prom/prometheus:v2.42.0
image: prom/prometheus:v2.41.0
container_name: prometheus
hostname: prometheus
restart: "no"
command:
- --config.file=/etc/prometheus/prometheus-configuration.yaml
- --web.console.templates=/etc/prometheus/consoles
- --web.console.libraries=/etc/prometheus/console_libraries
- --storage.tsdb.retention.time=1h
- --storage.tsdb.path=/prometheus
- --web.enable-lifecycle
- --web.route-prefix=/
- --config.file=/etc/prometheus/prometheus.yml
- --web.enable-remote-write-receiver
ports:
- "9090:9090"
volumes:
- prometheus-data:/prometheus
- ./agents/prometheus:/etc/prometheus
- ./otel-dev/prometheus.yaml:/etc/prometheus/prometheus.yml
networks:
- multi-data-sources

grafana:
image: grafana/grafana-oss:9.3.6
image: grafana/grafana:9.3.2
container_name: grafana
hostname: grafana
restart: "no"
environment:
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
GF_AUTH_ANONYMOUS_ENABLED: true
GF_AUTH_BASIC_ENABLED: false
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
- GF_SERVER_DOMAIN=localhost
volumes:
- grafana-data:/var/lib/grafana
- ./otel-dev/ds-prometheus.yaml:/etc/grafana/provisioning/datasources/datasource.yml
depends_on:
- prometheus
networks:
- multi-data-sources

Expand Down
Loading

0 comments on commit a12fa51

Please sign in to comment.