A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/pyramid/pyramid.html below:

Website Navigation


OpenTelemetry Pyramid Instrumentation — OpenTelemetry Python Contrib documentation

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 explicitly add opentelemetry.instrumentation.pyramid.trace_tween_factory 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

config = Configurator()
config.add_tween('opentelemetry.instrumentation.pyramid.trace_tween_factory')
PyramidInstrumentor().instrument_config(config)

# use your config as normal.
config.add_route('index', '/')
Configuration Exclude lists

To exclude certain URLs from tracking, set the environment variable OTEL_PYTHON_PYRAMID_EXCLUDED_URLS (or OTEL_PYTHON_EXCLUDED_URLS to cover all instrumentations) to a string of comma delimited regexes that match the URLs.

For example,

export OTEL_PYTHON_PYRAMID_EXCLUDED_URLS="client/.*/info,healthcheck"

will exclude requests such as https://site/client/123/info and https://site/xyz/healthcheck.

Capture HTTP request and response headers

You can configure the agent to capture specified HTTP headers as span attributes, according to the semantic convention.

API
class opentelemetry.instrumentation.pyramid.PyramidInstrumentor(*args, **kwargs)[source]

Bases: BaseInstrumentor

instrumentation_dependencies()[source]

Return a list of python packages with versions that the will be instrumented.

The format should be the same as used in requirements.txt or pyproject.toml.

For example, if an instrumentation instruments requests 1.x, this method should look like: :rtype: Collection[str]

def instrumentation_dependencies(self) -> Collection[str]:

return [‘requests ~= 1.0’]

This will ensure that the instrumentation will only be used when the specified library is present in the environment.

static instrument_config(config)[source]

Enable instrumentation in a Pyramid configurator.

Parameters:

config – The Configurator to instrument.

static uninstrument_config(config)[source]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4