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

feat: ✨ add trace and metrics pipelines for cqrs operations #91

Closed
wants to merge 15 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,5 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

.cycle/
94 changes: 54 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,36 @@ install-tools:

.PHONY: run-catalogs-write-service
run-catalogs-write-service:
@./scripts/run.sh catalog_write_service
@./scripts/run.sh catalogwriteservice

.PHONY: run-catalog-read-service
run-catalog-read-service:
@./scripts/run.sh catalog_read_service
@./scripts/run.sh catalogreadservice

.PHONY: run-order-service
run-order-service:
@./scripts/run.sh order_service
@./scripts/run.sh orderservice

.PHONY: build
build:
@./scripts/build.sh pkg
@./scripts/build.sh catalog_write_service
@./scripts/build.sh catalog_read_service
@./scripts/build.sh order_service
@./scripts/build.sh catalogwriteservice
@./scripts/build.sh catalogreadservice
@./scripts/build.sh orderservice

.PHONY: update-dependencies
update-dependencies:
@./scripts/update-dependencies.sh pkg
@./scripts/update-dependencies.sh catalogwriteservice
@./scripts/update-dependencies.sh catalogreadservice
@./scripts/update-dependencies.sh orderservice

.PHONY: install-dependencies
install-dependencies:
@./scripts/install-dependencies.sh pkg
@./scripts/install-dependencies.sh catalog_write_service
@./scripts/install-dependencies.sh catalog_read_service
@./scripts/install-dependencies.sh order_service
@./scripts/install-dependencies.sh catalogwriteservice
@./scripts/install-dependencies.sh catalogreadservice
@./scripts/install-dependencies.sh orderservice

.PHONY: docker-compose-infra-up
docker-compose-infra-up:
Expand All @@ -37,33 +44,33 @@ docker-compose-infra-down:

.PHONY: openapi
openapi:
@./scripts/openapi.sh catalog_write_service
@./scripts/openapi.sh catalog_read_service
@./scripts/openapi.sh order_service
@./scripts/openapi.sh catalogwriteservice
@./scripts/openapi.sh catalogreadservice
@./scripts/openapi.sh orderservice

# https://stackoverflow.com/questions/13616033/install-protocol-buffers-on-windows
.PHONY: proto
proto:
@./scripts/proto.sh catalog_write_service
@./scripts/proto.sh order_service
@./scripts/proto.sh catalogwriteservice
@./scripts/proto.sh orderservice

.PHONY: unit-test
unit-test:
@./scripts/test.sh catalog_read_service unit
@./scripts/test.sh catalog_write_service unit
@./scripts/test.sh order_service unit
@./scripts/test.sh catalogreadservice unit
@./scripts/test.sh catalogwriteservice unit
@./scripts/test.sh orderservice unit

.PHONY: integration-test
integration-test:
@./scripts/test.sh catalog_read_service integration
@./scripts/test.sh catalog_write_service integration
@./scripts/test.sh order_service integration
@./scripts/test.sh catalogreadservice integration
@./scripts/test.sh catalogwriteservice integration
@./scripts/test.sh orderservice integration

.PHONY: e2e-test
e2e-test:
@./scripts/test.sh catalog_read_service e2e
@./scripts/test.sh catalog_write_service e2e
@./scripts/test.sh order_service e2e
@./scripts/test.sh catalogreadservice e2e
@./scripts/test.sh catalogwriteservice e2e
@./scripts/test.sh orderservice e2e

#.PHONY: load-test
#load-test:
Expand All @@ -73,16 +80,16 @@ e2e-test:

.PHONY: format
format:
@./scripts/format.sh catalog_write_service
@./scripts/format.sh catalog_read_service
@./scripts/format.sh order_service
@./scripts/format.sh catalogwriteservice
@./scripts/format.sh catalogreadservice
@./scripts/format.sh orderservice
@./scripts/format.sh pkg

.PHONY: lint
lint:
@./scripts/lint.sh catalog_write_service
@./scripts/lint.sh catalog_read_service
@./scripts/lint.sh order_service
@./scripts/lint.sh catalogwriteservice
@./scripts/lint.sh catalogreadservice
@./scripts/lint.sh orderservice
@./scripts/lint.sh pkg

# https://github.com/golang-migrate/migrate/blob/856ea12df9d230b0145e23d951b7dbd6b86621cb/database/postgres/TUTORIAL.md
Expand All @@ -91,22 +98,29 @@ lint:
# https://github.com/golang-migrate/migrate/tree/856ea12df9d230b0145e23d951b7dbd6b86621cb/cmd/migrate#usage
.PHONY: go-migrate
go-migrate:
@./scripts/go-migrate.sh -p ./internal/services/catalog_write_service/db/migrations/go-migrate -c create -n create_product_table
@./scripts/go-migrate.sh -p ./internal/services/catalog_write_service/db/migrations/go-migrate -c up -o postgres://postgres:postgres@localhost:5432/catalogs_service?sslmode=disable
@./scripts/go-migrate.sh -p ./internal/services/catalog_write_service/db/migrations/go-migrate -c down -o postgres://postgres:postgres@localhost:5432/catalogs_service?sslmode=disable
@./scripts/go-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/go-migrate -c create -n create_product_table
@./scripts/go-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/go-migrate -c up -o postgres://postgres:postgres@localhost:5432/catalogs_service?sslmode=disable
@./scripts/go-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/go-migrate -c down -o postgres://postgres:postgres@localhost:5432/catalogs_service?sslmode=disable

