Skip to content

Commit

Permalink
feat: start project
Browse files Browse the repository at this point in the history
  • Loading branch information
gbzarelli committed Jan 5, 2025
0 parents commit 7ecdcb2
Show file tree
Hide file tree
Showing 92 changed files with 4,391 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .docker-compose-local/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3.8"

services:

app-db-migration:
build:
context: ../
dockerfile: Dockerfile
entrypoint: [ "/flyway/flyway" ]
command: "-url=jdbc:mysql://database -schemas=sampledb -user=root -password=rpassword -connectRetries=60 migrate -locations=filesystem:/flyway/sql"
networks:
- database-net

app:
build:
context: ../
dockerfile: Dockerfile
environment:
KAFKA_BOOTSTRAP_SERVERS: kafka:29092
DATABASE_URL: jdbc:mysql://database/sampledb
DATABASE_USER: root
DATABASE_PASSWORD: rpassword
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: http://otel-collector:4318/v1/metrics
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: http://otel-collector:4318/v1/traces
ports:
- "8080:8080"
depends_on:
- app-db-migration
networks:
- database-net
- kafka-net
- observability-net

networks:
database-net:
driver: bridge
kafka-net:
driver: bridge
observability-net:
driver: bridge
16 changes: 16 additions & 0 deletions .docker-compose-local/config/ds-prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: 1

deleteDatasources:
- name: Prometheus
orgId: 1

datasources:
- name: Prometheus
type: prometheus
url: http://prometheus:9090
access: proxy
orgId: 1
isDefault: true
basicAuth: false
version: 1
editable: false
109 changes: 109 additions & 0 deletions .docker-compose-local/config/otel-collector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Configuration file for OpenTelemetry Collector.
# This file defines receivers, exporters, processors, and service pipelines for telemetry data collection and processing.

receivers:
# Receivers collect telemetry data from applications or other sources.

otlp: # OpenTelemetry Protocol receiver.
protocols:
http:
endpoint: 0.0.0.0:4318 # HTTP endpoint for receiving telemetry data.
grpc:
endpoint: 0.0.0.0:4317 # gRPC endpoint for receiving telemetry data.

prometheus: # Prometheus receiver to scrape metrics from endpoints.
config:
scrape_configs:
- job_name: otelcol-metrics
scrape_interval: 60s # Frequency for scraping metrics.
static_configs:
- targets: ["otel-collector:8888"] # Target endpoint for metrics scraping.
- job_name: spanmetrics
scrape_interval: 60s # Frequency for scraping span metrics.
static_configs:
- targets: ["otel-collector:9999"] # Target endpoint for span metrics scraping.
metric_relabel_configs:
- source_labels: [span_kind]
regex: SPAN_KIND_SERVER
action: keep # Keep only server spans.
- source_labels: [http_user_agent, request_header_user_agent, http_request_header_user_agent]
regex: kube-probe/.*|Prometheus/.*|Gravitee.io/.*|ELB-HealthChecker/.*
action: drop # Drop metrics generated by probes or health checkers.
- regex: http_user_agent|request_header_user_agent|http_request_header_user_agent
action: labeldrop # Remove specified labels.

otlp/spanmetrics: # Separate receiver for span metrics.
protocols:
grpc:
endpoint: 0.0.0.0:12345 # gRPC endpoint for receiving span metrics.

exporters:
# Exporters send processed telemetry data to external systems.

prometheusremotewrite:
endpoint: "http://prometheus:9090/api/v1/write" # Export metrics to Prometheus.

logging:
logLevel: debug # Log telemetry data for debugging.

otlp/jaeger:
endpoint: "jaeger:4317" # Export traces to Jaeger.
tls:
insecure: true # Disable TLS verification (for testing or internal use).

prometheus/spanmetrics:
endpoint: 0.0.0.0:9999 # Endpoint for exposing span metrics to Prometheus.
metric_expiration: 75s # Time to keep metrics before expiring them.

processors:
# Processors transform telemetry data before exporting.

batch: # Batch processor to group data for efficient processing.

