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

[Demo] Add info about React Native app #5704

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/en/docs/demo/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ found here:
- [Recommendation Service](services/recommendation/)
- [Shipping Service](services/shipping/)
- [Image Provider Service](services/imageprovider/)
- [React Native App](services/reactnativeapp/)
julianocosta89 marked this conversation as resolved.
Show resolved Hide resolved

## Scenarios

Expand Down
3 changes: 3 additions & 0 deletions content/en/docs/demo/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ quoteservice(Quote Service):::php
recommendationservice(Recommendation Service):::python
shippingservice(Shipping Service):::rust
queue[(queue<br/>&#40Kafka&#41)]:::java
reactnativeapp(React Native App):::typescript

adservice ---->|gRPC| flagd

Expand Down Expand Up @@ -73,6 +74,8 @@ recommendationservice -->|gRPC| productcatalogservice
recommendationservice -->|gRPC| flagd

shippingservice -->|HTTP| quoteservice

reactnativeapp -->|HTTP| frontendproxy
end

classDef dotnet fill:#178600,color:white;
Expand Down
3 changes: 2 additions & 1 deletion content/en/docs/demo/services/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ To visualize request flows, see the [Service Diagram](../architecture/).
| [currencyservice](currency/) | C++ | Converts one money amount to another currency. Uses real values fetched from European Central Bank. It's the highest QPS service. |
| [emailservice](email/) | Ruby | Sends users an order confirmation email (mock/). |
| [frauddetectionservice](fraud-detection/) | Kotlin | Analyzes incoming orders and detects fraud attempts (mock/). |
| [frontend](frontend/) | JavaScript | Exposes an HTTP server to serve the website. Does not require sign up / login and generates session IDs for all users automatically. |
| [frontend](frontend/) | TypeScript | Exposes an HTTP server to serve the website. Does not require sign up / login and generates session IDs for all users automatically. |
julianocosta89 marked this conversation as resolved.
Show resolved Hide resolved
| [loadgenerator](load-generator/) | Python/Locust | Continuously sends requests imitating realistic user shopping flows to the frontend. |
| [paymentservice](payment/) | JavaScript | Charges the given credit card info (mock/) with the given amount and returns a transaction ID. |
| [productcatalogservice](product-catalog/) | Go | Provides the list of products from a JSON file and ability to search products and get individual products. |
| [quoteservice](quote/) | PHP | Calculates the shipping costs, based on the number of items to be shipped. |
| [recommendationservice](recommendation/) | Python | Recommends other products based on what's given in the cart. |
| [shippingservice](shipping/) | Rust | Gives shipping cost estimates based on the shopping cart. Ships items to the given address (mock/). |
| [reactnativeapp](reactnativeapp/) | TypeScript | React Native mobile application that provides a UI on top of the shopping services. |
38 changes: 38 additions & 0 deletions content/en/docs/demo/services/reactnativeapp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: React Native App
cSpell:ignore: typeof
---

The React Native app provides a mobile UI for users on Android and iOS devices
to interact with the demo's services. It is built with Expo and uses Expo's
julianocosta89 marked this conversation as resolved.
Show resolved Hide resolved
file-based routing to layout the screens for the app.

[React Native app source](https://github.com/open-telemetry/opentelemetry-demo/blob/main/src/reactnativeapp/)

## Instrumentation

The application uses the OpenTelemetry packages to instrument the application at
the JS layer

> **NOTE:** The JS OTel packages are supported for node and web environments.
> While they work for React Native as well they are not currently explicitly
> supported for that environment and may break compatibility with minor version
> updates or require workarounds. Building more support for React Native is an
> area of active development.
jpmunz marked this conversation as resolved.
Show resolved Hide resolved

The main entry point for the application is `app/_layout.tsx` where a hook is
used to initialize the instrumentation and make sure it is loaded before
displaying the UI:

```typescript
import { useTracer } from '@/hooks/useTracer';

const { loaded: tracerLoaded } = useTracer();
```

`hooks/useTracer.ts` contains all the code for setting up instrumentation
including initializing a TracerProvider, establishing an OTLP export,
registering trace context propagators, and registering auto-instrumentation of
network requests.

[Instrumentation source](https://github.com/open-telemetry/opentelemetry-demo/blob/main/src/reactnativeapp/hooks/useTracer.ts)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modelled from the Browser Instrumentation section in content/en/docs/demo/services/frontend.md, in that file a code snippet is included directly but given the TODOs in https://github.com/open-telemetry/opentelemetry-demo/blob/b4dc87ebeac93353106ebdbc7d29eb402e49eca8/src/reactnativeapp/hooks/useTracer.ts I thought it might be better to link out here instead, thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I don't like doc pages that link to code snippets.
But this is my opinion, I'd love to hear what the @open-telemetry/docs-approvers have to say.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's not link out, especially to blob/main which may break at some point because the file was renamed.

Let's have it like on the other pages and keep the source code, we (docs and demo maintainers) can discuss if we can make use of code-excerpts (See https://github.com/open-telemetry/opentelemetry.io/tree/main/tools) for demo source code as well to keep them in sync

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, updated here to include the snippet: e41e5ea