Skip to content

Commit

Permalink
Merge branch 'main' into accountingservice-change
Browse files Browse the repository at this point in the history
  • Loading branch information
julianocosta89 authored Jun 27, 2024
2 parents f8ef400 + 918e86a commit 5f13792
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 43 deletions.
10 changes: 6 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ JAEGERTRACING_IMAGE=jaegertracing/all-in-one:1.57
OPENSEARCH_IMAGE=opensearchproject/opensearch:2.14.0
POSTGRES_IMAGE=postgres:16.3
PROMETHEUS_IMAGE=quay.io/prometheus/prometheus:v2.52.0
REDIS_IMAGE=redis:7.2-alpine
VALKEY_IMAGE=valkey/valkey:7.2-alpine
# must also update the version arg in ./test/tracetesting/Dockerfile
TRACETEST_IMAGE=kubeshop/tracetest:v1.3.0

Expand All @@ -25,6 +25,8 @@ ENV_PLATFORM=local
OTEL_COLLECTOR_HOST=otelcol
OTEL_COLLECTOR_PORT_GRPC=4317
OTEL_COLLECTOR_PORT_HTTP=4318
OTEL_COLLECTOR_CONFIG=./src/otelcollector/otelcol-config.yml
OTEL_COLLECTOR_CONFIG_EXTRAS=./src/otelcollector/otelcol-config-extras.yml
OTEL_EXPORTER_OTLP_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT_GRPC}
PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:8080/otlp-http/v1/traces

Expand Down Expand Up @@ -129,9 +131,9 @@ FLAGD_PORT=8013
KAFKA_SERVICE_PORT=9092
KAFKA_SERVICE_ADDR=kafka:${KAFKA_SERVICE_PORT}

# Redis
REDIS_PORT=6379
REDIS_ADDR=redis-cart:${REDIS_PORT}
# Valkey
VALKEY_PORT=6379
VALKEY_ADDR=valkey-cart:${VALKEY_PORT}

# ********************
# Telemetry Components
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/component_build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ jobs:
max-parallelism = 2
- name: Matrix Build and push demo images
if: steps.check_changes.outputs.skip == 'false'
uses: docker/build-push-action@v6.0.1
uses: docker/build-push-action@v6.1.0
with:
context: ${{ matrix.file_tag.context }}
file: ${{ matrix.file_tag.file }}
Expand Down
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ the release.

## Unreleased

