How julianocosta89/opentelemetry-microservices-demo works
Purpose and entry points
Online Boutique is a polyglot, Kubernetes-oriented e-commerce demo modified to emit OpenTelemetry traces. The user-facing entry point is the Go HTTP frontend in src/frontend/main.go, with request orchestration in src/frontend/handlers.go and gRPC clients in src/frontend/rpc.go. Synthetic traffic enters through Locust at src/loadgenerator/locustfile.py.
Service contract and communication
Services communicate primarily over gRPC, with shared API definitions in pb/demo.proto and health definitions in pb/grpc/health/v1/health.proto. Each service carries generated or local protobuf bindings, creating a contract boundary between independently deployed containers. Dockerfiles under each src/<service>/Dockerfile package the services.
Storefront and browse path
Frontend renders templates/static assets and fans out to catalog, currency, recommendation, ad, and cart services. Product data is file-backed by src/productcatalogservice/products.json, served from src/productcatalogservice/server.go. Currency conversion is a Node service rooted at src/currencyservice/server.js, using conversion data in src/currencyservice/data/currency_conversion.json. Recommendations and ads are Python/Java gRPC services at src/recommendationservice/recommendation_server.py and src/adservice/src/main/java/hipstershop/AdService.java.
Cart persistence boundary
Cart operations are implemented by the C# gRPC service in src/cartservice/src/services/CartService.cs. Storage is abstracted behind src/cartservice/src/cartstore/ICartStore.cs, with Redis-backed implementation in src/cartservice/src/cartstore/RedisCartStore.cs. Redis is deployed as a separate infrastructure workload through kubernetes-manifests/redis.yaml; it is the primary durable/stateful dependency.
Checkout orchestration
Checkout is the central transactional control flow in src/checkoutservice/main.go: it retrieves cart contents, prepares an order, then invokes payment, shipping, and email services. Payment is a mock charge boundary in src/paymentservice/server.js/src/paymentservice/charge.js; shipping cost and fulfillment are in src/shippingservice/main.go and src/shippingservice/quote.go; confirmation notification is handled by src/emailservice/email_server.py.
Observability pipeline
All services are instrumented for OpenTelemetry traces. Instrumented applications export via gRPC to the collector configured in src/otelcollector/conf.yml; the collector deployment is kubernetes-manifests/otelcollector.yaml. It exports traces to logs and Jaeger, deployed via kubernetes-manifests/jaeger.yaml; Jaeger provides the trace UI. Node services explicitly load tracing support through src/currencyservice/tracing.js and src/paymentservice/tracing.js; Java includes src/adservice/agent/opentelemetry-javaagent.jar.
Deployment and runtime topology
The system runs as Docker containers locally via hack/build-and-run.sh, or as Kubernetes workloads defined per service in kubernetes-manifests/frontend.yaml, kubernetes-manifests/checkoutservice.yaml, and sibling manifests. skaffold.yaml is the Kubernetes build/deploy entry point. Optional Istio topology and ingress are represented by istio-manifests/frontend-gateway.yaml and istio-manifests/frontend.yaml. CI/build integration includes cloudbuild.yaml and GitHub workflows under .github/workflows/.
Main entry points: checkoutservice/main.go Checkout · handlers.go Request handlers · frontend/main.go Frontend · demo.proto Shared protobuf contracts
Components 22
Entry & Storefront
- Locust traffic
src/loadgenerator/locustfile.py - Frontend · Renders storefront and orchestrates browse and cart requests.
src/frontend/main.go - Request handlers
src/frontend/handlers.go
Commerce Services
- Product catalog · Serves file-backed product data.
src/productcatalogservice/server.go - Product data
src/productcatalogservice/products.json - Currency
src/currencyservice/server.js - Recommendations
src/recommendationservice/recommendation_server.py - Ads
src/adservice/src/main/java/hipstershop/AdService.java - Cart
src/cartservice/src/services/CartService.cs - Checkout · Prepares orders and coordinates payment, shipping, and email.
src/checkoutservice/main.go - Payment · Mock charge boundary.
src/paymentservice/server.js - Shipping · Quotes and fulfills shipments.
src/shippingservice/main.go - Email
src/emailservice/email_server.py
State & Contracts
- Cart store abstraction
src/cartservice/src/cartstore/ICartStore.cs - Redis cart store
src/cartservice/src/cartstore/RedisCartStore.cs - Redis · Primary durable cart dependency.
kubernetes-manifests/redis.yaml - Shared protobuf contracts
pb/demo.proto
Observability
- OpenTelemetry Collector · Receives application traces over gRPC.
src/otelcollector/conf.yml - Jaeger
kubernetes-manifests/jaeger.yaml
Deployment
- Skaffold deployment
skaffold.yaml - Frontend workload
kubernetes-manifests/frontend.yaml - Checkout workload
kubernetes-manifests/checkoutservice.yaml
Connections 27
- Locust traffic → Frontend: HTTP traffic
- Frontend → Request handlers: routes requests
- Request handlers → Product catalog: gRPC browse
- Request handlers → Currency: gRPC conversion
- Request handlers → Recommendations: gRPC recommendations
- Request handlers → Ads: gRPC ads
- Request handlers → Cart: gRPC cart
- Request handlers → Checkout: gRPC checkout
- Product catalog → Product data: reads
- Cart → Cart store abstraction: uses
- Cart store abstraction → Redis cart store: implemented by
- Redis cart store → Redis: stores carts
- Checkout → Cart: retrieves cart
- Checkout → Payment: charges
- Checkout → Shipping: ships order
- Checkout → Email: sends confirmation
- Shared protobuf contracts → Frontend: gRPC contract
- Shared protobuf contracts → Checkout: gRPC contract
- Shared protobuf contracts → Cart: gRPC contract
- Shared protobuf contracts → Product catalog: gRPC contract
- Frontend → OpenTelemetry Collector: exports traces
- Checkout → OpenTelemetry Collector: exports traces
- OpenTelemetry Collector → Jaeger: exports traces
- Skaffold deployment → Frontend workload: deploys
- Skaffold deployment → Checkout workload: deploys
- Frontend workload → Frontend: runs
- Checkout workload → Checkout: runs