Skip to content

Commit 860a35d

Browse files
author
Juliano Costa
authored
Add PHP quote service (#345)
1 parent 82f6cb0 commit 860a35d

File tree

18 files changed

+366
-1
lines changed

18 files changed

+366
-1
lines changed

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ PAYMENT_SERVICE_ADDR=paymentservice:${PAYMENT_SERVICE_PORT}
3737
PRODUCT_CATALOG_SERVICE_PORT=3550
3838
PRODUCT_CATALOG_SERVICE_ADDR=productcatalogservice:${PRODUCT_CATALOG_SERVICE_PORT}
3939

40+
QUOTE_SERVICE_PORT=8090
41+
QUOTE_SERVICE_ADDR=quoteservice:${QUOTE_SERVICE_PORT}
42+
4043
RECOMMENDATION_SERVICE_PORT=9001
4144
RECOMMENDATION_SERVICE_ADDR=recommendationservice:${RECOMMENDATION_SERVICE_PORT}
4245

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ build
3131
src/frontend/protos
3232
next-env.d.ts
3333
src/frontend/cypress/videos
34-
src/frontend/cypress/screenshots
34+
src/frontend/cypress/screenshots
35+
vendor/
36+
composer.lock

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,7 @@ significant modifications will be credited to OpenTelemetry Authors.
8989
([#331](https://github.com/open-telemetry/opentelemetry-demo/pull/331))
9090
* Add span events to shipping service
9191
([#344](https://github.com/open-telemetry/opentelemetry-demo/pull/344))
92+
* Add PHP quote service
93+
([#345](https://github.com/open-telemetry/opentelemetry-demo/pull/345))
9294
* Improve initial run time, without a build
9395
([#362](https://github.com/open-telemetry/opentelemetry-demo/pull/362))

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,27 @@ services:
278278
- otelcol
279279
logging: *logging
280280

281+
quoteservice:
282+
image: ${IMAGE_NAME}:${IMAGE_VERSION}-quoteservice
283+
container_name: quoteservice
284+
build:
285+
context: ./
286+
dockerfile: ./src/quoteservice/Dockerfile
287+
ports:
288+
- "${QUOTE_SERVICE_PORT}"
289+
environment:
290+
# OTEL_EXPORTER_OTLP_TRACES_ENDPOINT # Not working for PHP
291+
- QUOTE_SERVICE_PORT
292+
- OTEL_SERVICE_NAME=quoteservice
293+
- OTEL_EXPORTER_OTLP_ENDPOINT=otelcol:4317
294+
- OTEL_TRACES_SAMPLER=parentbased_always_on
295+
- OTEL_TRACES_EXPORTER=otlp
296+
- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc
297+
- OTEL_PHP_TRACES_PROCESSOR=simple
298+
depends_on:
299+
- otelcol
300+
logging: *logging
301+
281302
# RecommendationService
282303
recommendationservice:
283304
image: ${IMAGE_NAME}:${IMAGE_VERSION}-recommendationservice
@@ -313,6 +334,7 @@ services:
313334
- "${SHIPPING_SERVICE_PORT}"
314335
environment:
315336
- SHIPPING_SERVICE_PORT
337+
- QUOTE_SERVICE_ADDR
316338
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
317339
- OTEL_SERVICE_NAME=shippingservice
318340
depends_on:

docs/manual_span_attributes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ This document contains the list of manual Span Attributes used throughout the de
9696
| `app.products.count` | number | Number of products in catalog |
9797
| `app.products_search.count` | number | Number of products returned in search |
9898

99+
## QuoteService
100+
101+
| Name | Type | Description |
102+
|-----------------------------|--------|----------------------|
103+
| `app.quote.items.count` | number | Total items to ship |
104+
| `app.quote.cost.total` | number | Total shipping quote |
105+
99106
## RecommendationService
100107

101108
| Name | Type | Description |

docs/service_table.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ View [Service Graph](../README.md#architecture) to visualize request flows.
1414
| [loadgenerator](../src/loadgenerator/README.md) | Python/Locust | Continuously sends requests imitating realistic user shopping flows to the frontend. |
1515
| [paymentservice](../src/paymentservice/README.md) | JavaScript | Charges the given credit card info (mock) with the given amount and returns a transaction ID. |
1616
| [productcatalogservice](../src/productcatalogservice/README.md) | Go | Provides the list of products from a JSON file and ability to search products and get individual products. |
17+
| [quoteservice](../src/quoteservice/README.md) | PHP | Calculates the shipping costs, based on the number of items to be shipped. |
1718
| [recommendationservice](../src/recommendationservice/README.md) | Python | Recommends other products based on what's given in the cart. |
1819
| [shippingservice](../src/shippingservice/README.md) | Rust | Gives shipping cost estimates based on the shopping cart. Ships items to the given address (mock). |

docs/trace_service_features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ Emoji Legend
1717
| Frontend | JavaScript | :100: | :100: | :100: | :no_bell: | :100: | :100: |
1818
| Payment | JavaScript | :100: | :100: | :100: | :no_bell: | :no_bell: | :100: |
1919
| Product Catalog | Go | :100: | :construction: | :100: | :no_bell: | :no_bell: | :no_bell: |
20+
| Quote Service | PHP | :100: | :100: | :100: | :no_bell: | :no_bell: | :no_bell: |
2021
| Recommendation | Python | :100: | :100: | :100: | :no_bell: | :no_bell: | :no_bell: |
2122
| Shipping | Rust | :no_bell: | :100: | :100: | :100: | :no_bell: | :no_bell: |

src/quoteservice/.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.dockerignore
2+
.idea
3+
Dockerfile
4+
vendor

src/quoteservice/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.idea/
2+
.vscode/
3+
/coverage/
4+
/vendor/
5+
/logs/*
6+
!/logs/README.md
7+
.phpunit.result.cache

src/quoteservice/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM composer:2.4.1 AS build
2+
3+
WORKDIR /tmp/
4+
COPY ./src/quoteservice/composer.json .
5+
6+
RUN composer install \
7+
--ignore-platform-reqs \
8+
--no-interaction \
9+
--no-plugins \
10+
--no-scripts \
11+
--prefer-dist
12+
13+
FROM php:8.1-cli
14+
15+
# install GRPC (required for the OTel exporter)
16+
RUN apt-get -y update && apt install -y --no-install-recommends zlib1g-dev && \
17+
pecl install grpc protobuf && \
18+
docker-php-ext-enable grpc protobuf
19+
20+
WORKDIR /var/www
21+
COPY --from=build /tmp/vendor/ /var/www/vendor/
22+
COPY ./src/quoteservice/ /var/www
23+
24+
EXPOSE ${QUOTE_SERVICE_PORT}
25+
26+
ENTRYPOINT php -S 0.0.0.0:${QUOTE_SERVICE_PORT} -t public

0 commit comments

Comments
 (0)