Pyramid SDK
Monoscope 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 monoscope-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 Monoscope platform. To setup open telemetry, you need to configure the following environment variables:
export OTEL_EXPORTER_OTLP_ENDPOINT="http://otelcol.apitoolkit.io:4317"
export OTEL_SERVICE_NAME="my-service" # Specifies the name of the service.
export OTEL_RESOURCE_ATTRIBUTES="at-project-key={ENTER_YOUR_API_KEY_HERE}" # Adds your API KEY to the resource.
export 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
Monoscope 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 = {
"MONOSCOPE_SERVICE_NAME": "my-service",
"MONOSCOPE_CAPTURE_REQUEST_BODY": True,
"MONOSCOPE_CAPTURE_RESPONSE_BODY": True
}
with Configurator(settings=setting) as config:
# Initialize Monoscope
config.add_tween("monoscope_pyramid.Monoscope")
config.add_route('home', '/')
config.scan()
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 6543, app)
server.serve_forever()
Metadata
Release files for monoscope-pyramid 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| monoscope_pyramid-1.0.0.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| monoscope_pyramid-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.6 kB
Release files / monoscope_pyramid-1.0.0.tar.gz
| Download URL | monoscope_pyramid-1.0.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a270730342926f181320802675c5c35a11dcffbabb6d9d4b71b64c5187ac8be
|
|
BLAKE2b-256 checksum How to use checksums |
0aaf53dff1b7db3c967f5ca19ac9d8fb04fdc9388c5f45a6489b33485d9ec4e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Release files / monoscope_pyramid-1.0.0-py3-none-any.whl
| Download URL | monoscope_pyramid-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f18ea95b22d1155acf4298d411f49668c564fecd08a59de433abe572da0036e
|
|
BLAKE2b-256 checksum How to use checksums |
87022f2a937084849deb56efbce3c74f471ed358864c27cddd1718f5ba42f735
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|