tail_sampling: # Sampling processor for traces.
decision_wait: 45s # Wait time for sampling decision.
num_traces: 50000 # Maximum number of traces to sample.
policies:
- name: ignore-http-user-agent
type: string_attribute
string_attribute:
key: http.user_agent
values: [kube-probe/*, Prometheus/*, Gravitee.io/*, ELB-HealthChecker/*]
enabled_regex_matching: true
invert_match: true # Include traces not matching these values.
- name: sampling-50%
type: probabilistic
probabilistic:
sampling_percentage: 50 # Sample 50% of traces.

spanmetrics: # Processor for creating span metrics.
dimensions:
- name: http.method
- name: http.status_code
- name: http.user_agent
- name: request.header.user-agent
- name: http.request.header-user-agent
latency_histogram_buckets: [2ms, 10ms, 100ms, 1s, 10s] # Define latency buckets.
metrics_exporter: prometheus/spanmetrics # Export processed metrics.

service:
# Service defines the pipeline for processing telemetry data.

telemetry:
metrics:
address: 0.0.0.0:8888 # Address to expose collector's own metrics.

pipelines:
metrics/spanmetrics: # Pipeline for span metrics.
receivers: [otlp/spanmetrics]
exporters: [prometheus/spanmetrics]

traces: # Pipeline for trace data.
receivers: [otlp]
processors: [spanmetrics, tail_sampling, batch]
exporters: [logging, otlp/jaeger]

metrics: # Pipeline for general metrics.
receivers: [otlp, prometheus]
processors: [batch]
exporters: [logging, prometheusremotewrite]
1 change: 1 addition & 0 deletions .docker-compose-local/config/prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scrape_configs: [ ]
60 changes: 60 additions & 0 deletions .docker-compose-local/infrastructure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: "3.8"

services:

database:
image: mysql:8.0.28
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: rpassword
MYSQL_DATABASE: sampledb
MYSQL_USER: user
MYSQL_PASSWORD: password
networks:
- database-net

flyway:
image: flyway/flyway:7.5.2
command: -url=jdbc:mysql://database -schemas=sampledb -user=root -password=rpassword -connectRetries=60 migrate
volumes:
- ../resources/flyway/db/migration:/flyway/sql
depends_on:
- database
networks:
- database-net

zookeeper:
image: confluentinc/cp-zookeeper:7.5.0
container_name: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
networks:
- kafka-net

kafka:
image: confluentinc/cp-kafka:7.5.0
container_name: kafka
ports:
- "9092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,INTERNAL://kafka:29092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,INTERNAL://kafka:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,INTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
depends_on:
- zookeeper
networks:
- kafka-net

networks:
database-net:
driver: bridge
kafka-net:
driver: bridge
67 changes: 67 additions & 0 deletions .docker-compose-local/observability.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: "3.8"

services:

jaeger:
image: jaegertracing/all-in-one:1.40.0
ports:
- "16686:16686"
environment:
- COLLECTOR_OTLP_ENABLED=true
- METRICS_STORAGE_TYPE=prometheus
- PROMETHEUS_SERVER_URL=http://prometheus:9090
networks:
- observability-net

otel-collector:
image: otel/opentelemetry-collector-contrib:0.68.0
command: ["--config=/etc/otel-collector-config.yaml"]
volumes:
- ./config/otel-collector.yaml:/etc/otel-collector-config.yaml
ports:
- "4317:4317"
- "4318:4318"
- "8888:8888"
- "9999:9999"
depends_on:
- jaeger
- prometheus
networks:
- observability-net

prometheus:
image: prom/prometheus:v2.41.0
command:
- --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
volumes:
- ./config/prometheus.yaml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
networks:
- observability-net

grafana:
image: grafana/grafana:9.3.2
ports:
- "3000:3000"
volumes:
- ./config/ds-prometheus.yaml:/etc/grafana/provisioning/datasources/datasource.yml
environment:
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_BASIC_ENABLED=false
depends_on:
- prometheus
networks:
- observability-net

networks:
observability-net:
driver: bridge
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/mvnw text eol=lf
*.cmd text eol=crlf
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
Binary file added .images/acceptance-tests.webp
Binary file not shown.
Binary file added .images/banner.webp
Binary file not shown.
Binary file added .images/hexagonal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .maven-dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
acceptance-test/target/docker/**
19 changes: 19 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
Loading

0 comments on commit 7ecdcb2

Please sign in to comment.