OpenTelemetry Pyramid Instrumentation¶
Pyramid instrumentation supporting pyramid, it can be enabled by
using PyramidInstrumentor
.
Usage¶
There are two methods to instrument Pyramid:
Method 1 (Instrument all Configurators):¶
from pyramid.config import Configurator
from opentelemetry.instrumentation.pyramid import PyramidInstrumentor
PyramidInstrumentor().instrument()
config = Configurator()
# use your config as normal
config.add_route('index', '/')
Method 2 (Instrument one Configurator):¶
from pyramid.config import Configurator
from opentelemetry.instrumentation.pyramid import PyramidInstrumentor
config = Configurator()
PyramidInstrumentor().instrument_config(config)
# use your config as normal
config.add_route('index', '/')
Using pyramid.tweens
setting:¶
If you use Method 2 and then set tweens for your application with the pyramid.tweens
setting,
you need to add opentelemetry.instrumentation.pyramid.trace_tween_factory
explicity to the list,
as well as instrumenting the config as shown above.
For example:
from pyramid.config import Configurator
from opentelemetry.instrumentation.pyramid import PyramidInstrumentor
settings = {
'pyramid.tweens', 'opentelemetry.instrumentation.pyramid.trace_tween_factory\nyour_tween_no_1\nyour_tween_no_2',
}
config = Configurator(settings=settings)
PyramidInstrumentor().instrument_config(config)
# use your config as normal.
config.add_route('index', '/')