You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 PHP, see the OpenTelemetry developer documentation.
8
+
This is a getting started guide for the example applications found in the AWS contrib folder. This walkthrough covers prerequisite, 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 PHP, see the OpenTelemetry developer documentation.
8
9
9
10
## About the Sample Apps
10
11
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
+
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
13
14
### Sample App 1
14
15
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
+
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
17
18
### Sample App 2
18
19
19
20
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
21
22
## 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
+
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.
In another terminal window, navigate to the opentelemetry-php-contrib folder.
104
108
105
109
Run the following command for Sample App 1:
106
110
107
111
`php examples/aws/SampleApp1/SampleApp1.php`
108
112
109
113
The output for this app should look similar to the following:
110
-
```
114
+
115
+
```console
111
116
Starting Sample App
112
117
Which call would you like to make?
113
118
Type outgoing-http-call or aws-sdk-call
@@ -116,22 +121,25 @@ Final trace ID: {"traceId":"1-6115648a-d40b50a270b3c1249bcf60c2"}
116
121
Sample App complete!
117
122
```
118
123
124
+
Currently the `aws-sdk-call` option is commented out. This is due to dependency conflicts between AWS and the PHP Library. If you would like to enable it, follow the instructions in the comments of the SampleApp1.php file.
125
+
119
126
Run the following command for Sample App 2:
120
127
121
128
`php examples/aws/SampleApp2/SampleApp2.php`
122
129
123
130
The output for this app should look similar to the following:
124
-
```
131
+
132
+
```console
125
133
Starting Sample App
126
134
Child span trace ID after service 2: {"traceId":"1-6115649a-230ef2ffe1d289a056b8d0ea"}
127
135
Sample App complete!
128
136
```
129
137
130
-
The trace IDs in any sample app will be completely unique. The first number is the version, the second section is the timestamp, and the last section is a randomized hexadecimal string.
138
+
The trace IDs in any sample app will be completely unique. The first number is the version, the second section is the timestamp, and the last section is a randomized hexadecimal string.
131
139
132
140
## Viewing Traces on AWS X-Ray
133
141
134
-
Navigate to AWS X-Ray on your internet browser.
142
+
Navigate to AWS X-Ray on your internet browser.
135
143
136
144
Click on the traces tab on the left hand side, like the image below:
137
145
@@ -141,6 +149,6 @@ Make sure your region is set to us-west-2:
141
149
142
150
<imgwidth="291"alt="Screen Shot 2021-08-12 at 11 21 59 AM"src="https://user-images.githubusercontent.com/46689344/129248725-d3f7a655-fe3b-47d4-a229-583365e16a54.png">
143
151
144
-
After running the sample app, there should be traces under the traces tab with all relevant information.
152
+
After running the sample app, there should be traces under the traces tab with all relevant information.
145
153
146
154
<imgwidth="1398"alt="Screen Shot 2021-08-09 at 11 42 50 PM"src="https://user-images.githubusercontent.com/46689344/129248704-0888b387-2fa8-4753-824e-d99e0c9a67b6.png">
0 commit comments