From baa5651f85724d6322b8a26d12aca7f0e37d4db9 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Sun, 22 Dec 2024 22:41:18 -0500 Subject: [PATCH 1/3] rename paymentservice to payment --- .env | 6 +++--- .github/workflows/component-build-images.yml | 4 ++-- .gitignore | 2 +- docker-compose-tests.yml | 4 ++-- docker-compose.minimal.yml | 18 +++++++++--------- docker-compose.yml | 18 +++++++++--------- docker-gen-proto.sh | 2 +- ide-gen-proto.sh | 2 +- renovate.json5 | 4 ++-- src/checkoutservice/main.go | 4 ++-- src/flagd/demo.flagd.json | 4 ++-- src/{paymentservice => payment}/.dockerignore | 0 src/{paymentservice => payment}/Dockerfile | 6 +++--- src/{paymentservice => payment}/README.md | 2 +- src/{paymentservice => payment}/charge.js | 6 +++--- src/{paymentservice => payment}/index.js | 4 ++-- src/{paymentservice => payment}/logger.js | 0 .../opentelemetry.js | 0 .../package-lock.json | 4 ++-- src/{paymentservice => payment}/package.json | 2 +- .../amex-credit-card-not-allowed.yaml | 2 +- .../paymentservice/expired-credit-card.yaml | 2 +- .../paymentservice/invalid-credit-card.yaml | 2 +- .../paymentservice/valid-credit-card.yaml | 2 +- test/tracetesting/run.bash | 6 +++--- 25 files changed, 53 insertions(+), 53 deletions(-) rename src/{paymentservice => payment}/.dockerignore (100%) rename src/{paymentservice => payment}/Dockerfile (82%) rename src/{paymentservice => payment}/README.md (87%) rename src/{paymentservice => payment}/charge.js (95%) rename src/{paymentservice => payment}/index.js (88%) rename src/{paymentservice => payment}/logger.js (100%) rename src/{paymentservice => payment}/opentelemetry.js (100%) rename src/{paymentservice => payment}/package-lock.json (99%) rename src/{paymentservice => payment}/package.json (97%) diff --git a/.env b/.env index b011c764dc..d981fd810c 100644 --- a/.env +++ b/.env @@ -102,9 +102,9 @@ LOCUST_HEADLESS=false LOAD_GENERATOR_DOCKERFILE=./src/load-generator/Dockerfile # Payment Service -PAYMENT_SERVICE_PORT=50051 -PAYMENT_SERVICE_ADDR=paymentservice:${PAYMENT_SERVICE_PORT} -PAYMENT_SERVICE_DOCKERFILE=./src/paymentservice/Dockerfile +PAYMENT_PORT=50051 +PAYMENT_ADDR=payment:${PAYMENT_PORT} +PAYMENT_DOCKERFILE=./src/payment/Dockerfile # Product Catalog Service PRODUCT_CATALOG_SERVICE_PORT=3550 diff --git a/.github/workflows/component-build-images.yml b/.github/workflows/component-build-images.yml index 1ebd177346..00b6898e99 100644 --- a/.github/workflows/component-build-images.yml +++ b/.github/workflows/component-build-images.yml @@ -103,8 +103,8 @@ jobs: tag_suffix: load-generator context: ./ setup-qemu: true - - file: ./src/paymentservice/Dockerfile - tag_suffix: paymentservice + - file: ./src/payment/Dockerfile + tag_suffix: payment context: ./ setup-qemu: true - file: ./src/productcatalogservice/Dockerfile diff --git a/.gitignore b/.gitignore index 0e791dd5dd..af7e02c117 100644 --- a/.gitignore +++ b/.gitignore @@ -52,7 +52,7 @@ test/tracetesting/tracetesting-vars.yaml /src/frauddetectionservice/src/main/proto /src/frontend/pb/ /src/frontend/protos/ -/src/paymentservice/demo.proto +/src/payment/demo.proto /src/shipping/proto/ /src/currency/proto diff --git a/docker-compose-tests.yml b/docker-compose-tests.yml index 31fd9a80ab..fd0ba766d4 100644 --- a/docker-compose-tests.yml +++ b/docker-compose-tests.yml @@ -43,7 +43,7 @@ services: - CURRENCY_ADDR - EMAIL_SERVICE_ADDR - FRONTEND_ADDR - - PAYMENT_SERVICE_ADDR + - PAYMENT_ADDR - PRODUCT_CATALOG_SERVICE_ADDR - RECOMMENDATION_SERVICE_ADDR - SHIPPING_ADDR @@ -73,7 +73,7 @@ services: condition: service_started frontend: condition: service_started - paymentservice: + payment: condition: service_started productcatalogservice: condition: service_started diff --git a/docker-compose.minimal.yml b/docker-compose.minimal.yml index 0c0b868462..c3ddc54c39 100644 --- a/docker-compose.minimal.yml +++ b/docker-compose.minimal.yml @@ -102,7 +102,7 @@ services: - CURRENCY_ADDR - EMAIL_SERVICE_ADDR - FLAGD_HOST - - PAYMENT_SERVICE_ADDR + - PAYMENT_ADDR - PRODUCT_CATALOG_SERVICE_ADDR - SHIPPING_ADDR - OTEL_EXPORTER_OTLP_ENDPOINT @@ -116,7 +116,7 @@ services: condition: service_started emailservice: condition: service_started - paymentservice: + payment: condition: service_started productcatalogservice: condition: service_started @@ -351,28 +351,28 @@ services: logging: *logging # Payment service - paymentservice: - image: ${IMAGE_NAME}:${DEMO_VERSION}-paymentservice + payment: + image: ${IMAGE_NAME}:${DEMO_VERSION}-payment container_name: payment-service build: context: ./ - dockerfile: ${PAYMENT_SERVICE_DOCKERFILE} + dockerfile: ${PAYMENT_DOCKERFILE} cache_from: - - ${IMAGE_NAME}:${IMAGE_VERSION}-paymentservice + - ${IMAGE_NAME}:${IMAGE_VERSION}-payment deploy: resources: limits: memory: 120M restart: unless-stopped ports: - - "${PAYMENT_SERVICE_PORT}" + - "${PAYMENT_PORT}" environment: - FLAGD_HOST - - PAYMENT_SERVICE_PORT + - PAYMENT_PORT - OTEL_EXPORTER_OTLP_ENDPOINT - OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE - OTEL_RESOURCE_ATTRIBUTES - - OTEL_SERVICE_NAME=paymentservice + - OTEL_SERVICE_NAME=payment depends_on: otel-collector: condition: service_started diff --git a/docker-compose.yml b/docker-compose.yml index 722afe90dc..2b3781404b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -135,7 +135,7 @@ services: - CART_ADDR - CURRENCY_ADDR - EMAIL_SERVICE_ADDR - - PAYMENT_SERVICE_ADDR + - PAYMENT_ADDR - PRODUCT_CATALOG_SERVICE_ADDR - SHIPPING_ADDR - KAFKA_SERVICE_ADDR @@ -150,7 +150,7 @@ services: condition: service_started emailservice: condition: service_started - paymentservice: + payment: condition: service_started productcatalogservice: condition: service_started @@ -427,29 +427,29 @@ services: logging: *logging # Payment service - paymentservice: - image: ${IMAGE_NAME}:${DEMO_VERSION}-paymentservice + payment: + image: ${IMAGE_NAME}:${DEMO_VERSION}-payment container_name: payment-service build: context: ./ - dockerfile: ${PAYMENT_SERVICE_DOCKERFILE} + dockerfile: ${PAYMENT_DOCKERFILE} cache_from: - - ${IMAGE_NAME}:${IMAGE_VERSION}-paymentservice + - ${IMAGE_NAME}:${IMAGE_VERSION}-payment deploy: resources: limits: memory: 120M restart: unless-stopped ports: - - "${PAYMENT_SERVICE_PORT}" + - "${PAYMENT_PORT}" environment: - - PAYMENT_SERVICE_PORT + - PAYMENT_PORT - FLAGD_HOST - FLAGD_PORT - OTEL_EXPORTER_OTLP_ENDPOINT - OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE - OTEL_RESOURCE_ATTRIBUTES - - OTEL_SERVICE_NAME=paymentservice + - OTEL_SERVICE_NAME=payment depends_on: otel-collector: condition: service_started diff --git a/docker-gen-proto.sh b/docker-gen-proto.sh index 80fa1f8634..4897e6083e 100755 --- a/docker-gen-proto.sh +++ b/docker-gen-proto.sh @@ -28,7 +28,7 @@ gen_proto_go checkoutservice #gen_proto_cpp currency #gen_proto_ruby emailservice #gen_proto_ts frontend -#gen_proto_js paymentservice +#gen_proto_js payment gen_proto_go productcatalogservice #gen_proto_php quote gen_proto_python recommendationservice diff --git a/ide-gen-proto.sh b/ide-gen-proto.sh index 14649b8517..c7c975fc0d 100755 --- a/ide-gen-proto.sh +++ b/ide-gen-proto.sh @@ -73,7 +73,7 @@ gen_proto_go checkoutservice # gen_proto_ruby emailservice gen_proto_ts frontend gen_proto_ts react-native-app -gen_proto_js paymentservice +gen_proto_js payment gen_proto_go productcatalogservice # gen_proto_php quote gen_proto_python recommendationservice diff --git a/renovate.json5 b/renovate.json5 index de6ac5c52a..77f3dcfa72 100644 --- a/renovate.json5 +++ b/renovate.json5 @@ -71,8 +71,8 @@ "groupName": "otel-collector", }, { - "matchFileNames": ["src/paymentservice/**"], - "groupName": "paymentservice", + "matchFileNames": ["src/payment/**"], + "groupName": "payment", }, { "matchFileNames": ["src/productcatalogservice/**"], diff --git a/src/checkoutservice/main.go b/src/checkoutservice/main.go index d4c7bfadc9..02696e46b2 100644 --- a/src/checkoutservice/main.go +++ b/src/checkoutservice/main.go @@ -192,7 +192,7 @@ func main() { svc.emailSvcClient = pb.NewEmailServiceClient(c) defer c.Close() - mustMapEnv(&svc.paymentSvcAddr, "PAYMENT_SERVICE_ADDR") + mustMapEnv(&svc.paymentSvcAddr, "PAYMENT_ADDR") c = mustCreateClient(svc.paymentSvcAddr) svc.paymentSvcClient = pb.NewPaymentServiceClient(c) defer c.Close() @@ -442,7 +442,7 @@ func (cs *checkoutService) convertCurrency(ctx context.Context, from *pb.Money, func (cs *checkoutService) chargeCard(ctx context.Context, amount *pb.Money, paymentInfo *pb.CreditCardInfo) (string, error) { paymentService := cs.paymentSvcClient - if cs.isFeatureFlagEnabled(ctx, "paymentServiceUnreachable") { + if cs.isFeatureFlagEnabled(ctx, "paymentUnreachable") { badAddress := "badAddress:50051" c := mustCreateClient(badAddress) paymentService = pb.NewPaymentServiceClient(c) diff --git a/src/flagd/demo.flagd.json b/src/flagd/demo.flagd.json index 74fb5fcf1d..07439ebf89 100644 --- a/src/flagd/demo.flagd.json +++ b/src/flagd/demo.flagd.json @@ -64,7 +64,7 @@ }, "defaultVariant": "off" }, - "paymentServiceFailure": { + "paymentFailure": { "description": "Fail payment service charge requests n%", "state": "ENABLED", "variants": { @@ -78,7 +78,7 @@ }, "defaultVariant": "off" }, - "paymentServiceUnreachable": { + "paymentUnreachable": { "description": "Payment service is unavailable", "state": "ENABLED", "variants": { diff --git a/src/paymentservice/.dockerignore b/src/payment/.dockerignore similarity index 100% rename from src/paymentservice/.dockerignore rename to src/payment/.dockerignore diff --git a/src/paymentservice/Dockerfile b/src/payment/Dockerfile similarity index 82% rename from src/paymentservice/Dockerfile rename to src/payment/Dockerfile index fb78bc3b17..e1f5e03278 100644 --- a/src/paymentservice/Dockerfile +++ b/src/payment/Dockerfile @@ -6,7 +6,7 @@ FROM node:22-alpine AS build WORKDIR /usr/src/app/ -COPY ./src/paymentservice/package*.json ./ +COPY ./src/payment/package*.json ./ RUN apk add --no-cache python3 make g++ && npm ci --omit=dev @@ -19,8 +19,8 @@ WORKDIR /usr/src/app/ ENV NODE_ENV=production COPY --chown=node:node --from=build /usr/src/app/node_modules/ ./node_modules/ -COPY ./src/paymentservice/ ./ +COPY ./src/payment/ ./ COPY ./pb/demo.proto ./ -EXPOSE ${PAYMENT_SERVICE_PORT} +EXPOSE ${PAYMENT_PORT} ENTRYPOINT [ "npm", "run", "start" ] diff --git a/src/paymentservice/README.md b/src/payment/README.md similarity index 87% rename from src/paymentservice/README.md rename to src/payment/README.md index 1f73c2d954..62194705b4 100644 --- a/src/paymentservice/README.md +++ b/src/payment/README.md @@ -12,5 +12,5 @@ Copy the `demo.proto` file to this directory and run `npm ci` From the root directory, run: ```sh -docker compose build paymentservice +docker compose build payment ``` diff --git a/src/paymentservice/charge.js b/src/payment/charge.js similarity index 95% rename from src/paymentservice/charge.js rename to src/payment/charge.js index 4d02ba24e8..588cc0754e 100644 --- a/src/paymentservice/charge.js +++ b/src/payment/charge.js @@ -9,8 +9,8 @@ const { FlagdProvider } = require('@openfeature/flagd-provider'); const flagProvider = new FlagdProvider(); const logger = require('./logger'); -const tracer = trace.getTracer('paymentservice'); -const meter = metrics.getMeter('paymentservice'); +const tracer = trace.getTracer('payment'); +const meter = metrics.getMeter('payment'); const transactionsCounter = meter.createCounter('app.payment.transactions'); const LOYALTY_LEVEL = ['platinum', 'gold', 'silver', 'bronze']; @@ -26,7 +26,7 @@ module.exports.charge = async request => { await OpenFeature.setProviderAndWait(flagProvider); - const numberVariant = await OpenFeature.getClient().getNumberValue("paymentServiceFailure", 0); + const numberVariant = await OpenFeature.getClient().getNumberValue("paymentFailure", 0); if (numberVariant > 0) { // n% chance to fail with app.loyalty.level=gold diff --git a/src/paymentservice/index.js b/src/payment/index.js similarity index 88% rename from src/paymentservice/index.js rename to src/payment/index.js index c068c31082..362059e2a6 100644 --- a/src/paymentservice/index.js +++ b/src/payment/index.js @@ -45,12 +45,12 @@ server.addService(health.service, new health.Implementation({ server.addService(otelDemoPackage.oteldemo.PaymentService.service, { charge: chargeServiceHandler }) -server.bindAsync(`0.0.0.0:${process.env['PAYMENT_SERVICE_PORT']}`, grpc.ServerCredentials.createInsecure(), (err, port) => { +server.bindAsync(`0.0.0.0:${process.env['PAYMENT_PORT']}`, grpc.ServerCredentials.createInsecure(), (err, port) => { if (err) { return logger.error({ err }) } - logger.info(`PaymentService gRPC server started on port ${port}`) + logger.info(`payment gRPC server started on port ${port}`) }) process.once('SIGINT', closeGracefully) diff --git a/src/paymentservice/logger.js b/src/payment/logger.js similarity index 100% rename from src/paymentservice/logger.js rename to src/payment/logger.js diff --git a/src/paymentservice/opentelemetry.js b/src/payment/opentelemetry.js similarity index 100% rename from src/paymentservice/opentelemetry.js rename to src/payment/opentelemetry.js diff --git a/src/paymentservice/package-lock.json b/src/payment/package-lock.json similarity index 99% rename from src/paymentservice/package-lock.json rename to src/payment/package-lock.json index 881fb4216b..8128bed3ab 100644 --- a/src/paymentservice/package-lock.json +++ b/src/payment/package-lock.json @@ -1,11 +1,11 @@ { - "name": "paymentservice", + "name": "payment", "version": "1.12.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "paymentservice", + "name": "payment", "version": "1.12.0", "license": "ISC", "dependencies": { diff --git a/src/paymentservice/package.json b/src/payment/package.json similarity index 97% rename from src/paymentservice/package.json rename to src/payment/package.json index 2c0365b0c1..607dcf02c9 100644 --- a/src/paymentservice/package.json +++ b/src/payment/package.json @@ -1,5 +1,5 @@ { - "name": "paymentservice", + "name": "payment", "description": "Payment Service", "repository": "https://github.com/opentelemetry/opentelemetry-demo", "main": "index.js", diff --git a/test/tracetesting/paymentservice/amex-credit-card-not-allowed.yaml b/test/tracetesting/paymentservice/amex-credit-card-not-allowed.yaml index ab3629df30..6ad88e7885 100644 --- a/test/tracetesting/paymentservice/amex-credit-card-not-allowed.yaml +++ b/test/tracetesting/paymentservice/amex-credit-card-not-allowed.yaml @@ -10,7 +10,7 @@ spec: type: grpc grpc: protobufFile: ../../../pb/demo.proto - address: ${var:PAYMENT_SERVICE_ADDR} + address: ${var:PAYMENT_ADDR} method: oteldemo.PaymentService.Charge request: |- { diff --git a/test/tracetesting/paymentservice/expired-credit-card.yaml b/test/tracetesting/paymentservice/expired-credit-card.yaml index 27963f28d7..c2f9d5d020 100644 --- a/test/tracetesting/paymentservice/expired-credit-card.yaml +++ b/test/tracetesting/paymentservice/expired-credit-card.yaml @@ -10,7 +10,7 @@ spec: type: grpc grpc: protobufFile: ../../../pb/demo.proto - address: ${var:PAYMENT_SERVICE_ADDR} + address: ${var:PAYMENT_ADDR} method: oteldemo.PaymentService.Charge request: |- { diff --git a/test/tracetesting/paymentservice/invalid-credit-card.yaml b/test/tracetesting/paymentservice/invalid-credit-card.yaml index a6028f66a2..6ab64de72a 100644 --- a/test/tracetesting/paymentservice/invalid-credit-card.yaml +++ b/test/tracetesting/paymentservice/invalid-credit-card.yaml @@ -10,7 +10,7 @@ spec: type: grpc grpc: protobufFile: ../../../pb/demo.proto - address: ${var:PAYMENT_SERVICE_ADDR} + address: ${var:PAYMENT_ADDR} method: oteldemo.PaymentService.Charge request: |- { diff --git a/test/tracetesting/paymentservice/valid-credit-card.yaml b/test/tracetesting/paymentservice/valid-credit-card.yaml index 32c1001332..3bc7a657cd 100644 --- a/test/tracetesting/paymentservice/valid-credit-card.yaml +++ b/test/tracetesting/paymentservice/valid-credit-card.yaml @@ -10,7 +10,7 @@ spec: type: grpc grpc: protobufFile: ../../../pb/demo.proto - address: ${var:PAYMENT_SERVICE_ADDR} + address: ${var:PAYMENT_ADDR} method: oteldemo.PaymentService.Charge request: |- { diff --git a/test/tracetesting/run.bash b/test/tracetesting/run.bash index 865de274e0..abe64287fe 100755 --- a/test/tracetesting/run.bash +++ b/test/tracetesting/run.bash @@ -8,7 +8,7 @@ set -e # Availalble services to test -ALL_SERVICES=("ad" "cart" "currency" "checkoutservice" "frontend" "emailservice" "paymentservice" "productcatalogservice" "recommendationservice" "shipping") +ALL_SERVICES=("ad" "cart" "currency" "checkoutservice" "frontend" "emailservice" "payment" "productcatalogservice" "recommendationservice" "shipping") ## Script variables # Will contain the list of services to test @@ -46,8 +46,8 @@ spec: value: $EMAIL_SERVICE_ADDR - key: FRONTEND_ADDR value: $FRONTEND_ADDR - - key: PAYMENT_SERVICE_ADDR - value: $PAYMENT_SERVICE_ADDR + - key: PAYMENT_ADDR + value: $PAYMENT_ADDR - key: PRODUCT_CATALOG_SERVICE_ADDR value: $PRODUCT_CATALOG_SERVICE_ADDR - key: RECOMMENDATION_SERVICE_ADDR From 6b8a3647182227c568f319dadd7dab9d0bb3172d Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Sun, 22 Dec 2024 22:43:15 -0500 Subject: [PATCH 2/3] rename paymentservice to payment --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 886de03eea..8becf9c576 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,8 @@ the release. ([#1857](https://github.com/open-telemetry/opentelemetry-demo/pull/1857)) * [currency] rename currencyservice to currency ([#1858](https://github.com/open-telemetry/opentelemetry-demo/pull/1858)) +* [payment] rename paymentservice to payment + ([#1863](https://github.com/open-telemetry/opentelemetry-demo/pull/1863)) ## 1.12.0 From 50fa79df26c1da33325f1719043a819f4ca5de53 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Sun, 22 Dec 2024 23:30:24 -0500 Subject: [PATCH 3/3] rename paymentservice to payment --- test/tracetesting/{paymentservice => payment}/all.yaml | 6 +++--- .../amex-credit-card-not-allowed.yaml | 0 .../{paymentservice => payment}/expired-credit-card.yaml | 0 .../{paymentservice => payment}/invalid-credit-card.yaml | 0 .../{paymentservice => payment}/valid-credit-card.yaml | 0 5 files changed, 3 insertions(+), 3 deletions(-) rename test/tracetesting/{paymentservice => payment}/all.yaml (67%) rename test/tracetesting/{paymentservice => payment}/amex-credit-card-not-allowed.yaml (100%) rename test/tracetesting/{paymentservice => payment}/expired-credit-card.yaml (100%) rename test/tracetesting/{paymentservice => payment}/invalid-credit-card.yaml (100%) rename test/tracetesting/{paymentservice => payment}/valid-credit-card.yaml (100%) diff --git a/test/tracetesting/paymentservice/all.yaml b/test/tracetesting/payment/all.yaml similarity index 67% rename from test/tracetesting/paymentservice/all.yaml rename to test/tracetesting/payment/all.yaml index e295034dce..c7d08d8944 100644 --- a/test/tracetesting/paymentservice/all.yaml +++ b/test/tracetesting/payment/all.yaml @@ -3,9 +3,9 @@ type: TestSuite spec: - id: payment-service-all - name: 'Payment Service' - description: Run all Payment Service tests enabled in sequence + id: payment-all + name: 'Payment' + description: Run all Payment tests enabled in sequence steps: - ./valid-credit-card.yaml - ./invalid-credit-card.yaml diff --git a/test/tracetesting/paymentservice/amex-credit-card-not-allowed.yaml b/test/tracetesting/payment/amex-credit-card-not-allowed.yaml similarity index 100% rename from test/tracetesting/paymentservice/amex-credit-card-not-allowed.yaml rename to test/tracetesting/payment/amex-credit-card-not-allowed.yaml diff --git a/test/tracetesting/paymentservice/expired-credit-card.yaml b/test/tracetesting/payment/expired-credit-card.yaml similarity index 100% rename from test/tracetesting/paymentservice/expired-credit-card.yaml rename to test/tracetesting/payment/expired-credit-card.yaml diff --git a/test/tracetesting/paymentservice/invalid-credit-card.yaml b/test/tracetesting/payment/invalid-credit-card.yaml similarity index 100% rename from test/tracetesting/paymentservice/invalid-credit-card.yaml rename to test/tracetesting/payment/invalid-credit-card.yaml diff --git a/test/tracetesting/paymentservice/valid-credit-card.yaml b/test/tracetesting/payment/valid-credit-card.yaml similarity index 100% rename from test/tracetesting/paymentservice/valid-credit-card.yaml rename to test/tracetesting/payment/valid-credit-card.yaml