Skip to content

Commit

Permalink
[currency] Rename currencyservice to currency (#1858)
Browse files Browse the repository at this point in the history
  • Loading branch information
puckpuck authored Dec 22, 2024
1 parent d5c0efe commit e3548c6
Show file tree
Hide file tree
Showing 28 changed files with 73 additions and 71 deletions.
6 changes: 3 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ src/*/Dockerfile
src/*/*/Dockerfile

###################################
# currencyservice
./src/currencyservice/client.js
./src/currencyservice/node_modules/
# currency
./src/currency/client.js
./src/currency/node_modules/
###################################

###################################
Expand Down
6 changes: 3 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ CHECKOUT_SERVICE_ADDR=checkoutservice:${CHECKOUT_SERVICE_PORT}
CHECKOUT_SERVICE_DOCKERFILE=./src/checkoutservice/Dockerfile

# Currency Service
CURRENCY_SERVICE_PORT=7001
CURRENCY_SERVICE_ADDR=currencyservice:${CURRENCY_SERVICE_PORT}
CURRENCY_SERVICE_DOCKERFILE=./src/currencyservice/Dockerfile
CURRENCY_PORT=7001
CURRENCY_ADDR=currency:${CURRENCY_PORT}
CURRENCY_DOCKERFILE=./src/currency/Dockerfile

# Email Service
EMAIL_SERVICE_PORT=6060
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/component-build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ jobs:
tag_suffix: checkoutservice
context: ./
setup-qemu: true
- file: ./src/currencyservice/Dockerfile
tag_suffix: currencyservice
- file: ./src/currency/Dockerfile
tag_suffix: currency
context: ./
setup-qemu: true
- file: ./src/emailservice/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test/tracetesting/tracetesting-vars.yaml
/src/frontend/protos/
/src/paymentservice/demo.proto
/src/shipping/proto/
/src/currencyservice/proto
/src/currency/proto

# Android
*.apk
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ the release.
([#1856](https://github.com/open-telemetry/opentelemetry-demo/pull/1856))
* [image-provider] rename imageprovider to image-provider
([#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))

## 1.12.0

Expand Down
4 changes: 2 additions & 2 deletions docker-compose-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ services:
- AD_ADDR
- CART_ADDR
- CHECKOUT_SERVICE_ADDR
- CURRENCY_SERVICE_ADDR
- CURRENCY_ADDR
- EMAIL_SERVICE_ADDR
- FRONTEND_ADDR
- PAYMENT_SERVICE_ADDR
Expand All @@ -65,7 +65,7 @@ services:
condition: service_started
checkoutservice:
condition: service_started
currencyservice:
currency:
condition: service_started
emailservice:
condition: service_started
Expand Down
22 changes: 11 additions & 11 deletions docker-compose.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ services:
environment:
- CHECKOUT_SERVICE_PORT
- CART_ADDR
- CURRENCY_SERVICE_ADDR
- CURRENCY_ADDR
- EMAIL_SERVICE_ADDR
- FLAGD_HOST
- PAYMENT_SERVICE_ADDR
Expand All @@ -112,7 +112,7 @@ services:
depends_on:
cart:
condition: service_started
currencyservice:
currency:
condition: service_started
emailservice:
condition: service_started
Expand All @@ -127,14 +127,14 @@ services:
logging: *logging

# Currency service
currencyservice:
image: ${IMAGE_NAME}:${DEMO_VERSION}-currencyservice
currency:
image: ${IMAGE_NAME}:${DEMO_VERSION}-currency
container_name: currency-service
build:
context: ./
dockerfile: ${CURRENCY_SERVICE_DOCKERFILE}
dockerfile: ${CURRENCY_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-currencyservice
- ${IMAGE_NAME}:${IMAGE_VERSION}-currency
args:
OPENTELEMETRY_CPP_VERSION: ${OPENTELEMETRY_CPP_VERSION}
deploy:
Expand All @@ -143,12 +143,12 @@ services:
memory: 20M
restart: unless-stopped
ports:
- "${CURRENCY_SERVICE_PORT}"
- "${CURRENCY_PORT}"
environment:
- CURRENCY_SERVICE_PORT
- CURRENCY_PORT
- VERSION=${IMAGE_VERSION}
- OTEL_EXPORTER_OTLP_ENDPOINT
- OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES},service.name=currencyservice # The C++ SDK does not support OTEL_SERVICE_NAME
- OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES},service.name=currency # The C++ SDK does not support OTEL_SERVICE_NAME
depends_on:
otel-collector:
condition: service_started
Expand Down Expand Up @@ -202,7 +202,7 @@ services:
- AD_ADDR
- CART_ADDR
- CHECKOUT_SERVICE_ADDR
- CURRENCY_SERVICE_ADDR
- CURRENCY_ADDR
- PRODUCT_CATALOG_SERVICE_ADDR
- RECOMMENDATION_SERVICE_ADDR
- SHIPPING_ADDR
Expand All @@ -223,7 +223,7 @@ services:
condition: service_started
checkoutservice:
condition: service_started
currencyservice:
currency:
condition: service_started
productcatalogservice:
condition: service_started
Expand Down
22 changes: 11 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ services:
- FLAGD_PORT
- CHECKOUT_SERVICE_PORT
- CART_ADDR
- CURRENCY_SERVICE_ADDR
- CURRENCY_ADDR
- EMAIL_SERVICE_ADDR
- PAYMENT_SERVICE_ADDR
- PRODUCT_CATALOG_SERVICE_ADDR
Expand All @@ -146,7 +146,7 @@ services:
depends_on:
cart:
condition: service_started
currencyservice:
currency:
condition: service_started
emailservice:
condition: service_started
Expand All @@ -165,14 +165,14 @@ services:
logging: *logging

# Currency service
currencyservice:
image: ${IMAGE_NAME}:${DEMO_VERSION}-currencyservice
currency:
image: ${IMAGE_NAME}:${DEMO_VERSION}-currency
container_name: currency-service
build:
context: ./
dockerfile: ${CURRENCY_SERVICE_DOCKERFILE}
dockerfile: ${CURRENCY_DOCKERFILE}
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-currencyservice
- ${IMAGE_NAME}:${IMAGE_VERSION}-currency
args:
OPENTELEMETRY_CPP_VERSION: ${OPENTELEMETRY_CPP_VERSION}
deploy:
Expand All @@ -181,12 +181,12 @@ services:
memory: 20M
restart: unless-stopped
ports:
- "${CURRENCY_SERVICE_PORT}"
- "${CURRENCY_PORT}"
environment:
- CURRENCY_SERVICE_PORT
- CURRENCY_PORT
- VERSION=${IMAGE_VERSION}
- OTEL_EXPORTER_OTLP_ENDPOINT
- OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES},service.name=currencyservice # The C++ SDK does not support OTEL_SERVICE_NAME
- OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES},service.name=currency # The C++ SDK does not support OTEL_SERVICE_NAME
depends_on:
otel-collector:
condition: service_started
Expand Down Expand Up @@ -274,7 +274,7 @@ services:
- AD_ADDR
- CART_ADDR
- CHECKOUT_SERVICE_ADDR
- CURRENCY_SERVICE_ADDR
- CURRENCY_ADDR
- PRODUCT_CATALOG_SERVICE_ADDR
- RECOMMENDATION_SERVICE_ADDR
- SHIPPING_ADDR
Expand All @@ -295,7 +295,7 @@ services:
condition: service_started
checkoutservice:
condition: service_started
currencyservice:
currency:
condition: service_started
productcatalogservice:
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 @@ -25,7 +25,7 @@ gen_proto_python() {
#gen_proto_java ad
#gen_proto_dotnet cart
gen_proto_go checkoutservice
#gen_proto_cpp currencyservice
#gen_proto_cpp currency
#gen_proto_ruby emailservice
#gen_proto_ts frontend
#gen_proto_js paymentservice
Expand Down
2 changes: 1 addition & 1 deletion ide-gen-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ gen_proto_dotnet accounting
# gen_proto_java ad
gen_proto_dotnet cart
gen_proto_go checkoutservice
# gen_proto_cpp currencyservice
# gen_proto_cpp currency
# gen_proto_ruby emailservice
gen_proto_ts frontend
gen_proto_ts react-native-app
Expand Down
4 changes: 2 additions & 2 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"groupName": "checkoutservice",
},
{
"matchFileNames": ["src/currencyservice/**"],
"groupName": "currencyservice",
"matchFileNames": ["src/currency/**"],
"groupName": "currency",
},
{
"matchFileNames": ["src/emailservice/**"],
Expand Down
2 changes: 1 addition & 1 deletion src/checkoutservice/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func main() {
svc.cartSvcClient = pb.NewCartServiceClient(c)
defer c.Close()

mustMapEnv(&svc.currencySvcAddr, "CURRENCY_SERVICE_ADDR")
mustMapEnv(&svc.currencySvcAddr, "CURRENCY_ADDR")
c = mustCreateClient(svc.currencySvcAddr)
svc.currencySvcClient = pb.NewCurrencyServiceClient(c)
defer c.Close()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ add_library(demo-proto ${DEMO_PB_H_FILE}
target_link_libraries(demo-proto gRPC::grpc++ protobuf::libprotobuf)
include_directories("${GENERATED_PROTOBUF_PATH}" "${OPENTELEMETRY_CPP_INCLUDE_DIRS}")

add_executable(currencyservice src/server.cpp)
add_dependencies(currencyservice demo-proto)
add_executable(currency src/server.cpp)
add_dependencies(currency demo-proto)
target_link_libraries(
currencyservice demo-proto protobuf::libprotobuf
currency demo-proto protobuf::libprotobuf
${OPENTELEMETRY_CPP_LIBRARIES} opentelemetry_trace opentelemetry_common
opentelemetry_exporter_otlp_grpc opentelemetry_exporter_otlp_grpc_client
opentelemetry_proto opentelemetry_otlp_recordable opentelemetry_resources
opentelemetry_metrics opentelemetry_exporter_otlp_grpc_metrics gRPC::grpc++)

install(TARGETS currencyservice DESTINATION bin)
install(TARGETS currency DESTINATION bin)
10 changes: 5 additions & 5 deletions src/currencyservice/Dockerfile → src/currency/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ RUN git clone https://github.com/open-telemetry/opentelemetry-cpp \
-DWITH_EXAMPLES=OFF -DWITH_OTLP_GRPC=ON -DWITH_ABSEIL=ON \
&& make -j$(nproc || sysctl -n hw.ncpu || echo 1) install && cd ../..

COPY ./src/currencyservice /currencyservice
COPY ./pb/demo.proto /currencyservice/proto/demo.proto
COPY ./src/currency /currency
COPY ./pb/demo.proto /currency/proto/demo.proto

RUN cd /currencyservice \
RUN cd /currency \
&& mkdir -p build && cd build \
&& cmake .. \
&& make -j$(nproc || sysctl -n hw.ncpu || echo 1) install
Expand All @@ -44,5 +44,5 @@ FROM alpine:3.18 AS release
RUN apk update && apk add grpc-dev protobuf-dev
COPY --from=builder /usr/local /usr/local

EXPOSE ${CURRENCY_SERVICE_PORT}
ENTRYPOINT ["sh", "-c", "./usr/local/bin/currencyservice ${CURRENCY_SERVICE_PORT}"]
EXPOSE ${CURRENCY_PORT}
ENTRYPOINT ["sh", "-c", "./usr/local/bin/currency ${CURRENCY_PORT}"]
6 changes: 3 additions & 3 deletions src/currencyservice/README.md → src/currency/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ To build the currency service, run the following from root directory
of opentelemetry-demo

```sh
docker-compose build currencyservice
docker-compose build currency
```

## Run the service

Execute the below command to run the service.

```sh
docker-compose up currencyservice
docker-compose up currency
```

## Run the client
Expand All @@ -29,4 +29,4 @@ service. To run the client, execute the below command.
docker exec -it <container_name> currencyclient 7000
```

'7000' is port where currencyservice listens to.
'7000' is port where currency listens to.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace
};

std::string version = std::getenv("VERSION");
std::string name{ "currencyservice" };
std::string name{ "currency" };

nostd::unique_ptr<metrics_api::Counter<uint64_t>> currency_counter;
nostd::shared_ptr<opentelemetry::logs::Logger> logger;
Expand Down Expand Up @@ -115,15 +115,15 @@ class CurrencyService final : public oteldemo::CurrencyService::Service
auto new_context = prop->Extract(carrier, current_ctx);
options.parent = GetSpan(new_context)->GetContext();

std::string span_name = "CurrencyService/GetSupportedCurrencies";
std::string span_name = "Currency/GetSupportedCurrencies";
auto span =
get_tracer("currencyservice")->StartSpan(span_name,
get_tracer("currency")->StartSpan(span_name,
{{SemanticConventions::kRpcSystem, "grpc"},
{SemanticConventions::kRpcService, "oteldemo.CurrencyService"},
{SemanticConventions::kRpcMethod, "GetSupportedCurrencies"},
{SemanticConventions::kRpcGrpcStatusCode, 0}},
options);
auto scope = get_tracer("currencyservice")->WithActiveSpan(span);
auto scope = get_tracer("currency")->WithActiveSpan(span);

span->AddEvent("Processing supported currencies request");

Expand Down Expand Up @@ -176,15 +176,15 @@ class CurrencyService final : public oteldemo::CurrencyService::Service
auto new_context = prop->Extract(carrier, current_ctx);
options.parent = GetSpan(new_context)->GetContext();

std::string span_name = "CurrencyService/Convert";
std::string span_name = "Currency/Convert";
auto span =
get_tracer("currencyservice")->StartSpan(span_name,
get_tracer("currency")->StartSpan(span_name,
{{SemanticConventions::kRpcSystem, "grpc"},
{SemanticConventions::kRpcService, "oteldemo.CurrencyService"},
{SemanticConventions::kRpcMethod, "Convert"},
{SemanticConventions::kRpcGrpcStatusCode, 0}},
options);
auto scope = get_tracer("currencyservice")->WithActiveSpan(span);
auto scope = get_tracer("currency")->WithActiveSpan(span);

span->AddEvent("Processing currency conversion request");

Expand Down Expand Up @@ -257,7 +257,7 @@ void RunServer(uint16_t port)
int main(int argc, char **argv) {

if (argc < 2) {
std::cout << "Usage: currencyservice <port>";
std::cout << "Usage: currency <port>";
return 0;
}

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/frontend/gateways/rpc/Currency.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import { ChannelCredentials } from '@grpc/grpc-js';
import { GetSupportedCurrenciesResponse, CurrencyServiceClient, Money } from '../../protos/demo';

const { CURRENCY_SERVICE_ADDR = '' } = process.env;
const { CURRENCY_ADDR = '' } = process.env;

const client = new CurrencyServiceClient(CURRENCY_SERVICE_ADDR, ChannelCredentials.createInsecure());
const client = new CurrencyServiceClient(CURRENCY_ADDR, ChannelCredentials.createInsecure());

const CurrencyGateway = () => ({
convert(from: Money, toCode: string) {
Expand Down
Loading

0 comments on commit e3548c6

Please sign in to comment.