OpenTelemetry Pyramid Integration

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.ext.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.ext.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.ext.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.ext.pyramid import PyramidInstrumentor

settings = {
    'pyramid.tweens', 'opentelemetry.ext.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', '/')

API

class opentelemetry.ext.pyramid.PyramidInstrumentor[source]

Bases: opentelemetry.instrumentation.instrumentor.BaseInstrumentor

instrument_config(config)[source]

Enable instrumentation in a Pyramid configurator.

Parameters

config – The Configurator to instrument.

uninstrument_config(config)[source]