Skip to content

Commit e129174

Browse files
Adding web.py example (#523)
Co-authored-by: Diego Hurtado <[email protected]>
1 parent 7cae4d3 commit e129174

File tree

1 file changed

+30
-1
lines changed
  • instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi

1 file changed

+30
-1
lines changed

instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py

+30-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
"""
1515
This library provides a WSGI middleware that can be used on any WSGI framework
16-
(such as Django / Flask) to track requests timing through OpenTelemetry.
16+
(such as Django / Flask / Web.py) to track requests timing through OpenTelemetry.
1717
1818
Usage (Flask)
1919
-------------
@@ -50,6 +50,35 @@ def hello():
5050
application = get_wsgi_application()
5151
application = OpenTelemetryMiddleware(application)
5252
53+
Usage (Web.py)
54+
--------------
55+
56+
.. code-block:: python
57+
58+
import web
59+
from opentelemetry.instrumentation.wsgi import OpenTelemetryMiddleware
60+
from cheroot import wsgi
61+
62+
urls = ('/', 'index')
63+
64+
65+
class index:
66+
67+
def GET(self):
68+
return "Hello, world!"
69+
70+
71+
if __name__ == "__main__":
72+
app = web.application(urls, globals())
73+
func = app.wsgifunc()
74+
75+
func = OpenTelemetryMiddleware(func)
76+
77+
server = wsgi.WSGIServer(
78+
("localhost", 5100), func, server_name="localhost"
79+
)
80+
server.start()
81+
5382
API
5483
---
5584
"""

0 commit comments

Comments
 (0)