Scout APM Python Logging Agent
Project description
Scout APM Python Logging Agent
A Python package for detailed, easy-to-navigate, managed log monitoring. Sign up for an account at https://www.scoutapm.com to start monitoring your logs and application performance in minutes.
This is to be used alongside scout-apm-python package, thusly requires it.
To use Scout, you'll need to sign up for an account or use our Heroku Addon.
Then, you'll need to enable logging for your individual apps, which will provide a SCOUT_LOGS_INGEST_KEY
Installation
Install the Scout APM Python Logging Agent using pip:
pip install scout-apm-python-logging
Setup and Usage
Using dictConfig
We recommend setting up the OtelScoutHandler
using Python's dictConfig
. Here's an example configuration:
import logging
from logging.config import dictConfig
from scout_apm_python_logging import OtelScoutHandler
LOGGING_CONFIG = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"standard": {
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
},
},
"handlers": {
"otel": {
"level": "DEBUG",
"class": "scout_apm_python_logging.OtelScoutHandler",
"service_name": "your-service-name",
},
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "standard",
},
},
"loggers": {
"": { # Root logger
"handlers": ["console", "otel"],
"level": "DEBUG",
},
},
}
# Apply the logging configuration
dictConfig(LOGGING_CONFIG)
Adding to an Existing Logger
You can also add the OtelScoutHandler
to an existing logger:
import logging
from scout_apm_python_logging import OtelScoutHandler
# Get your logger
logger = logging.getLogger(__name__)
# Create and add the OtelScoutHandler
handler = OtelScoutHandler(service_name="your-service-name")
logger.addHandler(handler)
Configuration
The OtelScoutHandler
only requires service_name
to be supplied to the handler as an argument:
If the scout-apm
is configured (You've set your SCOUT_KEY
, etc), you'll only need add your SCOUT_LOGS_INGEST_KEY
to whichever configuration you are already using. This can also be set as an environment variable.
Make sure to set the SCOUT_LOGS_INGEST_KEY
variable before running your application.
OpenTelemetry
The Scout APM Python Logging Agent leverages OpenTelemetry Python to provide powerful and standardized logging capabilities. OpenTelemetry is an observability framework for cloud-native software, offering a collection of tools, APIs, and SDKs for generating, collecting, and exporting telemetry data (metrics, logs, and traces).
Our OtelScoutHandler
utilizes the OpenTelemetry Python SDK to:
- Create a
LoggerProvider
with a custom resource that includes your service name and instance ID. - Set up an OTLP (OpenTelemetry Protocol) exporter configured to send logs to Scout's ingestion endpoint.
- Add a
BatchLogRecordProcessor
to efficiently process and export log records. - Integrate with Scout APM's request tracking to enrich logs with request-specific information.
This integration allows you to benefit from OpenTelemetry's standardized approach to observability while leveraging Scout APM's powerful analysis and visualization tools.
For more information about OpenTelemetry and its Python SDK, visit the OpenTelemetry Python documentation.
Additional Resources
For more information on using Scout APM and advanced configuration options, please refer to our documentation.
Support
If you encounter any issues or have questions, please open an issue on our GitHub repository or contact our support team at support@scoutapm.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file scout_apm_logging-0.1.2.tar.gz
.
File metadata
- Download URL: scout_apm_logging-0.1.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72396945e0b3c0cdc2922bcb8df7b3b5cdb4e9022101f4e1d9279f3833998e5c |
|
MD5 | 6d3a105de9a72ead254348f337cd8b4d |
|
BLAKE2b-256 | 3ca7274b8965c5a45bd5b5419bf5f41a18188fcf3f8a306ffc729e7667a2a19f |
File details
Details for the file scout_apm_logging-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: scout_apm_logging-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63f74a8a8f6aa3d502045676d0cfcd6073831e71cc6201bce255a7bc8a07c674 |
|
MD5 | 49580bcbdaaff57e8a603116feeefa17 |
|
BLAKE2b-256 | ece6bcb4a4b92d820aacdf3bcadc91ca4657b37a44b0a90278f11493d15aef95 |