Registry / observability / datadog-logger

datadog-logger

JSON →
library1.0.3pypypi✓ verified 23d ago

The datadog-logger library provides a Python logging handler designed to send log records as events to DataDog. It simplifies integrating Python application logs with DataDog's event stream for monitoring and alerting. The current version is 1.0.2, and releases are infrequent, primarily focused on maintenance and minor improvements.

pip install datadog-logger
INSTALL
IMPORT
SIG · DATADOG-LOGGER
D
datadog-logger
observabilitypythonv1.0.3
Install
2.3s avg
Import
501ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.520s · 22.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.3s · import 0.482s · 23MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DatadogLogHandler
from datadog_logger import DatadogLogHandler
from datadog_logger import DataDogHandler

This quickstart demonstrates how to set up a `DataDogHandler` and integrate it with a standard Python `logging` instance. It configures the handler with API/APP keys, a hostname, and custom tags. Remember to replace placeholder keys with actual DataDog credentials, ideally loaded from environment variables.

import logging import os from datadog_logger import DataDogHandler # Configure your DataDog API and APP keys DD_API_KEY = os.environ.get('DATADOG_API_KEY', 'YOUR_DATADOG_API_KEY') DD_APP_KEY = os.environ.get('DATADOG_APP_KEY', 'YOUR_DATADOG_APP_KEY') # Set up a standard Python logger logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) # Configure the DataDogHandler # For production, set a meaningful hostname and tags datadog_handler = DataDogHandler( api_key=DD_API_KEY, app_key=DD_APP_KEY, hostname='my_application_host', tags=['env:dev', 'service:example-app'] ) # Add the handler to your logger logger.addHandler(datadog_handler) # Log some messages logger.info('Application started successfully.') logger.warning('Potential issue detected in module X.', extra={'user_id': 456, 'module': 'auth'}) logger.error('Critical error: Database connection failed!')
Debug
Known issues
gotchaThis library sends log records as DataDog *Events*, not DataDog *Logs*. If you intend to use DataDog's Log Management, you will need a different integration (e.g., DataDog Agent or `datadog-api-client` for Logs API).
fix
Understand the distinction: 'Events' are for notifications/alerts, 'Logs' are for detailed log aggregation. Use this library if you explicitly want DataDog Events for your logs.
affects: All versions
gotchaDataDog API Key and APP Key are mandatory for authentication. Without valid keys, the handler will fail to send events to DataDog.
fix
Ensure `api_key` and `app_key` parameters are correctly configured with your DataDog credentials. Load them from secure sources like environment variables or a configuration management system, not hardcoded.
affects: All versions
gotchaBy default, `DataDogHandler` sends events synchronously (buffer_size=1). For high-volume logging, this can impact application performance. Events are flushed upon each log call.
fix
Initialize `DataDogHandler` with `buffer_size` greater than 1 (e.g., `buffer_size=50`) to buffer events and send them in batches. This introduces a slight delay but can significantly reduce network calls and improve performance.
affects: All versions
gotchaOmitting `hostname` or relevant `tags` can make it difficult to filter and analyze events effectively within DataDog.
fix
Always provide a meaningful `hostname` and a list of descriptive `tags` (e.g., `['env:prod', 'service:api']`) during handler initialization to ensure proper indexing and discoverability in DataDog.
affects: All versions
breakingVersion 1.0.0 introduced a significant rewrite, including the removal of the `python-logstash-logger` dependency and improvements to error handling and tag support. Users upgrading from pre-1.0.0 versions will likely encounter breaking changes.
fix
If upgrading from an older version, review the GitHub repository's commit history around 1.0.0 for specific changes and adapt your code accordingly. The current API (1.x.x) is stable.
affects: <1.0.0 to >=1.0.0
Upgrade
Version history
1.0.3latest on PyPI · released Jul 27, 2026
Audit
Dependencies
requestsrequiredUsed for making HTTP requests to the DataDog API.
python-json-loggerrequiredUsed for formatting log records into JSON format before sending.
Agent activity
32 hits · last 30 days
node
26
OpenAI (training)
2
Bingbot
1
Resources
datadog-logger — pip install datadog-logger · libregistry