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

Initial Code Donation (Do Not Merge w/ out code owner approval) #23

Merged
merged 7 commits into from
May 19, 2022
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ content of "Unreleased" section content will generate release notes for the
release.

## Unreleased

* The initial code base is donated from a
[fork](https://github.com/julianocosta89/opentelemetry-microservices-demo) of
the [Google microservices
demo](https://github.com/GoogleCloudPlatform/microservices-demo) with express
knowledge of the owners. The pre-existing copyrights will remain. Any
future significant modifications will be credited to OpenTelemetry Authors.
83 changes: 76 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,74 @@
# Webstore Demo

## Under Construction

This repo is a work in progress

## Screenshots from the Online Boutique

| Home Page | Checkout Screen |
| ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| [![Screenshot of store homepage](./docs/img/online-boutique-frontend-1.png)](./docs/img/online-boutique-frontend-1.png) | [![Screenshot of checkout screen](./docs/img/online-boutique-frontend-2.png)](./docs/img/online-boutique-frontend-2.png) |

## Screenshots from Jaeger

| Jaeger UI | Trace View |
| ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| [![Screenshot of Jaeger UI](./docs/img/jaeger-ui.png)](./docs/img/jaeger-ui.png) | [![Screenshot of Trace View](./docs/img/jaeger-trace-view.png)](./docs/img/jaeger-trace-view.png) |

## Architecture

**Online Boutique** is composed of 10 microservices written in different
languages that talk to each other over gRPC. Plus one Load Generator which uses
Locust to fake user traffic.
See the [Development Principles](/docs/development-principles.md) doc for more information.

[![Architecture of microservices](./docs/img/architecture-diagram.png)](./docs/img/architecture-diagram.png)

Find **Protocol Buffers Descriptions** at the [`./pb` directory](./pb/README.md).

| Service | Language | Description |
| ---------------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| [frontend](./src/frontend/README.md) | Go | Exposes an HTTP server to serve the website. Does not require signup/login and generates session IDs for all users automatically. |
| [cartservice](./src/cartservice/README.md) | C# | Stores the items in the user's shopping cart in Redis and retrieves it. |
| [productcatalogservice](./src/productcatalogservice/README.md) | Go | Provides the list of products from a JSON file and ability to search products and get individual products. |
| [currencyservice](./src/currencyservice/README.md) | Node.js | Converts one money amount to another currency. Uses real values fetched from European Central Bank. It's the highest QPS service. |
| [paymentservice](./src/paymentservice/README.md) | Node.js | Charges the given credit card info (mock) with the given amount and returns a transaction ID. |
| [shippingservice](./src/shippingservice/README.md) | Go | Gives shipping cost estimates based on the shopping cart. Ships items to the given address (mock) |
| [emailservice](./src/emailservice/README.md) | Python | Sends users an order confirmation email (mock). |
| [checkoutservice](./src/checkoutservice/README.md) | Go | Retrieves user cart, prepares order and orchestrates the payment, shipping and the email notification. |
| [recommendationservice](./src/recommendationservice/README.md) | Python | Recommends other products based on what's given in the cart. |
| [adservice](./src/adservice/README.md) | Java | Provides text ads based on given context words. |
| [loadgenerator](./src/loadgenerator/README.md) | Python/Locust | Continuously sends requests imitating realistic user shopping flows to the frontend. |

## Features

- **[Kubernetes](https://kubernetes.io):**
The app is designed to run on Kubernetes (both locally , as well as on the cloud).
- **[Docker](https://docs.docker.com):**
This forked sample can also be executed only with Docker.
- **[gRPC](https://grpc.io):**
Microservices use a high volume of gRPC calls to communicate to each other.
- **[OpenTelemetry Traces](https://opentelemetry.io):**
All services are instrumented using OpenTelemetry available instrumentation libraries.
- **[OpenTelemetry Collector](https://opentelemetry.io/docs/collector/getting-started):**
All services are instrumented and sending the generated traces to the
OpenTelemetry Collector via gRPC. The received traces are then exported to the
logs and to Jaeger.
- **[Jager](https://www.jaegertracing.io):**
All generated traces are being sent to Jaeger.
- **Synthetic Load Generation:**
The application demo comes with a background job that creates realistic usage
patterns on the website using [Locust](https://locust.io/) load generator.

## Local Development

TBD

## Demos featuring Online Boutique

TBD

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md)
Expand All @@ -17,17 +86,17 @@ For edit access, get in touch on
[Maintainers](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer)
([@open-telemetry/demo-webstore-maintainers](https://github.com/orgs/open-telemetry/teams/demo-webstore-maintainers)):

* [Austin Parker](https://github.com/austinlparker), Lightstep
* [Carter Socha](https://github.com/cartersocha), Microsoft
* [Morgan McLean](https://github.com/mtwo), Splunk
- [Austin Parker](https://github.com/austinlparker), Lightstep
- [Carter Socha](https://github.com/cartersocha), Microsoft
- [Morgan McLean](https://github.com/mtwo), Splunk

[Approvers](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver)
([@open-telemetry/demo-webstore-approvers](https://github.com/orgs/open-telemetry/teams/demo-webstore-approvers)):

* [Joe Sirianni](https://github.com/jsirianni), ObservIQ
* [Juliano Costa](https://github.com/julianocosta89), Dynatrace
* [Michael Maxwell](https://github.com/mic-max), Microsoft
* [Reiley Yang](https://github.com/reyang), Microsoft
- [Joe Sirianni](https://github.com/jsirianni), ObservIQ
- [Juliano Costa](https://github.com/julianocosta89), Dynatrace
- [Michael Maxwell](https://github.com/mic-max), Microsoft
- [Reiley Yang](https://github.com/reyang), Microsoft

### Thanks to all the people who have contributed

Expand Down
Binary file added docs/img/architecture-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/jaeger-trace-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/jaeger-ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/memorystore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/online-boutique-frontend-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/online-boutique-frontend-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions pb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Read Me

This is a placeholder
262 changes: 262 additions & 0 deletions pb/demo.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
// Copyright 2020 Google LLC
//
// Licensed 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.

syntax = "proto3";

package hipstershop;

option go_package = "genproto/hipstershop";

// -----------------Cart service-----------------

service CartService {
rpc AddItem(AddItemRequest) returns (Empty) {}
rpc GetCart(GetCartRequest) returns (Cart) {}
rpc EmptyCart(EmptyCartRequest) returns (Empty) {}
}

message CartItem {
string product_id = 1;
int32 quantity = 2;
}

message AddItemRequest {
string user_id = 1;
CartItem item = 2;
}

message EmptyCartRequest {
string user_id = 1;
}

message GetCartRequest {
string user_id = 1;
}

message Cart {
string user_id = 1;
repeated CartItem items = 2;
}

message Empty {}

// ---------------Recommendation service----------

service RecommendationService {
rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse){}
}

message ListRecommendationsRequest {
string user_id = 1;
repeated string product_ids = 2;
}

message ListRecommendationsResponse {
repeated string product_ids = 1;
}

// ---------------Product Catalog----------------

service ProductCatalogService {
rpc ListProducts(Empty) returns (ListProductsResponse) {}
rpc GetProduct(GetProductRequest) returns (Product) {}
rpc SearchProducts(SearchProductsRequest) returns (SearchProductsResponse) {}
}

message Product {
string id = 1;
string name = 2;
string description = 3;
string picture = 4;
Money price_usd = 5;

// Categories such as "clothing" or "kitchen" that can be used to look up
// other related products.
repeated string categories = 6;
}

message ListProductsResponse {
repeated Product products = 1;
}

message GetProductRequest {
string id = 1;
}

message SearchProductsRequest {
string query = 1;
}

message SearchProductsResponse {
repeated Product results = 1;
}

// ---------------Shipping Service----------

service ShippingService {
rpc GetQuote(GetQuoteRequest) returns (GetQuoteResponse) {}
rpc ShipOrder(ShipOrderRequest) returns (ShipOrderResponse) {}
}

message GetQuoteRequest {
Address address = 1;
repeated CartItem items = 2;
}

message GetQuoteResponse {
Money cost_usd = 1;
}

message ShipOrderRequest {
Address address = 1;
repeated CartItem items = 2;
}

message ShipOrderResponse {
string tracking_id = 1;
}

message Address {
string street_address = 1;
string city = 2;
string state = 3;
string country = 4;
int32 zip_code = 5;
}

// -----------------Currency service-----------------

service CurrencyService {
rpc GetSupportedCurrencies(Empty) returns (GetSupportedCurrenciesResponse) {}
rpc Convert(CurrencyConversionRequest) returns (Money) {}
}

// Represents an amount of money with its currency type.
message Money {
// The 3-letter currency code defined in ISO 4217.
string currency_code = 1;

// The whole units of the amount.
// For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
int64 units = 2;

// Number of nano (10^-9) units of the amount.
// The value must be between -999,999,999 and +999,999,999 inclusive.
// If `units` is positive, `nanos` must be positive or zero.
// If `units` is zero, `nanos` can be positive, zero, or negative.
// If `units` is negative, `nanos` must be negative or zero.
// For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
int32 nanos = 3;
}

message GetSupportedCurrenciesResponse {
// The 3-letter currency code defined in ISO 4217.
repeated string currency_codes = 1;
}

message CurrencyConversionRequest {
Money from = 1;

// The 3-letter currency code defined in ISO 4217.
string to_code = 2;
}

// -------------Payment service-----------------

service PaymentService {
rpc Charge(ChargeRequest) returns (ChargeResponse) {}
}

message CreditCardInfo {
string credit_card_number = 1;
int32 credit_card_cvv = 2;
int32 credit_card_expiration_year = 3;
int32 credit_card_expiration_month = 4;
}

message ChargeRequest {
Money amount = 1;
CreditCardInfo credit_card = 2;
}

message ChargeResponse {
string transaction_id = 1;
}

// -------------Email service-----------------

service EmailService {
rpc SendOrderConfirmation(SendOrderConfirmationRequest) returns (Empty) {}
}

message OrderItem {
CartItem item = 1;
Money cost = 2;
}

message OrderResult {
string order_id = 1;
string shipping_tracking_id = 2;
Money shipping_cost = 3;
Address shipping_address = 4;
repeated OrderItem items = 5;
}

message SendOrderConfirmationRequest {
string email = 1;
OrderResult order = 2;
}


// -------------Checkout service-----------------

service CheckoutService {
rpc PlaceOrder(PlaceOrderRequest) returns (PlaceOrderResponse) {}
}

message PlaceOrderRequest {
string user_id = 1;
string user_currency = 2;

Address address = 3;
string email = 5;
CreditCardInfo credit_card = 6;
}

message PlaceOrderResponse {
OrderResult order = 1;
}

// ------------Ad service------------------

service AdService {
rpc GetAds(AdRequest) returns (AdResponse) {}
}

message AdRequest {
// List of important key words from the current page describing the context.
repeated string context_keys = 1;
}

message AdResponse {
repeated Ad ads = 1;
}

message Ad {
// url to redirect to when an ad is clicked.
string redirect_url = 1;

// short advertisement text to display.
string text = 2;
}
Loading