# https://github.com/pressly/goose#usage
.PHONY: goose-migrate
goose-migrate:
@./scripts/goose-migrate.sh -p ./internal/services/catalog_write_service/db/migrations/goose-migrate -c create -n create_product_table
@./scripts/goose-migrate.sh -p ./internal/services/catalog_write_service/db/migrations/goose-migrate -c up -o "user=postgres password=postgres dbname=catalogs_service sslmode=disable"
@./scripts/goose-migrate.sh -p ./internal/services/catalog_write_service/db/migrations/goose-migrate -c down -o "user=postgres password=postgres dbname=catalogs_service sslmode=disable"
@./scripts/goose-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/goose-migrate -c create -n create_product_table
@./scripts/goose-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/goose-migrate -c up -o "user=postgres password=postgres dbname=catalogs_service sslmode=disable"
@./scripts/goose-migrate.sh -p ./internal/services/catalogwriteservice/db/migrations/goose-migrate -c down -o "user=postgres password=postgres dbname=catalogs_service sslmode=disable"

# https://atlasgo.io/guides/orms/gorm
.PHONY: atlas
atlas:
@./scripts/atlas-migrate.sh -c gorm-sync -p "./internal/services/catalog_write_service"
@./scripts/atlas-migrate.sh -c apply -p "./internal/services/catalog_write_service" -o "postgres://postgres:postgres@localhost:5432/catalogs_service?sslmode=disable"
@./scripts/atlas-migrate.sh -c gorm-sync -p "./internal/services/catalogwriteservice"
@./scripts/atlas-migrate.sh -c apply -p "./internal/services/catalogwriteservice" -o "postgres://postgres:postgres@localhost:5432/catalogs_service?sslmode=disable"

.PHONY: cycle-check
cycle-check:
cd internal/pkg && goimportcycle -dot imports.dot dot -Tpng -o cycle/pkg.png imports.dot
cd internal/services/catalogwriteservice && goimportcycle -dot imports.dot dot -Tpng -o cycle/catalogwriteservice.png imports.dot
cd internal/services/catalogwriteservice && goimportcycle -dot imports.dot dot -Tpng -o cycle/catalogwriteservice.png imports.dot
cd internal/services/orderservice && goimportcycle -dot imports.dot dot -Tpng -o cycle/orderservice.png imports.dot

#.PHONY: c4
#c4:
Expand All @@ -123,6 +137,6 @@ pkg-mocks:

.PHONY: services-mocks
services-mocks:
cd internal/services/catalog_write_service && mockery --output mocks --all
cd internal/services/catalog_read_service && mockery --output mocks --all
cd internal/services/order_service && mockery --output mocks --all
cd internal/services/catalogwriteservice && mockery --output mocks --all
cd internal/services/catalogreadservice && mockery --output mocks --all
cd internal/services/orderservice && mockery --output mocks --all

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 43 additions & 2 deletions deployments/docker-compose/.env
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ PROMETHEUS_PORT=9090
PROMETHEUS_HOST_PORT=9090
KIBANA_PORT=5601
KIBANA_HOST_PORT=5601
ELASTIC_PORT=9200
ELASTIC_HOST_PORT=9200

EVENTSTORE_PORT=2113
EVENTSTORE_HOST_PORT=2113
EVENTSTORE_TCP_HOST_PORT=1113
Expand All @@ -44,3 +43,45 @@ CUSTOMERS_SVC_PORT=8000
ORDERS_SVC_PORT=5000
IDENTITY_SVC_PORT=7000

# ******************
# Dependent Services
# ******************
# Kafka
KAFKA_SERVICE_PORT=9092

# Redis
REDIS_PORT=6379

# Elastic
ELASTIC_PORT=9200
ELASTIC_HOST_PORT=9200

# ********************
# Telemetry Components
# ********************
# Grafana
GRAFANA_SERVICE_PORT=3000
GRAFANA_SERVICE_HOST=grafana

# Jaeger
JAEGER_SERVICE_PORT=16686
JAEGER_SERVICE_HOST=jaeger

# Prometheus
PROMETHEUS_SERVICE_PORT=9090
PROMETHEUS_SERVICE_HOST=prometheus
PROMETHEUS_ADDR=${PROMETHEUS_SERVICE_HOST}:${PROMETHEUS_SERVICE_PORT}


# OpenTelemetry Collector
OTEL_COLLECTOR_HOST=otelcol
OTEL_COLLECTOR_PORT_GRPC=4317
OTEL_COLLECTOR_PORT_HTTP=4318
OTEL_EXPORTER_OTLP_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT_GRPC}
PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:8080/otlp-http/v1/traces

# OpenTelemetry Resource Definitions
OTEL_RESOURCE_ATTRIBUTES="service.namespace=ecommerce"

# Metrics Temporality
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative
Loading
Loading