Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[protobuf] - encode zipcode as a string #587

Merged
merged 11 commits into from
Nov 21, 2022
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,5 @@ significant modifications will be credited to OpenTelemetry Authors.
([#569](https://github.com/open-telemetry/opentelemetry-demo/pull/569))
* Optimize GitHub Builds and fix broken emulation of featureflag
([#536](https://github.com/open-telemetry/opentelemetry-demo/pull/536))
* Change ZipCode data type from int to string
([#587](https://github.com/open-telemetry/opentelemetry-demo/pull/587))
11 changes: 6 additions & 5 deletions docs/manual_span_attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ This document contains the list of manual Span Attributes used throughout the de

## ShippingService

| Name | Type | Description |
|----------------------------|--------|----------------------|
| `app.shipping.cost.total` | number | Total shipping cost |
| `app.shipping.items.count` | number | Total items to ship |
| `app.shipping.tracking.id` | string | Shipping tracking Id |
| Name | Type | Description |
|----------------------------|--------|-------------------------------|
| `app.shipping.cost.total` | number | Total shipping cost |
| `app.shipping.items.count` | number | Total items to ship |
| `app.shipping.tracking.id` | string | Shipping tracking Id |
| `app.shipping.zip_code` | string | Zip code used to ship item(s) |
2 changes: 1 addition & 1 deletion pb/demo.proto
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ message Address {
string city = 2;
string state = 3;
string country = 4;
int32 zip_code = 5;
string zip_code = 5;
}

// -----------------Currency service-----------------
Expand Down
7 changes: 3 additions & 4 deletions src/frontend/components/CheckoutForm/CheckoutForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface IFormData {
city: string;
state: string;
country: string;
zipCode: number;
zipCode: string;
creditCardNumber: string;
creditCardCvv: number;
creditCardExpirationYear: number;
Expand Down Expand Up @@ -45,7 +45,7 @@ const CheckoutForm = ({ onSubmit }: IProps) => {
city: 'Mountain View',
state: 'CA',
country: 'United States',
zipCode: 94043,
zipCode: "94043",
creditCardNumber: '4432-8015-6152-0454',
creditCardCvv: 672,
creditCardExpirationYear: 2030,
Expand Down Expand Up @@ -99,13 +99,12 @@ const CheckoutForm = ({ onSubmit }: IProps) => {
/>
<Input
label="Zip Code"
type="number"
type="text"
name="zipCode"
id="zip_code"
value={zipCode}
onChange={handleChange}
required
pattern="\d{4,5}"
/>
<Input label="City" type="text" name="city" id="city" value={city} required onChange={handleChange} />

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/components/CheckoutItem/CheckoutItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const CheckoutItem = ({
},
cost = { currencyCode: 'USD', units: 0, nanos: 0 },
},
address: { streetAddress = '', city = '', state = '', zipCode = 0, country = '' },
address: { streetAddress = '', city = '', state = '', zipCode = '', country = '' },
}: IProps) => {
const [isCollapsed, setIsCollapsed] = useState(false);

Expand Down
18 changes: 9 additions & 9 deletions src/loadgenerator/locustfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"email": "[email protected]",
"address": {
"streetAddress": "1600 Amphitheatre Parkway",
"zipCode": 94043,
"zipCode": "94043",
"city": "Mountain View",
"state": "CA",
"country": "United States",
Expand All @@ -67,7 +67,7 @@
"email": "[email protected]",
"address": {
"streetAddress": "One Microsoft Way",
"zipCode": 98052,
"zipCode": "98052",
"city": "Redmond",
"state": "WA",
"country": "United States",
Expand All @@ -84,7 +84,7 @@
"email": "[email protected]",
"address": {
"streetAddress": "One Apple Park Way",
"zipCode": 95014,
"zipCode": "95014",
"city": "Cupertino",
"state": "CA",
"country": "United States",
Expand All @@ -101,7 +101,7 @@
"email": "[email protected]",
"address": {
"streetAddress": "1 Hacker Way",
"zipCode": 94025,
"zipCode": "94025",
"city": "Menlo Park",
"state": "CA",
"country": "United States",
Expand All @@ -118,7 +118,7 @@
"email": "[email protected]",
"address": {
"streetAddress": "410 Terry Ave N",
"zipCode": 98109,
"zipCode": "98109",
"city": "Seattle",
"state": "WA",
"country": "United States",
Expand All @@ -135,7 +135,7 @@
"email": "[email protected]",
"address": {
"streetAddress": "100 Winchester Circle",
"zipCode": 95032,
"zipCode": "95032",
"city": "Los Gatos",
"state": "CA",
"country": "United States",
Expand All @@ -152,7 +152,7 @@
"email": "[email protected]",
"address": {
"streetAddress": "150 Elgin St",
"zipCode": 214,
"zipCode": "N9J3Z6",
"city": "Ottawa",
"state": "ON",
"country": "Canada",
Expand All @@ -169,7 +169,7 @@
"email": "[email protected]",
"address": {
"streetAddress": "1355 Market St",
"zipCode": 94103,
"zipCode": "94103",
"city": "San Francisco",
"state": "CA",
"country": "United States",
Expand All @@ -186,7 +186,7 @@
"email": "[email protected]",
"address": {
"streetAddress": "2200 Mission College Blvd",
"zipCode": 95054,
"zipCode": "95054",
"city": "Santa Clara",
"state": "CA",
"country": "United States",
Expand Down
7 changes: 4 additions & 3 deletions src/shippingservice/src/shipping_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ impl ShippingService for ShippingServer {
let parent_cx =
global::get_text_map_propagator(|prop| prop.extract(&MetadataMap(request.metadata())));

let itemct: u32 = request
.into_inner()
let request_message = request.into_inner();

let itemct: u32 = request_message
.items
.into_iter()
.fold(0, |accum, cart_item| accum + (cart_item.quantity as u32));
Expand All @@ -62,8 +63,8 @@ impl ShippingService for ShippingServer {
// check out the create_quote_from_count method to see how we use the span created here
let tracer = global::tracer("shippingservice/get-quote");
let mut span = tracer.start_with_context("get-quote", &parent_cx);

span.add_event("Processing get quote request".to_string(), vec![]);
span.set_attribute(KeyValue::new("app.shipping.zip_code", request_message.address.unwrap().zip_code));

let q = match create_quote_from_count(itemct)
.with_context(Context::current_with_span(span))
Expand Down
6 changes: 3 additions & 3 deletions test/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"city": "Seattle",
"state": "Washington",
"country": "United States",
"zipCode": 98109
"zipCode": "98109"
},
"email": "[email protected]",
"creditCard": {
Expand Down Expand Up @@ -50,7 +50,7 @@
"city": "Mountain View",
"state": "California",
"country": "United States",
"zipCode": 94043
"zipCode": "94043"
},
"items": [
{
Expand Down Expand Up @@ -90,7 +90,7 @@
"city": "Redmond",
"state": "Washington",
"country": "United States",
"zipCode": 98052
"zipCode": "98052"
},
"items": [
{
Expand Down