Skip to content

Commit

Permalink
Merge branch 'main' into rename.paymentservice
Browse files Browse the repository at this point in the history
  • Loading branch information
julianocosta89 authored Dec 23, 2024
2 parents 50fa79d + 3868f0e commit 07d5be7
Show file tree
Hide file tree
Showing 35 changed files with 73 additions and 69 deletions.
8 changes: 4 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ CURRENCY_ADDR=currency:${CURRENCY_PORT}
CURRENCY_DOCKERFILE=./src/currency/Dockerfile

# Email Service
EMAIL_SERVICE_PORT=6060
EMAIL_SERVICE_ADDR=http://emailservice:${EMAIL_SERVICE_PORT}
EMAIL_SERVICE_DOCKERFILE=./src/emailservice/Dockerfile
EMAIL_PORT=6060
EMAIL_ADDR=http://email:${EMAIL_PORT}
EMAIL_DOCKERFILE=./src/email/Dockerfile

# Fraud Service
FRAUD_SERVICE_DOCKERFILE=./src/frauddetectionservice/Dockerfile
FRAUD_DOCKERFILE=./src/fraud-detection/Dockerfile

# Frontend
FRONTEND_PORT=8080
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/component-build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ jobs:
tag_suffix: currency
context: ./
setup-qemu: true
- file: ./src/emailservice/Dockerfile
tag_suffix: emailservice
- file: ./src/email/Dockerfile
tag_suffix: email
context: ./
setup-qemu: true
- file: ./src/frauddetectionservice/Dockerfile
tag_suffix: frauddetectionservice
- file: ./src/fraud-detection/Dockerfile
tag_suffix: fraud-detection
context: ./
setup-qemu: true
- file: ./src/frontend/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test/tracetesting/tracetesting-vars.yaml
/src/featureflagservice/src/ffs_demo_pb.erl
/src/featureflagservice/src/ffs_service_*.erl
/src/featureflagservice/src/oteldemo_*.erl
/src/frauddetectionservice/src/main/proto
/src/fraud-detection/src/main/proto
/src/frontend/pb/
/src/frontend/protos/
/src/payment/demo.proto
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ 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))
* [email] rename emailservice to email
([#1861](https://github.com/open-telemetry/opentelemetry-demo/pull/1861))
* [fraud-detection] rename frauddetectionservice to fraud-detection
([#1862](https://github.com/open-telemetry/opentelemetry-demo/pull/1862))
* [payment] rename paymentservice to payment
([#1863](https://github.com/open-telemetry/opentelemetry-demo/pull/1863))

Expand Down
6 changes: 3 additions & 3 deletions docker-compose-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ services:
- CART_ADDR
- CHECKOUT_SERVICE_ADDR
- CURRENCY_ADDR
- EMAIL_SERVICE_ADDR
- EMAIL_ADDR
- FRONTEND_ADDR
- PAYMENT_ADDR
- PRODUCT_CATALOG_SERVICE_ADDR
Expand All @@ -67,9 +67,9 @@ services:
condition: service_started
currency:
condition: service_started
emailservice:
email:
condition: service_started
frauddetectionservice:
fraud-detection:
condition: service_started
frontend:
condition: service_started
Expand Down
18 changes: 9 additions & 9 deletions docker-compose.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ services:
- CHECKOUT_SERVICE_PORT
- CART_ADDR
- CURRENCY_ADDR
- EMAIL_SERVICE_ADDR
- EMAIL_ADDR
- FLAGD_HOST
- PAYMENT_ADDR
- PRODUCT_CATALOG_SERVICE_ADDR
Expand All @@ -114,7 +114,7 @@ services:
condition: service_started
currency:
condition: service_started
emailservice:
email:
condition: service_started
payment:
condition: service_started
Expand Down Expand Up @@ -155,26 +155,26 @@ services:
logging: *logging

# Email service
emailservice:
image: ${IMAGE_NAME}:${DEMO_VERSION}-emailservice
email:
image: ${IMAGE_NAME}:${DEMO_VERSION}-email
container_name: email-service
build:
context: ./src/emailservice
context: ./src/email
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-emailservice
- ${IMAGE_NAME}:${IMAGE_VERSION}-email
deploy:
resources:
limits:
memory: 100M
restart: unless-stopped
ports:
- "${EMAIL_SERVICE_PORT}"
- "${EMAIL_PORT}"
environment:
- APP_ENV=production
- EMAIL_SERVICE_PORT
- EMAIL_PORT
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT_HTTP}/v1/traces
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=emailservice
- OTEL_SERVICE_NAME=email
depends_on:
otel-collector:
condition: service_started
Expand Down
30 changes: 15 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ services:
- CHECKOUT_SERVICE_PORT
- CART_ADDR
- CURRENCY_ADDR
- EMAIL_SERVICE_ADDR
- EMAIL_ADDR
- PAYMENT_ADDR
- PRODUCT_CATALOG_SERVICE_ADDR
- SHIPPING_ADDR
Expand All @@ -148,7 +148,7 @@ services:
condition: service_started
currency:
condition: service_started
emailservice:
email:
condition: service_started
payment:
condition: service_started
Expand Down Expand Up @@ -193,41 +193,41 @@ services:
logging: *logging

# Email service
emailservice:
image: ${IMAGE_NAME}:${DEMO_VERSION}-emailservice
email:
image: ${IMAGE_NAME}:${DEMO_VERSION}-email
container_name: email-service
build:
context: ./
dockerfile: ${EMAIL_SERVICE_DOCKERFILE}
dockerfile: ${EMAIL_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-emailservice
- ${IMAGE_NAME}:${IMAGE_VERSION}-email
deploy:
resources:
limits:
memory: 100M
restart: unless-stopped
ports:
- "${EMAIL_SERVICE_PORT}"
- "${EMAIL_PORT}"
environment:
- APP_ENV=production
- EMAIL_SERVICE_PORT
- EMAIL_PORT
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT_HTTP}/v1/traces
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=emailservice
- OTEL_SERVICE_NAME=email
depends_on:
otel-collector:
condition: service_started
logging: *logging

# Fraud Detection service
frauddetectionservice:
image: ${IMAGE_NAME}:${DEMO_VERSION}-frauddetectionservice
container_name: frauddetection-service
fraud-detection:
image: ${IMAGE_NAME}:${DEMO_VERSION}-fraud-detection
container_name: fraud-detection
build:
context: ./
dockerfile: ${FRAUD_SERVICE_DOCKERFILE}
dockerfile: ${FRAUD_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-frauddetectionservice
- ${IMAGE_NAME}:${IMAGE_VERSION}-fraud-detection
args:
OTEL_JAVA_AGENT_VERSION: ${OTEL_JAVA_AGENT_VERSION}
deploy:
Expand All @@ -244,7 +244,7 @@ services:
- OTEL_INSTRUMENTATION_KAFKA_EXPERIMENTAL_SPAN_ATTRIBUTES=true
- OTEL_INSTRUMENTATION_MESSAGING_EXPERIMENTAL_RECEIVE_TELEMETRY_ENABLED=true
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=frauddetectionservice
- OTEL_SERVICE_NAME=fraud-detection
depends_on:
otel-collector:
condition: service_started
Expand Down
2 changes: 1 addition & 1 deletion docker-gen-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ gen_proto_python() {
#gen_proto_dotnet cart
gen_proto_go checkoutservice
#gen_proto_cpp currency
#gen_proto_ruby emailservice
#gen_proto_ruby email
#gen_proto_ts frontend
#gen_proto_js payment
gen_proto_go productcatalogservice
Expand Down
2 changes: 1 addition & 1 deletion ide-gen-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ gen_proto_dotnet accounting
gen_proto_dotnet cart
gen_proto_go checkoutservice
# gen_proto_cpp currency
# gen_proto_ruby emailservice
# gen_proto_ruby email
gen_proto_ts frontend
gen_proto_ts react-native-app
gen_proto_js payment
Expand Down
8 changes: 4 additions & 4 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
"groupName": "currency",
},
{
"matchFileNames": ["src/emailservice/**"],
"groupName": "emailservice",
"matchFileNames": ["src/email/**"],
"groupName": "email",
},
{
"matchFileNames": ["src/featureflagservice/**"],
"groupName": "featureflagservice",
},
{
"matchFileNames": ["src/frauddetectionservice/**"],
"groupName": "frauddetectionservice",
"matchFileNames": ["src/fraud-detection/**"],
"groupName": "fraud-detection",
},
{
"matchFileNames": ["src/frontend/**"],
Expand Down
6 changes: 3 additions & 3 deletions src/checkoutservice/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func main() {
svc.currencySvcClient = pb.NewCurrencyServiceClient(c)
defer c.Close()

mustMapEnv(&svc.emailSvcAddr, "EMAIL_SERVICE_ADDR")
mustMapEnv(&svc.emailSvcAddr, "EMAIL_ADDR")
c = mustCreateClient(svc.emailSvcAddr)
svc.emailSvcClient = pb.NewEmailServiceClient(c)
defer c.Close()
Expand Down Expand Up @@ -458,15 +458,15 @@ func (cs *checkoutService) chargeCard(ctx context.Context, amount *pb.Money, pay
}

func (cs *checkoutService) sendOrderConfirmation(ctx context.Context, email string, order *pb.OrderResult) error {
emailServicePayload, err := json.Marshal(map[string]interface{}{
emailPayload, err := json.Marshal(map[string]interface{}{
"email": email,
"order": order,
})
if err != nil {
return fmt.Errorf("failed to marshal order to JSON: %+v", err)
}

resp, err := otelhttp.Post(ctx, cs.emailSvcAddr+"/send_order_confirmation", "application/json", bytes.NewBuffer(emailServicePayload))
resp, err := otelhttp.Post(ctx, cs.emailSvcAddr+"/send_order_confirmation", "application/json", bytes.NewBuffer(emailPayload))
if err != nil {
return fmt.Errorf("failed POST to email service: %+v", err)
}
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/emailservice/Dockerfile → src/email/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ FROM base AS builder

WORKDIR /tmp

COPY ./src/emailservice/Gemfile ./src/emailservice/Gemfile.lock ./
COPY ./src/email/Gemfile ./src/email/Gemfile.lock ./

#RUN apk update && apk add make gcc musl-dev gcompat && bundle install
RUN apt-get update && apt-get install build-essential -y && bundle install
FROM base AS release

WORKDIR /email_server

COPY ./src/emailservice/ .
COPY ./src/email/ .

RUN chmod 666 ./Gemfile.lock

COPY --from=builder /usr/local/bundle/ /usr/local/bundle/


EXPOSE ${EMAIL_SERVICE_PORT}
EXPOSE ${EMAIL_PORT}
ENTRYPOINT ["bundle", "exec", "ruby", "email_server.rb"]
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/emailservice/README.md → src/email/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ You may run this service locally with `bundle exec ruby email_server.rb`.

## Docker Build

From `src/emailservice`, run `docker build .`
From `src/email`, run `docker build .`
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
require "opentelemetry/exporter/otlp"
require "opentelemetry/instrumentation/sinatra"

set :port, ENV["EMAIL_SERVICE_PORT"]
set :port, ENV["EMAIL_PORT"]

OpenTelemetry::SDK.configure do |c|
c.use "OpenTelemetry::Instrumentation::Sinatra"
Expand All @@ -34,7 +34,7 @@

def send_email(data)
# create and start a manual span
tracer = OpenTelemetry.tracer_provider.tracer('emailservice')
tracer = OpenTelemetry.tracer_provider.tracer('email')
tracer.in_span("send_email") do |span|
Pony.mail(
to: data.email,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM --platform=${BUILDPLATFORM} gradle:8-jdk17 AS builder

WORKDIR /usr/src/app/

COPY ./src/frauddetectionservice/ ./
COPY ./src/fraud-detection/ ./
COPY ./pb/ ./src/main/proto/
RUN gradle shadowJar

Expand All @@ -17,8 +17,8 @@ FROM gcr.io/distroless/java17-debian11
ARG OTEL_JAVA_AGENT_VERSION
WORKDIR /usr/src/app/

COPY --from=builder /usr/src/app/build/libs/frauddetectionservice-1.0-all.jar ./
COPY --from=builder /usr/src/app/build/libs/fraud-detection-1.0-all.jar ./
ADD --chmod=644 https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$OTEL_JAVA_AGENT_VERSION/opentelemetry-javaagent.jar /app/opentelemetry-javaagent.jar
ENV JAVA_TOOL_OPTIONS=-javaagent:/app/opentelemetry-javaagent.jar

ENTRYPOINT [ "java", "-jar", "frauddetectionservice-1.0-all.jar" ]
ENTRYPOINT [ "java", "-jar", "fraud-detection-1.0-all.jar" ]
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ cp -r ../../pb/ src/main/proto/
To build using Docker run from the repo root:

```sh
docker build -f ./src/frauddetectionservice/Dockerfile .
docker build -f ./src/fraud-detection/Dockerfile .
```
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ protobuf {
}

application {
mainClass.set("frauddetectionservice.MainKt")
mainClass.set("frauddetection.MainKt")
}

tasks.jar {
manifest.attributes["Main-Class"] = "frauddetectionservice.MainKt"
manifest.attributes["Main-Class"] = "frauddetection.MainKt"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/fraud-detection/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

rootProject.name = "fraud-detection"

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package frauddetectionservice
package frauddetection

import org.apache.kafka.clients.consumer.ConsumerConfig.*
import org.apache.kafka.clients.consumer.KafkaConsumer
Expand All @@ -24,7 +24,7 @@ import dev.openfeature.sdk.Value
import dev.openfeature.sdk.OpenFeatureAPI

const val topic = "orders"
const val groupID = "frauddetectionservice"
const val groupID = "fraud-detection"

private val logger: Logger = LogManager.getLogger(groupID)

Expand Down
3 changes: 0 additions & 3 deletions src/frauddetectionservice/settings.gradle.kts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

type: TestSuite
spec:
id: email-service-all
name: 'Email Service'
description: Run all Email Service tests enabled in sequence
id: email-all
name: 'Email'
description: Run all Email tests enabled in sequence
steps:
- ./confirmation.yaml
Loading

0 comments on commit 07d5be7

Please sign in to comment.