Skip to main content

pyramid-otelapm

OpenTelemetry APM integration for the Pyramid framework.

This package is a drop-in, vendor-neutral replacement for pyramid-elasticapm: it sets up the OpenTelemetry SDK, exports traces via OTLP/HTTP and instruments a Pyramid application (plus a few commonly used libraries) with as little wiring as possible.

Installation

Install with pip:

$ pip install pyramid-otelapm

Optionally, install support for instrumenting some commonly used libraries:

$ pip install pyramid-otelapm[requests,botocore,sqlalchemy,logging]

Then include it in your pyramid application via config:

[app:main]
...
pyramid.includes = pyramid_otelapm

or programmatically in your application:

config.include('pyramid_otelapm')

Settings

Settings for the OpenTelemetry SDK can be specified via the opentelemetry namespace:

  • opentelemetry.endpoint: The OTLP/HTTP collector endpoint, e.g. http://otel-collector.example.com:4318. If unset, pyramid_otelapm stays completely inactive (no-op).

  • opentelemetry.service_name: The service name reported to the collector.

  • opentelemetry.environment: The deployment environment (e.g. testing, production, …), reported as deployment.environment.

  • opentelemetry.service_distribution: The name of the package you are deploying. pyramid_otelapm will retrieve the installed version of this package and report it as service.version on every span, so traces can be tied back to the exact software release they were recorded from.

  • opentelemetry.transactions_ignore_patterns: Whitespace separated list of regular expressions; matching request URLs are excluded from tracing.

Instrumented libraries

Besides the Pyramid request/response cycle itself, pyramid_otelapm enables the following (optional, best-effort) OpenTelemetry instrumentations if the respective libraries (and their corresponding opentelemetry-instrumentation-* package) are installed:

  • requests (outgoing HTTP calls)

  • botocore (boto3/AWS calls, e.g. S3)

  • SQLAlchemy (database queries)

  • logging (correlate log records with the active trace/span)

Missing optional instrumentation packages are silently skipped.

Instrumenting SQLAlchemy engines created before config.include

opentelemetry-instrumentation-sqlalchemy patches sqlalchemy.create_engine itself, so only engines created after instrumentation was set up get traced. If your application creates SQLAlchemy engines before the Pyramid Configurator is built (and config.include('pyramid_otelapm') is called), call pyramid_otelapm.setup_tracing(settings) explicitly, as early as possible during application startup:

import pyramid_otelapm

pyramid_otelapm.setup_tracing(settings)
# ... create SQLAlchemy engines, boto3 clients, etc ...

config = Configurator(settings=settings)
config.include('pyramid_otelapm')  # safe to call again, is a no-op

setup_tracing is idempotent, so calling it again later via config.include is safe.

Transaction naming

pyramid_otelapm.get_transaction_name(request) returns a human readable transaction name ("<method> <route pattern>"), the same convention used by pyramid_elasticapm. This is useful e.g. to pass a consistent transaction/view name to a frontend RUM agent (like Grafana Faro or Elastic APM RUM) alongside the backend traces.

Release files for pyramid-otelapm 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyramid-otelapm 1.0.1
File Size Uploaded
pyramid_otelapm-1.0.1.tar.gz 10.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyramid-otelapm 1.0.1
File Interpreter ABI Platform
pyramid_otelapm-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.2 kB

Release files / pyramid_otelapm-1.0.1.tar.gz

Download URL pyramid_otelapm-1.0.1.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e97f640866652565499f5b0352853b5178a59188f8e9a9cf2bfb874b359cbb16
BLAKE2b-256 checksum
How to use checksums
ab0448101abca13a7ed2e1e1bb653571c3d817c14bec848ba84cc4105eaae593
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.18

Release files / pyramid_otelapm-1.0.1-py3-none-any.whl

Download URL pyramid_otelapm-1.0.1-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
043cd797f9cf986166aaaaf22212a18e651c2ecca8a2798f9fe864b2fbc901ae
BLAKE2b-256 checksum
How to use checksums
cdce5507e79f9dc5ff3f9b46b250d55c5198d21d7b9eeac34829e6362a262794
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.18

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page