Skip to content

Commit ed68620

Browse files
committed
First draft
1 parent a337876 commit ed68620

File tree

1 file changed

+114
-1
lines changed

1 file changed

+114
-1
lines changed

examples/README.md

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,114 @@
1-
Readme for examples (temporary file)
1+
2+
# Tracing with AWS Sample Apps
3+
4+
## Overview
5+
![Current Version](https://img.shields.io/github/v/tag/open-telemetry/opentelemetry-php)
6+
7+
This is a getting started guide for the example applications found in the AWS contrib folder. This walkthrough covers prerequite, installations, how to run the applications, and viewing the traces on X-Ray. Before reading this guide, you should familiarize with distributed tracing and the basics of OpenTelemetry. To learn more about getting started with OpenTelemetry Go, see the OpenTelemetry developer documentation.
8+
9+
## About the Sample Apps
10+
11+
Currently, the ability to instrument an application automatically does not exist, so manually instrumenting the apps was necessary. In both of the applications, creation of a tracer, generation of spans, propagation of contexts, and closing spans was implemented manually. Both of these applications are console applications that export trace data to the OTEL Collector which is then exported to AWS X-Ray.
12+
13+
### Sample App 1
14+
15+
The first sample app in its implementation is creation of a span, then a child span, which is then populated in an HTTP header that makes a request to either aws.amazon.com (http://aws.amazon.com/) or the AWS SDK. The application will prompt you for input on which action you would like to take, and subsequently prints out the trace ID.
16+
17+
### Sample App 2
18+
19+
The second application is a more robust example of how a real-world application may make a request to different services. A main application will make a call to two different microservices called Service1 and Service2. Before calling either of the services, the span context is injected into a carrier that is then taken to the service. Then, the services will extract the context from the carrier and create a new span based upon it. After the services are concluded, the child spans are ended and then the main root span is ended in the main application.
20+
21+
## Prerequisites
22+
The following downloads are necessary for running either of the above specified applications. The two repositories below can be downloaded anywhere on your machine. If you are having an issue with not being able to access the collector with your credentials, clone the aws-otel-collector in your root directory.
23+
24+
Download Docker here: https://docs.docker.com/get-docker/
25+
26+
Clone locally the opentelemetry-php-contrib here: https://github.com/open-telemetry/opentelemetry-php-contrib
27+
28+
Clone locally the aws-otel-collector here: https://github.com/aws-observability/aws-otel-collector
29+
30+
## Set Up
31+
32+
### Docker
33+
34+
Make sure Docker Desktop is running.
35+
36+
### AWS Access Keys
37+
First make sure that your AWS access keys are configured in your root directory. If they are not configured, please visit [here](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) for instructions on how to set them up.
38+
39+
### Grpc Installation
40+
41+
In your root directory, run the following commands:
42+
43+
`brew install PHP`
44+
45+
`sudo pecl install grpc`
46+
47+
If you are having issues please visit one of these resources:
48+
- https://github.com/grpc/grpc/tree/master/src/php
49+
- https://programmersought.com/article/22193951689/
50+
- https://grpc.io/docs/languages/php/quickstart/
51+
- https://cjyabraham.github.io/docs/quickstart/php/
52+
53+
### Update Repository Packages and Dependencies
54+
55+
In the php contrib repository, run the following:
56+
57+
`make install`
58+
59+
Then run to make sure all dependencies and packages are up to date:
60+
61+
`make update`
62+
63+
To make sure everything is working properly, run the following command to run all tests:
64+
65+
`make install && make update && make style && make test && make phan && make psalm && make phpstan`
66+
67+
At this point all necessary items have been installed in your system and you are ready to begin running the application.
68+
69+
## Running the Applications
70+
71+
### Run Collector
72+
73+
First start the up the collector.
74+
75+
Open a new terminal window and navigate into the aws-otel-collector folder.
76+
77+
Run the following command. Make sure to replace `YOUR_ACCESS_KEY_HERE` and `YOUR_SECRET_ACCESS_KEY_HERE` with your own specific keys.
78+
```
79+
docker run --rm -p 4317:4317 -p 55681:55681 -p 8889:8888 \
80+
-e AWS_REGION=us-west-2 \
81+
-e AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_HERE \
82+
-e AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY_HERE \
83+
-v "${PWD}/examples/docker/config-test.yaml":/otel-local-config.yaml \
84+
--name awscollector public.ecr.aws/aws-observability/aws-otel-collector:latest \
85+
--config otel-local-config.yaml
86+
```
87+
In another terminal window, navigate to the opentelemetry-php-contrib folder.
88+
89+
Run the following command for Sample App 1:
90+
91+
`php examples/SampleApp1/SampleApp1.php`
92+
93+
Run the following command for Sample App 2:
94+
95+
`php examples/SampleApp2/SampleApp2.php`
96+
97+
You should see the trace Id in the terminal similar to the following:
98+
```
99+
Final trace ID: {"traceId":"1-61141835-46b87ba81fad02d169814785"}
100+
Sample App complete!
101+
```
102+
## Viewing Traces on AWS X-Ray
103+
104+
Navigate to AWS X-Ray on your internet browser.
105+
106+
Click on the traces tab on the left hand side, like the image below:
107+
108+
TODO: Add image here
109+
110+
Make sure your region is set to us-west-2:
111+
112+
TODO: Add image here
113+
114+
After running the sample app, there should be traces under the traces tab with all relevant information.

0 commit comments

Comments
 (0)