Skip to main content

APItoolkit's Logo APItoolkit's Logo

Pyramid SDK

APItoolkit SDK PyPI - Version PyPI - Downloads Join Discord Server APItoolkit Docs

APIToolkit pyramid SDK is a middleware that can be used to monitor incoming HTTP requests, errors and outgoing requests. It is provides additional functionalities on top of the open telemetry instrumentation which creates a custom span for each request capturing details about the request including request, response bodies, headers, status code, duration, etc.


Table of Contents


Installation

Kindly run the command below to install the apitoolkit pyramid sdks and necessary opentelemetry packages:

pip install apitoolkit-pyramid opentelemetry-distro opentelemetry-exporter-otlp
opentelemetry-bootstrap -a install

Setup Open Telemetry

Setting up open telemetry allows you to send traces, metrics and logs to the APIToolkit platform. To setup open telemetry, you need to configure the following environment variables:

OTEL_EXPORTER_OTLP_ENDPOINT="http://otelcol.apitoolkit.io:4317"
OTEL_SERVICE_NAME="my-service" # Specifies the name of the service.
OTEL_RESOURCE_ATTRIBUTES="at-project-key={ENTER_YOUR_API_KEY_HERE}" # Adds your API KEY to the resource.
OTEL_EXPORTER_OTLP_PROTOCOL="grpc" #Specifies the protocol to use for the OpenTelemetry exporter.

Then run the command below to start your server with opentelemetry instrumented:

opentelemetry-instrument python3 myapp.py

APIToolkit Pyramid Configuration

After setting up open telemetry, you can now configure and start the apitoolkit pyramid middleware.

from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
from pyramid.view import view_config


@view_config(
    route_name='home'
)
def home(request):
    return Response('Welcome!')

if __name__ == '__main__':
    setting = {
      "APITOOLKIT_SERVICE_NAME": "my-service",
      "APITOOLKIT_CAPTURE_REQUEST_BODY": True,
      "APITOOLKIT_CAPTURE_RESPONSE_BODY": True
      }
    with Configurator(settings=setting) as config:
        # Initialize APItoolkit
        config.add_tween("apitoolkit_pyramid.APIToolkit")
        config.add_route('home', '/')
        config.scan()
        app = config.make_wsgi_app()
    server = make_server('0.0.0.0', 6543, app)
    server.serve_forever()

Release files for apitoolkit-pyramid 2.0.0

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

Source distribution (sdist)

Source distribution for apitoolkit-pyramid 2.0.0
File Size Uploaded
apitoolkit_pyramid-2.0.0.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for apitoolkit-pyramid 2.0.0
File Interpreter ABI Platform
apitoolkit_pyramid-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.6 kB

Release files / apitoolkit_pyramid-2.0.0.tar.gz

Download URL apitoolkit_pyramid-2.0.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2e99d88d1a423fceeb4a39b3d1a036795ca97ad5613e73f11ec27480b4c9ba81
BLAKE2b-256 checksum
How to use checksums
e338efc92460f1d627706106105413d69fc857a01d10fbdb485a77b5102344c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / apitoolkit_pyramid-2.0.0-py3-none-any.whl

Download URL apitoolkit_pyramid-2.0.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e63f4a6c97f4f394d08311025472710f57119406458ffe0aa8165acd80458ed
BLAKE2b-256 checksum
How to use checksums
5f95f0e9caabff53994b3eaa5da42b6feb3393eadb1fec8a2a3dab6c4f60bfa0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

0.1.6

2 release files

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.0.2

1 release file

0.0.1

1 release file

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