Skip to content

Commit 33c61ad

Browse files
Hybrid apm (#5)
* local dev doc update * changes to remove the errors from email and product catalog we were making to clean up the demo * make this SQL query longer --------- Co-authored-by: Jeremy Hicks <jeremyh@splunk.com>
1 parent e4c4e5e commit 33c61ad

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

src/shop-dc-shim/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ The service includes **intentional Jackson serialization errors** on the transac
4949
**Note:** This requires the instance to have a k3s/k3d deployment with Astronomy Shop Demo
5050
- Update and use `build-image-quay-dev.sh` to build a new image with your local changes
5151
- Reference that new image in `k8s-addition.yaml` and copy to your instance
52-
- `kubectl apply -f k8s-addition.yaml` will add the `shop-dc-shim-db`, `shop-dc-shim`, and `shop-dc-load-generator` pods to your cluster
52+
- On your instances with the cluser `export APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY=<SE-LABS-TOKEN>`
53+
- `envsubst < k8s-additions.yaml | kubectl apply -f -` will add the `shop-dc-shim-db`, `shop-dc-shim`, and `shop-dc-load-generator` pods to your cluster
54+
- **NOTE:** `envsubst` is important here to pass the appd agent token
5355
- Once `shop-dc-shim` finishes spinning up (5-7min) the load generator will start sending traffic
5456
- **For DBMon** upgrade splunk-otel-collector helm chart with `dbmon-values.yaml`
5557
- E.G. `helm upgrade splunk-otel-collector-1760534477 --values /home/splunk/dbmon-values.yaml splunk-otel-collector-chart/splunk-otel-collector --reuse-values`

src/shop-dc-shim/load-generator/shop_load_generator.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,14 @@ def __init__(self, shop_service_url: str = "http://localhost:8070"):
9797
["TERM-001", "TERM-002"])
9898
]
9999

100-
# Product catalog (simulating local inventory)
101100
self.products = [
102-
Product("SKU-TELE-001", "Professional Telescope", 299.99, "telescopes"),
103-
Product("SKU-BINO-001", "High-Power Binoculars", 149.99, "binoculars"),
104-
Product("SKU-LENS-001", "Camera Lens Set", 199.99, "accessories"),
105-
Product("SKU-TRIPOD-001", "Carbon Fiber Tripod", 89.99, "accessories"),
106-
Product("SKU-BOOK-001", "Astronomy Guide Book", 24.99, "books"),
107-
Product("SKU-COMPASS-001", "Digital Compass", 39.99, "navigation"),
108-
Product("SKU-FILTER-001", "Light Pollution Filter", 79.99, "accessories"),
109-
Product("SKU-MOUNT-001", "Telescope Mount", 159.99, "accessories")
101+
Product("OLJCESPC7Z", "Professional Telescope", 299.99, "telescopes"),
102+
Product("2ZYFJ3GM2N", "High-Power Binoculars", 149.99, "binoculars"),
103+
Product("L9ECAV7KIM", "Camera Lens Set", 199.99, "accessories"),
104+
Product("HQTGWGPNH4", "Astronomy Guide Book", 24.99, "books"),
105+
Product("LS4PSXUNUM", "Digital Compass", 39.99, "navigation"),
106+
Product("6E92ZMYYFZ", "Light Pollution Filter", 79.99, "accessories"),
107+
Product("9SIQT8TOJO", "Telescope Mount", 159.99, "accessories")
110108
]
111109

112110
# Customer database (simulating local customer records)
@@ -191,7 +189,7 @@ def create_purchase_request(self, store: StoreLocation, terminal: str) -> Dict[s
191189
"creditCardNumber": "4111-1111-1111-1111", # Test card number
192190
"creditCardCvv": random.randint(100, 999),
193191
"expirationMonth": random.randint(1, 12),
194-
"expirationYear": random.randint(2025, 2030)
192+
"expirationYear": random.randint(2030, 2035)
195193
},
196194
"items": purchase_items
197195
}

src/shop-dc-shim/src/main/java/com/opentelemetry/demo/shopdcshim/repository/ShopTransactionRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
@Repository
1717
public interface ShopTransactionRepository extends JpaRepository<ShopTransaction, Long> {
1818

19-
Optional<ShopTransaction> findByTransactionId(String transactionId);
19+
@Query("SELECT s FROM ShopTransaction s, ShopTransaction s2, ShopTransaction s3 WHERE s.transactionId = :transactionId AND s.id = s2.id AND s.id = s3.id ORDER BY s.createdAt")
20+
Optional<ShopTransaction> findByTransactionId(@Param("transactionId") String transactionId);
2021

2122
Optional<ShopTransaction> findByLocalOrderId(String localOrderId);
2223

src/shop-dc-shim/src/main/java/com/opentelemetry/demo/shopdcshim/service/CloudCheckoutService.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.springframework.stereotype.Service;
1414
import oteldemo.Demo.*;
1515
import oteldemo.CheckoutServiceGrpc;
16+
import oteldemo.CartServiceGrpc;
1617

1718
import javax.annotation.PreDestroy;
1819
import java.util.UUID;
@@ -24,6 +25,7 @@ public class CloudCheckoutService {
2425

2526
private final ManagedChannel channel;
2627
private final CheckoutServiceGrpc.CheckoutServiceBlockingStub checkoutStub;
28+
private final CartServiceGrpc.CartServiceBlockingStub cartStub;
2729
private final Tracer tracer;
2830
private final String checkoutServiceAddr;
2931

@@ -40,6 +42,12 @@ public CloudCheckoutService(
4042

4143
this.checkoutStub = CheckoutServiceGrpc.newBlockingStub(channel);
4244

45+
// Create cart service client otherwise we get cart errors on checkout
46+
ManagedChannel cartChannel = ManagedChannelBuilder.forTarget("cart:8080")
47+
.usePlaintext()
48+
.build();
49+
this.cartStub = CartServiceGrpc.newBlockingStub(cartChannel);
50+
4351
log.info("Initialized Cloud Checkout Service with gRPC address: {}", checkoutServiceAddr);
4452
}
4553

@@ -73,6 +81,13 @@ public CloudCheckoutResult submitToCloudCheckout(String localOrderId, ShopPurcha
7381

7482
// Generate a unique user ID for this transaction
7583
String userId = "shop-dc-" + UUID.randomUUID().toString();
84+
85+
for (var item : request.getItems()) {
86+
cartStub.addItem(AddItemRequest.newBuilder()
87+
.setUserId(userId)
88+
.setItem(CartItem.newBuilder().setProductId(item.getProductId()).setQuantity(item.getQuantity()).build())
89+
.build());
90+
}
7691

7792
// Build the gRPC PlaceOrderRequest
7893
PlaceOrderRequest grpcRequest = buildGrpcRequest(userId, request);

0 commit comments

Comments
 (0)