2020
2121Usage
2222-----
23- There are two methods to instrument Pyramid:
23+ There are two methods to instrument Pyramid:
2424
2525Method 1 (Instrument all Configurators):
2626----------------------------------------
27+
2728.. code:: python
2829
2930 from pyramid.config import Configurator
3031 from opentelemetry.ext.pyramid import PyramidInstrumentor
3132
32- PyramidInstrumentor.instrument()
33+ PyramidInstrumentor() .instrument()
3334
3435 config = Configurator()
3536
3839
3940Method 2 (Instrument one Configurator):
4041---------------------------------------
42+
4143.. code:: python
4244
4345 from pyramid.config import Configurator
4951 # use your config as normal
5052 config.add_route('index', '/')
5153
52- Using ``pyramid.tweens`` settings:
53- ----------------------------------
54- If you use Method 2 and then set tweens for your application with the ``pyramid.tweens`` setting,
55- you need to add ``opentelemetry.ext.pyramid.trace_tween_factory`` explicity to the list,
56- *as well as* instrumenting the config with `PyramidInstrumentor().instrument_config(config)`.
54+ Using ``pyramid.tweens`` setting:
55+ ---------------------------------
56+
57+ If you use Method 2 and then set tweens for your application with the ``pyramid.tweens`` setting,
58+ you need to add ``opentelemetry.ext.pyramid.trace_tween_factory`` explicity to the list,
59+ *as well as* instrumenting the config as shown above.
60+
61+ For example:
5762
58- For example:
5963.. code:: python
64+
65+ from pyramid.config import Configurator
66+ from opentelemetry.ext.pyramid import PyramidInstrumentor
67+
6068 settings = {
6169 'pyramid.tweens', 'opentelemetry.ext.pyramid.trace_tween_factory\\ nyour_tween_no_1\\ nyour_tween_no_2',
6270 }
6371 config = Configurator(settings=settings)
64- PyramidInstrumentor.instrument_config(config)
72+ PyramidInstrumentor() .instrument_config(config)
6573
6674 # use your config as normal.
6775 config.add_route('index', '/')
76+
77+ API
6878---
6979"""
7080
8797from opentelemetry .trace import TracerProvider , get_tracer
8898
8999
90- def traced_init (wrapped , instance , args , kwargs ):
100+ def _traced_init (wrapped , instance , args , kwargs ):
91101 settings = kwargs .get ("settings" , {})
92102 tweens = aslist (settings .get ("pyramid.tweens" , []))
93103
@@ -119,7 +129,7 @@ def _instrument(self, **kwargs):
119129 """Integrate with Pyramid Python library.
120130 https://docs.pylonsproject.org/projects/pyramid/en/latest/
121131 """
122- _wrap ("pyramid.config" , "Configurator.__init__" , traced_init )
132+ _wrap ("pyramid.config" , "Configurator.__init__" , _traced_init )
123133
124134 def _uninstrument (self , ** kwargs ):
125135 """"Disable Pyramid instrumentation"""
@@ -131,9 +141,6 @@ def instrument_config(self, config):
131141
132142 Args:
133143 config: The Configurator to instrument.
134-
135- Returns:
136- An instrumented Configurator.
137144 """
138145 config .include ("opentelemetry.ext.pyramid.callbacks" )
139146
0 commit comments