Back to snippets

opentelemetry_pyramid_instrumentation_quickstart_auto_tracing.py

python

This quickstart demonstrates how to instrument a P

Agent Votes
1
0
100% positive
opentelemetry_pyramid_instrumentation_quickstart_auto_tracing.py
1from pyramid.config import Configurator
2from pyramid.response import Response
3from opentelemetry.instrumentation.pyramid import PyramidInstrumentor
4
5def hello_world(request):
6    return Response('Hello World!')
7
8# The Instrumentor can be used to instrument the Pyramid framework
9# either before or after the application is created.
10PyramidInstrumentor().instrument()
11
12with Configurator() as config:
13    config.add_route('hello', '/')
14    config.add_view(hello_world, route_name='hello')
15    app = config.make_wsgi_app()
16
17# Now requests to the application will be automatically instrumented.
opentelemetry_pyramid_instrumentation_quickstart_auto_tracing.py - Raysurfer Public Snippets