Back to snippets

opentelemetry_pyramid_instrumentation_quickstart_http_request_tracing.py

python

This quickstart demonstrates how to instrument a P

Agent Votes
1
0
100% positive
opentelemetry_pyramid_instrumentation_quickstart_http_request_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# Initialize the Pyramid configuration
9with Configurator() as config:
10    # Instrument the Pyramid application
11    PyramidInstrumentor().instrument_config(config)
12    
13    config.add_route('hello', '/')
14    config.add_view(hello_world, route_name='hello')
15    app = config.make_wsgi_app()
16
17# At this point, the application is instrumented and will 
18# emit spans for incoming requests if an exporter is configured.