Skip to content

Commit

Permalink
use different echo server instead of httpbin
Browse files Browse the repository at this point in the history
  • Loading branch information
jtl-novatec committed May 8, 2024
1 parent cfb4f4d commit 0d0d6be
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 24 deletions.
10 changes: 7 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ services:
ports:
- 5000:5000

httpbin:
image: kennethreitz/httpbin
echo:
image: ealen/echo-server:0.9.2
expose:
- 6000
environment:
PORT: 6000

tutorial:
image: ghcr.io/jensereal/otel-getting-started-tutorial:latest
Expand All @@ -24,4 +28,4 @@ services:
volumes:
- ./tutorial:/workspace
ports:
- 1313:80
- 1313:80
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_user():

def do_stuff():
time.sleep(0.1)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
_response = requests.get(url)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_user():

def do_stuff():
time.sleep(0.1)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
_response = requests.get(url)


Expand Down
2 changes: 1 addition & 1 deletion labs/collector/initial/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def do_stuff():
time.sleep(0.1)
headers = {}
inject(headers)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
response = requests.get(url)
print(response.json())
logging.info(str(response.json()))
Expand Down
2 changes: 1 addition & 1 deletion labs/collector/solution/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def do_stuff():
time.sleep(0.1)
headers = {}
inject(headers)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
response = requests.get(url)
print(response.json())
logging.info(str(response.json()))
Expand Down
2 changes: 1 addition & 1 deletion labs/manual-instrumentation-logs/initial/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_user():

def do_stuff():
time.sleep(0.1)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
_response = requests.get(url)


Expand Down
2 changes: 1 addition & 1 deletion labs/manual-instrumentation-logs/solution/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def get_user():

def do_stuff():
time.sleep(0.1)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
response = requests.get(url)
logging.info(response.json())

Expand Down
2 changes: 1 addition & 1 deletion labs/manual-instrumentation-metrics/initial/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_user():

def do_stuff():
time.sleep(0.1)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
_response = requests.get(url)


Expand Down
2 changes: 1 addition & 1 deletion labs/manual-instrumentation-metrics/solution/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_user():

def do_stuff():
time.sleep(0.1)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
_response = requests.get(url)


Expand Down
2 changes: 1 addition & 1 deletion labs/manual-instrumentation-traces/initial/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_user():

def do_stuff():
time.sleep(0.1)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
response = requests.get(url)


Expand Down
2 changes: 1 addition & 1 deletion labs/manual-instrumentation-traces/solution/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def do_stuff():
inject(headers)

time.sleep(.1)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
_response = requests.get(url, headers=headers)

@app.route('/')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_user():

def do_stuff():
time.sleep(0.1)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
_response = requests.get(url)


Expand Down Expand Up @@ -207,4 +207,4 @@ If OpenTelemetry doesn't support tracing your network client, you can use logs w
- **Instrumentation Libraries**: They are tools to add OpenTelemetry support to libraries without native support.
- **Example with Flask**: A Python Flask app can be instrumented using `opentelemetry-flask-instrumentation`.
- **Developing Libraries**: It's important to follow OpenTelemetry conventions and focus on user-facing operations.
- **Instrumentation Decisions**: Decide based on the complexity and necessity, considering logs or span events for unsupported clients. -->
- **Instrumentation Decisions**: Decide based on the complexity and necessity, considering logs or span events for unsupported clients. -->
16 changes: 7 additions & 9 deletions tutorial/content/labs/instrumentation/manual/traces/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,25 +347,24 @@ Let's see what happens when there is a network boundary in between.
@tracer.start_as_current_span("do_stuff")
def do_stuff():
time.sleep(0.1)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
response = requests.get(url)

# debug
print("response from httpbin:")
print("response from echo:")
print(response.text)
```

For testing purposes, the lab environment includes a `httpbin` server that echos the HTTP requests back to the client.
For testing purposes, the lab environment includes a `echo` server that returns the HTTP requests back to the client.
This is useful because it lets us examine what requests leaving our application look like.
`do_stuff` uses the `requests` package to send a get request to `httpbin`.
`do_stuff` uses the `requests` package to send a get request to `echo`.
To examine what happens, let's add some `print` statements.

```json
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Host": "httpbin",
"User-Agent": "python-requests/2.31.0"
},
```
Expand All @@ -385,7 +384,7 @@ def do_stuff():
inject(headers)

time.sleep(.1)
url = "http://httpbin:80/anything"
url = "http://echo:6000/"
response = requests.get(url, headers=headers) # <- inject trace context into headers
```

Expand All @@ -401,13 +400,12 @@ The requests `get` method has a second argument that allows us to pass in inform
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Host": "httpbin",
"Traceparent": "00-b9041f02352d1558fcdd9ea3804da1f0-aa8b34aa3f883298-01",
"User-Agent": "python-requests/2.31.0"
},
```

Let's re-run our previous experiment with `httpbin` and locate the output of our print statement.
Let's re-run our previous experiment with the `echo` server and locate the output of our print statement.
You should now see that the outgoing request contains a header called `traceparent`.
If you have prior experience with distributed tracing, you might already know that different tracing systems use different formats (such as [b3 propagation](https://github.com/openzipkin/b3-propagation) used by Zipkin).

Expand Down Expand Up @@ -565,4 +563,4 @@ This makes it trivial to share it across different telemetry signals and service
To implement it simply inherit from the `ResourceDetector` class and override the `detect` method.
Finally, we simply call the `merge` method on the `Resource` object, which combines both and returns a new object.
-->
-->

0 comments on commit 0d0d6be

Please sign in to comment.