* [cartservice] bump .NET package to 1.9.0 release
([#1610](https://github.com/open-telemetry/opentelemetry-demo/pull/1610))
* [accountingservice] convert from Go service to .NET service, uses
OpenTelemetry .NET Automatic Instrumentation.
([#1538](https://github.com/open-telemetry/opentelemetry-demo/pull/1538))
* [frontend] fixed default flagd port for HTTPS connections
([#1609](https://github.com/open-telemetry/opentelemetry-demo/pull/1609))
* [cartservice] bump .NET package to 1.9.0 release
([#1610](https://github.com/open-telemetry/opentelemetry-demo/pull/1610))
* [Valkey] Replace Redis with Valkey
([#1619](https://github.com/open-telemetry/opentelemetry-demo/pull/1619))
* ([recommendation] updated flag name to match flagd configuration
([#1634](https://github.com/open-telemetry/opentelemetry-demo/pull/1634))

## 1.10.0

Expand Down
20 changes: 10 additions & 10 deletions docker-compose.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ services:
environment:
- CART_SERVICE_PORT
- FLAGD_HOST
- REDIS_ADDR
- VALKEY_ADDR
- OTEL_EXPORTER_OTLP_ENDPOINT
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=cartservice
- ASPNETCORE_URLS=http://*:${CART_SERVICE_PORT}
depends_on:
redis-cart:
valkey-cart:
condition: service_started
otelcol:
condition: service_started
Expand Down Expand Up @@ -515,18 +515,18 @@ services:
logging:
*logging

# Redis used by Cart service
redis-cart:
image: ${REDIS_IMAGE}
container_name: redis-cart
user: redis
# Valkey used by Cart service
valkey-cart:
image: ${VALKEY_IMAGE}
container_name: valkey-cart
user: valkey
deploy:
resources:
limits:
memory: 20M
restart: unless-stopped
ports:
- "${REDIS_PORT}"
- "${VALKEY_PORT}"
logging: *logging


Expand Down Expand Up @@ -584,8 +584,8 @@ services:
restart: unless-stopped
command: [ "--config=/etc/otelcol-config.yml", "--config=/etc/otelcol-config-extras.yml" ]
volumes:
- ./src/otelcollector/otelcol-config.yml:/etc/otelcol-config.yml
- ./src/otelcollector/otelcol-config-extras.yml:/etc/otelcol-config-extras.yml
- ${OTEL_COLLECTOR_CONFIG}:/etc/otelcol-config.yml
- ${OTEL_COLLECTOR_CONFIG_EXTRAS}:/etc/otelcol-config-extras.yml
ports:
- "${OTEL_COLLECTOR_PORT_GRPC}"
- "${OTEL_COLLECTOR_PORT_HTTP}"
Expand Down
22 changes: 11 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ services:
- CART_SERVICE_PORT
- FLAGD_HOST
- FLAGD_PORT
- REDIS_ADDR
- VALKEY_ADDR
- OTEL_EXPORTER_OTLP_ENDPOINT
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=cartservice
- ASPNETCORE_URLS=http://*:${CART_SERVICE_PORT}
depends_on:
redis-cart:
valkey-cart:
condition: service_started
otelcol:
condition: service_started
Expand Down Expand Up @@ -190,7 +190,7 @@ services:

# Email service
emailservice:
image: demo/emailservice-contrib:latest
image: ${IMAGE_NAME}:${DEMO_VERSION}-emailservice
container_name: email-service
build:
context: ./
Expand Down Expand Up @@ -625,18 +625,18 @@ services:
retries: 10
logging: *logging

# Redis used by Cart service
redis-cart:
image: ${REDIS_IMAGE}
container_name: redis-cart
user: redis
# Valkey used by Cart service
valkey-cart:
image: ${VALKEY_IMAGE}
container_name: valkey-cart
user: valkey
deploy:
resources:
limits:
memory: 20M
restart: unless-stopped
ports:
- "${REDIS_PORT}"
- "${VALKEY_PORT}"
logging: *logging


Expand Down Expand Up @@ -694,8 +694,8 @@ services:
restart: unless-stopped
command: [ "--config=/etc/otelcol-config.yml", "--config=/etc/otelcol-config-extras.yml" ]
volumes:
- ./src/otelcollector/otelcol-config.yml:/etc/otelcol-config.yml
- ./src/otelcollector/otelcol-config-extras.yml:/etc/otelcol-config-extras.yml
- ${OTEL_COLLECTOR_CONFIG}:/etc/otelcol-config.yml
- ${OTEL_COLLECTOR_CONFIG_EXTRAS}:/etc/otelcol-config-extras.yml
ports:
- "${OTEL_COLLECTOR_PORT_GRPC}"
- "${OTEL_COLLECTOR_PORT_HTTP}"
Expand Down
2 changes: 1 addition & 1 deletion src/cartservice/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cart Service

This service stores user shopping carts in Redis.
This service stores user shopping carts in Valkey.

## Local Build

Expand Down
14 changes: 7 additions & 7 deletions src/cartservice/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
using OpenFeature.Contrib.Hooks.Otel;

var builder = WebApplication.CreateBuilder(args);
string redisAddress = builder.Configuration["REDIS_ADDR"];
if (string.IsNullOrEmpty(redisAddress))
string valkeyAddress = builder.Configuration["VALKEY_ADDR"];
if (string.IsNullOrEmpty(valkeyAddress))
{
Console.WriteLine("REDIS_ADDR environment variable is required.");
Console.WriteLine("VALKEY_ADDR environment variable is required.");
Environment.Exit(1);
}

Expand All @@ -33,7 +33,7 @@

builder.Services.AddSingleton<ICartStore>(x=>
{
var store = new RedisCartStore(x.GetRequiredService<ILogger<RedisCartStore>>(), redisAddress);
var store = new ValkeyCartStore(x.GetRequiredService<ILogger<ValkeyCartStore>>(), valkeyAddress);
store.Initialize();
return store;
});
Expand All @@ -48,7 +48,7 @@
builder.Services.AddSingleton(x =>
new CartService(
x.GetRequiredService<ICartStore>(),
new RedisCartStore(x.GetRequiredService<ILogger<RedisCartStore>>(), "badhost:1234"),
new ValkeyCartStore(x.GetRequiredService<ILogger<ValkeyCartStore>>(), "badhost:1234"),
x.GetRequiredService<IFeatureClient>()
));

Expand Down Expand Up @@ -79,8 +79,8 @@

var app = builder.Build();

var redisCartStore = (RedisCartStore) app.Services.GetRequiredService<ICartStore>();
app.Services.GetRequiredService<StackExchangeRedisInstrumentation>().AddConnection(redisCartStore.GetConnection());
var ValkeyCartStore = (ValkeyCartStore) app.Services.GetRequiredService<ICartStore>();
app.Services.GetRequiredService<StackExchangeRedisInstrumentation>().AddConnection(ValkeyCartStore.GetConnection());

app.MapGrpcService<CartService>();
app.MapGrpcHealthChecksService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace cartservice.cartstore;

public class RedisCartStore : ICartStore
public class ValkeyCartStore : ICartStore
{
private readonly ILogger _logger;
private const string CartFieldName = "cart";
Expand All @@ -25,13 +25,13 @@ public class RedisCartStore : ICartStore

private readonly ConfigurationOptions _redisConnectionOptions;

public RedisCartStore(ILogger<RedisCartStore> logger, string redisAddress)
public ValkeyCartStore(ILogger<ValkeyCartStore> logger, string valkeyAddress)
{
_logger = logger;
// Serialize empty cart into byte array.
var cart = new Oteldemo.Cart();
_emptyCartBytes = cart.ToByteArray();
_connectionString = $"{redisAddress},ssl=false,allowAdmin=true,abortConnect=false";
_connectionString = $"{valkeyAddress},ssl=false,allowAdmin=true,abortConnect=false";

_redisConnectionOptions = ConfigurationOptions.Parse(_connectionString);

Expand Down
11 changes: 9 additions & 2 deletions src/frontend/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,19 @@ if (typeof window !== 'undefined') {
* We connect to flagd through the envoy proxy, straight from the browser,
* for this we need to know the current hostname and port.
*/

const useTLS = window.location.protocol === 'https:';
let port = useTLS ? 443 : 80;
if (window.location.port) {
port = parseInt(window.location.port, 10);
}

OpenFeature.setProvider(
new FlagdWebProvider({
host: window.location.hostname,
pathPrefix: 'flagservice',
port: window.location.port ? parseInt(window.location.port, 10) : 80,
tls: window.location.protocol === 'https:',
port: port,
tls: useTLS,
maxRetries: 3,
maxDelay: 10000,
})
Expand Down
3 changes: 2 additions & 1 deletion src/otelcollector/otelcol-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ receivers:
targets:
- endpoint: http://frontendproxy:${env:ENVOY_PORT}
redis:
endpoint: "redis-cart:6379"
endpoint: "valkey-cart:6379"
username: "valkey"
collection_interval: 10s

exporters:
Expand Down
2 changes: 1 addition & 1 deletion src/recommendationservice/recommendation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_product_list(request_product_ids):
request_product_ids = request_product_ids_str.split(',')

# Feature flag scenario - Cache Leak
if check_feature_flag("recommendationCache"):
if check_feature_flag("recommendationServiceCacheFailure"):
span.set_attribute("app.recommendation.cache_enabled", True)
if random.random() < 0.5 or first_run:
first_run = False
Expand Down

0 comments on commit 5f13792

Please sign in to comment.