From 66d4794e4146a7a52c6c3e6ed43bf3bf5e84ac1b Mon Sep 17 00:00:00 2001 From: konfortes Date: Thu, 10 Nov 2022 16:35:28 +0200 Subject: [PATCH 1/2] Update Falcon example to use version 3 Falcon 2 is rarely used, there's version 4 out there. Change the example to use version 3 of falcon which deprecates the API class in favor of App. The falcon instrumentation package in version 3 only able to inject the middleware when the App class is used. --- .../falcon/main.py | 19 ++++++------------- .../falcon/requirements.txt | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/opentelemetry-tracing/opentelemetry-python-tracing/falcon/main.py b/opentelemetry-tracing/opentelemetry-python-tracing/falcon/main.py index 2728532c..22b59ba9 100755 --- a/opentelemetry-tracing/opentelemetry-python-tracing/falcon/main.py +++ b/opentelemetry-tracing/opentelemetry-python-tracing/falcon/main.py @@ -1,30 +1,23 @@ #!/usr/bin/env python import json -import sys -import logging import falcon from wsgiref import simple_server -from opentelemetry import trace -from opentelemetry.trace import SpanKind -tracer = trace.get_tracer(__name__) - class HelloWorldResource(object): def on_get(self, req, resp): """Handles GET requests""" - with tracer.start_as_current_span('internal_span', kind=SpanKind.INTERNAL) as span: - resp.body = json.dumps({'ok': True}) + resp.body = json.dumps({"ok": True}) -app = falcon.API() +app = falcon.App() -app.add_route('/hello', HelloWorldResource()) +app.add_route("/hello", HelloWorldResource()) -if __name__ == '__main__': +if __name__ == "__main__": port = 8000 - print('starting server: ', port) - httpd = simple_server.make_server('127.0.0.1', port, app) + print("starting server: ", port) + httpd = simple_server.make_server("127.0.0.1", port, app) httpd.serve_forever() diff --git a/opentelemetry-tracing/opentelemetry-python-tracing/falcon/requirements.txt b/opentelemetry-tracing/opentelemetry-python-tracing/falcon/requirements.txt index 6ca0945d..e7f9df6d 100644 --- a/opentelemetry-tracing/opentelemetry-python-tracing/falcon/requirements.txt +++ b/opentelemetry-tracing/opentelemetry-python-tracing/falcon/requirements.txt @@ -1,2 +1,2 @@ -falcon==2.0.0 +falcon~=3.0 splunk-opentelemetry[all]>=0.17.0 From 29ce64450e4778012023af1dfb05fb7e7dea20c7 Mon Sep 17 00:00:00 2001 From: Ronen Konfortes Date: Sun, 13 Nov 2022 10:13:42 +0200 Subject: [PATCH 2/2] Revert double quotes --- .../opentelemetry-python-tracing/falcon/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/opentelemetry-tracing/opentelemetry-python-tracing/falcon/main.py b/opentelemetry-tracing/opentelemetry-python-tracing/falcon/main.py index 22b59ba9..b29fb55f 100755 --- a/opentelemetry-tracing/opentelemetry-python-tracing/falcon/main.py +++ b/opentelemetry-tracing/opentelemetry-python-tracing/falcon/main.py @@ -9,15 +9,15 @@ class HelloWorldResource(object): def on_get(self, req, resp): """Handles GET requests""" - resp.body = json.dumps({"ok": True}) + resp.body = json.dumps({'ok': True}) app = falcon.App() -app.add_route("/hello", HelloWorldResource()) +app.add_route('/hello', HelloWorldResource()) -if __name__ == "__main__": +if __name__ == '__main__': port = 8000 - print("starting server: ", port) - httpd = simple_server.make_server("127.0.0.1", port, app) + print('starting server: ', port) + httpd = simple_server.make_server('127.0.0.1', port, app) httpd.serve_forever()