From 0d0d6be5ca337effd9b3efe8497c96ad33dd2e56 Mon Sep 17 00:00:00 2001 From: Jan-Niklas Tille Date: Tue, 7 May 2024 12:58:52 +0200 Subject: [PATCH] use different echo server instead of httpbin --- docker-compose.yml | 10 +++++++--- .../library-instrumentation/initial/src/app.py | 2 +- .../library-instrumentation/solution/src/app.py | 2 +- labs/collector/initial/src/app.py | 2 +- labs/collector/solution/src/app.py | 2 +- .../initial/src/app.py | 2 +- .../solution/src/app.py | 2 +- .../initial/src/app.py | 2 +- .../solution/src/app.py | 2 +- .../initial/src/app.py | 2 +- .../solution/src/app.py | 2 +- .../automatic/instrumentation_libraries/index.md | 4 ++-- .../labs/instrumentation/manual/traces/index.md | 16 +++++++--------- 13 files changed, 26 insertions(+), 24 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 47a012e..3eca545 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 @@ -24,4 +28,4 @@ services: volumes: - ./tutorial:/workspace ports: - - 1313:80 \ No newline at end of file + - 1313:80 diff --git a/labs/automatic-instrumentation/library-instrumentation/initial/src/app.py b/labs/automatic-instrumentation/library-instrumentation/initial/src/app.py index dcfed97..8f3bb83 100644 --- a/labs/automatic-instrumentation/library-instrumentation/initial/src/app.py +++ b/labs/automatic-instrumentation/library-instrumentation/initial/src/app.py @@ -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) diff --git a/labs/automatic-instrumentation/library-instrumentation/solution/src/app.py b/labs/automatic-instrumentation/library-instrumentation/solution/src/app.py index 7980a27..8285514 100644 --- a/labs/automatic-instrumentation/library-instrumentation/solution/src/app.py +++ b/labs/automatic-instrumentation/library-instrumentation/solution/src/app.py @@ -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) diff --git a/labs/collector/initial/src/app.py b/labs/collector/initial/src/app.py index 72abcae..f57fcc5 100644 --- a/labs/collector/initial/src/app.py +++ b/labs/collector/initial/src/app.py @@ -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())) diff --git a/labs/collector/solution/src/app.py b/labs/collector/solution/src/app.py index 16c4c02..c8485a2 100644 --- a/labs/collector/solution/src/app.py +++ b/labs/collector/solution/src/app.py @@ -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())) diff --git a/labs/manual-instrumentation-logs/initial/src/app.py b/labs/manual-instrumentation-logs/initial/src/app.py index dcfed97..8f3bb83 100644 --- a/labs/manual-instrumentation-logs/initial/src/app.py +++ b/labs/manual-instrumentation-logs/initial/src/app.py @@ -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) diff --git a/labs/manual-instrumentation-logs/solution/src/app.py b/labs/manual-instrumentation-logs/solution/src/app.py index 268e347..701ec42 100644 --- a/labs/manual-instrumentation-logs/solution/src/app.py +++ b/labs/manual-instrumentation-logs/solution/src/app.py @@ -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()) diff --git a/labs/manual-instrumentation-metrics/initial/src/app.py b/labs/manual-instrumentation-metrics/initial/src/app.py index dcfed97..8f3bb83 100644 --- a/labs/manual-instrumentation-metrics/initial/src/app.py +++ b/labs/manual-instrumentation-metrics/initial/src/app.py @@ -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) diff --git a/labs/manual-instrumentation-metrics/solution/src/app.py b/labs/manual-instrumentation-metrics/solution/src/app.py index 9008c0a..42e0ecb 100644 --- a/labs/manual-instrumentation-metrics/solution/src/app.py +++ b/labs/manual-instrumentation-metrics/solution/src/app.py @@ -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) diff --git a/labs/manual-instrumentation-traces/initial/src/app.py b/labs/manual-instrumentation-traces/initial/src/app.py index 3cd52ef..1df59b6 100644 --- a/labs/manual-instrumentation-traces/initial/src/app.py +++ b/labs/manual-instrumentation-traces/initial/src/app.py @@ -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) diff --git a/labs/manual-instrumentation-traces/solution/src/app.py b/labs/manual-instrumentation-traces/solution/src/app.py index 4ad82af..b8fed05 100644 --- a/labs/manual-instrumentation-traces/solution/src/app.py +++ b/labs/manual-instrumentation-traces/solution/src/app.py @@ -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('/') diff --git a/tutorial/content/labs/instrumentation/automatic/instrumentation_libraries/index.md b/tutorial/content/labs/instrumentation/automatic/instrumentation_libraries/index.md index 34b07f2..a721674 100644 --- a/tutorial/content/labs/instrumentation/automatic/instrumentation_libraries/index.md +++ b/tutorial/content/labs/instrumentation/automatic/instrumentation_libraries/index.md @@ -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) @@ -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. --> \ No newline at end of file +- **Instrumentation Decisions**: Decide based on the complexity and necessity, considering logs or span events for unsupported clients. --> diff --git a/tutorial/content/labs/instrumentation/manual/traces/index.md b/tutorial/content/labs/instrumentation/manual/traces/index.md index b6f4a84..f7f5421 100644 --- a/tutorial/content/labs/instrumentation/manual/traces/index.md +++ b/tutorial/content/labs/instrumentation/manual/traces/index.md @@ -347,17 +347,17 @@ 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 @@ -365,7 +365,6 @@ To examine what happens, let's add some `print` statements. "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "Host": "httpbin", "User-Agent": "python-requests/2.31.0" }, ``` @@ -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 ``` @@ -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). @@ -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. ---> \ No newline at end of file +-->