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 ScoutOtelHandler using Python's dictConfig. Here's an example configuration:
import logging
from logging.config import dictConfig
from scout_apm_logging import ScoutOtelHandler
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_logging.ScoutOtelHandler",
"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 ScoutOtelHandler to an existing logger:
import logging
from scout_apm_logging import ScoutOtelHandler
# Get your logger
logger = logging.getLogger(__name__)
# Create and add the ScoutOtelHandler
handler = ScoutOtelHandler(service_name="your-service-name")
logger.addHandler(handler)
Alternative logging configurations are covered in our documentation
Configuration
The ScoutOtelHandler 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 in the above configuration 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 ScoutOtelHandler utilizes the OpenTelemetry Python SDK to:
- Create a
LoggerProviderwith 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
BatchLogRecordProcessorto 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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scout_apm_logging-1.0.2.tar.gz.
File metadata
- Download URL: scout_apm_logging-1.0.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdf6710294edd63b1b58fcc86d82b556771558f8c05af9855ebdb71487918347
|
|
| MD5 |
3d370707ed71398a342a17dfeee42489
|
|
| BLAKE2b-256 |
d58e8059033b7301f997732ddc2e66d83cf84c102b415ad5510e6d5e3e1e5bb7
|
Provenance
The following attestation bundles were made for scout_apm_logging-1.0.2.tar.gz:
Publisher:
release.yml on scoutapp/scout_apm_python_logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scout_apm_logging-1.0.2.tar.gz -
Subject digest:
fdf6710294edd63b1b58fcc86d82b556771558f8c05af9855ebdb71487918347 - Sigstore transparency entry: 758054863
- Sigstore integration time:
-
Permalink:
scoutapp/scout_apm_python_logging@b5fdaff451994815a119de6ef0539e9c923c9380 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/scoutapp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b5fdaff451994815a119de6ef0539e9c923c9380 -
Trigger Event:
push
-
Statement type:
File details
Details for the file scout_apm_logging-1.0.2-py3-none-any.whl.
File metadata
- Download URL: scout_apm_logging-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b534090b48dcc6e1d34c82618479af29bdb3555a4b01bc3a12c46da488d712a7
|
|
| MD5 |
ed2ca233c07c348640e76f2c3c302e9c
|
|
| BLAKE2b-256 |
43f658e6e5d9bd44009b15631f2d7fc67f417c71dd8ba986d23696dc9a133fb3
|
Provenance
The following attestation bundles were made for scout_apm_logging-1.0.2-py3-none-any.whl:
Publisher:
release.yml on scoutapp/scout_apm_python_logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scout_apm_logging-1.0.2-py3-none-any.whl -
Subject digest:
b534090b48dcc6e1d34c82618479af29bdb3555a4b01bc3a12c46da488d712a7 - Sigstore transparency entry: 758054873
- Sigstore integration time:
-
Permalink:
scoutapp/scout_apm_python_logging@b5fdaff451994815a119de6ef0539e9c923c9380 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/scoutapp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b5fdaff451994815a119de6ef0539e9c923c9380 -
Trigger Event:
push
-
Statement type: