Skip to main content

Django integration for capturing LogBrew request spans and exceptions.

Project description

logbrew-django

LogBrew logo

Django integration for capturing LogBrew request spans and exceptions with the public Python SDK.

Install

python3 -m pip install logbrew-sdk logbrew-django

The package is typed, ships py.typed, depends on the core logbrew-sdk, and keeps Django as a normal framework dependency instead of owning the user's project layout.

Example

# settings.py
MIDDLEWARE = [
    "logbrew_django.LogBrewDjangoMiddleware",
    *MIDDLEWARE,
]
# app startup code
from logbrew_django import configure_logbrew
from logbrew_sdk import LogBrewClient, RecordingTransport

client = LogBrewClient.create(
    api_key="LOGBREW_API_KEY",
    sdk_name="logbrew-django",
    sdk_version="0.1.0",
)
transport = RecordingTransport.always_accept()
configure_logbrew(
    client=client,
    transport=transport,
    span_id_factory=lambda: "b7ad6b7169203331",
)

LogBrewDjangoMiddleware records successful requests as span events, records unhandled view exceptions as issue plus error-span events, and flushes through the configured transport after each response. If no transport is provided, events stay queued on the core client so the project can flush them itself.

When an incoming request has a valid W3C traceparent header, request capture continues that trace by using the incoming traceId and parent span id while creating a fresh child span id. Missing or malformed traceparent headers keep the existing synthetic request span behavior so bad client headers do not break the project. Automatic metadata uses the request path without query text.

Request duration metrics are opt-in. Set capture_request_metrics=True to emit an explicit http.server.duration histogram for completed requests:

configure_logbrew(
    client=client,
    transport=transport,
    capture_request_metrics=True,
)

The metric includes primitive, low-cardinality metadata: framework, method, routeTemplate, statusCode, and statusCodeClass. Query strings and URL hashes are omitted. Set capture_successful_requests=False with capture_request_metrics=True when you only want duration metrics and not successful request spans. Avoid user IDs, request payloads, headers, or free-form text in custom metric metadata.

By default, transport failures do not break the Django response path. Set raise_flush_errors=True only when your project wants delivery failures to surface as request errors.

Use a clearly fake placeholder like LOGBREW_API_KEY in examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logbrew_django-0.1.2.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logbrew_django-0.1.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file logbrew_django-0.1.2.tar.gz.

File metadata

  • Download URL: logbrew_django-0.1.2.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for logbrew_django-0.1.2.tar.gz
Algorithm Hash digest
SHA256 65bc356da9a1258e65655564962932389c8604a80f3bbdacca43c99f4fc42be5
MD5 ad36c268d13fe228d78e801f9a98e51d
BLAKE2b-256 6c08780da9250f7cba0bdb762d4b2300adf42176af7581035266160c941a5fb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for logbrew_django-0.1.2.tar.gz:

Publisher: publish-packages.yml on LogBrewCo/sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file logbrew_django-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: logbrew_django-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for logbrew_django-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c82895acaf6f1077a7c0b5fac607cda67accf04c16c3807761e2892628c26c55
MD5 e25059358cd9085ef1f42d7eabdbae1b
BLAKE2b-256 47d065055c60d07bdac0f7f579c314646b828c308e9af5cbd964074c129d06c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for logbrew_django-0.1.2-py3-none-any.whl:

Publisher: publish-packages.yml on LogBrewCo/sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page