datadog-async-handler 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,175 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be added to the global gitignore or merged into this project gitignore. For a PyCharm
158
+ # project, it is recommended to create a project-specific .gitignore file and
159
+ # place it in the project root directory.
160
+ .idea/
161
+
162
+ # VS Code
163
+ .vscode/
164
+
165
+ # Local development
166
+ .hatch/
167
+ .pytest_cache/
168
+
169
+ # macOS
170
+ .DS_Store
171
+
172
+ # Windows
173
+ Thumbs.db
174
+ ehthumbs.db
175
+ Desktop.ini
@@ -0,0 +1,48 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Initial release of datadog-http-handler
12
+ - Asynchronous HTTP logging handler for Datadog
13
+ - Batching support with configurable batch size and flush intervals
14
+ - Automatic retry logic with exponential backoff
15
+ - Comprehensive error handling and graceful degradation
16
+ - Type hints and mypy compatibility
17
+ - Support for all Datadog sites (US, EU, Government, etc.)
18
+ - Environment variable configuration support
19
+ - Framework integration examples (Django, FastAPI, Flask)
20
+ - Background worker thread for non-blocking log processing
21
+ - Automatic tag enrichment (environment, service, version)
22
+ - Memory-efficient queue management
23
+ - Graceful shutdown handling
24
+
25
+ ### Changed
26
+ - N/A (initial release)
27
+
28
+ ### Deprecated
29
+ - N/A (initial release)
30
+
31
+ ### Removed
32
+ - N/A (initial release)
33
+
34
+ ### Fixed
35
+ - N/A (initial release)
36
+
37
+ ### Security
38
+ - N/A (initial release)
39
+
40
+ ## [0.1.0] - 2025-08-25
41
+
42
+ ### Added
43
+ - Initial development version
44
+ - Core DatadogHTTPHandler implementation
45
+ - Basic test suite
46
+ - Documentation and examples
47
+ - Modern Python packaging with Hatch
48
+ - Comprehensive development tooling (Ruff, mypy, pytest)
@@ -0,0 +1,207 @@
1
+ # Contributing to datadog-http-handler
2
+
3
+ Thank you for your interest in contributing to datadog-http-handler! This document provides guidelines for contributing to the project.
4
+
5
+ ## Development Setup
6
+
7
+ ### Prerequisites
8
+
9
+ - Python 3.9 or higher
10
+ - [UV](https://github.com/astral-sh/uv) package manager
11
+
12
+ ### Setup
13
+
14
+ 1. Clone the repository:
15
+ ```bash
16
+ git clone https://github.com/enlyft/datadog-http-handler.git
17
+ cd datadog-http-handler
18
+ ```
19
+
20
+ 2. Install UV:
21
+ ```bash
22
+ curl -LsSf https://astral.sh/uv/install.sh | sh
23
+ ```
24
+
25
+ 3. Install dependencies:
26
+ ```bash
27
+ uv sync --extra dev
28
+ ```
29
+
30
+ 4. Install pre-commit hooks:
31
+ ```bash
32
+ uv run pre-commit install
33
+ ```
34
+
35
+ ## Development Workflow
36
+
37
+ ### Running Tests
38
+
39
+ ```bash
40
+ # Run all tests
41
+ uv run pytest
42
+
43
+ # Run with coverage
44
+ uv run pytest --cov=src/datadog_http_handler --cov-report=term-missing
45
+
46
+ # Run specific test
47
+ uv run pytest tests/test_handler.py::TestDatadogHTTPHandler::test_init_with_api_key
48
+ ```
49
+
50
+ ### Code Quality
51
+
52
+ ```bash
53
+ # Format code
54
+ uv run ruff format
55
+
56
+ # Lint code
57
+ uv run ruff check
58
+
59
+ # Type checking
60
+ uv run mypy src/datadog_http_handler tests
61
+
62
+ # Run all quality checks
63
+ uv run pre-commit run --all-files
64
+ ```
65
+
66
+ ### Building
67
+
68
+ ```bash
69
+ # Build package
70
+ uv build
71
+
72
+ # Install locally for testing
73
+ uv pip install -e .
74
+ ```
75
+
76
+ ## Code Style
77
+
78
+ This project uses:
79
+ - **Ruff** for linting and formatting
80
+ - **mypy** for type checking
81
+ - **pytest** for testing
82
+
83
+ ### Code Guidelines
84
+
85
+ 1. **Type Hints**: All public functions and methods must have type hints
86
+ 2. **Docstrings**: All public classes and functions must have docstrings
87
+ 3. **Tests**: All new features must include tests
88
+ 4. **Coverage**: Maintain >95% test coverage
89
+
90
+ ### Example Function
91
+
92
+ ```python
93
+ def process_log_item(record: logging.LogRecord, tags: Optional[list[str]] = None) -> HTTPLogItem:
94
+ """Process a log record into a Datadog HTTP log item.
95
+
96
+ Args:
97
+ record: The log record to process
98
+ tags: Optional additional tags to include
99
+
100
+ Returns:
101
+ Formatted HTTP log item ready for submission
102
+
103
+ Raises:
104
+ ValueError: If record cannot be processed
105
+ """
106
+ # Implementation here
107
+ pass
108
+ ```
109
+
110
+ ## Testing
111
+
112
+ ### Test Structure
113
+
114
+ - **Unit Tests**: Test individual functions and methods
115
+ - **Integration Tests**: Test component interactions
116
+ - **Performance Tests**: Benchmark critical paths
117
+
118
+ ### Writing Tests
119
+
120
+ ```python
121
+ import pytest
122
+ from datadog_http_handler import DatadogHTTPHandler
123
+
124
+ def test_handler_initialization():
125
+ """Test that handler initializes correctly."""
126
+ handler = DatadogHTTPHandler(
127
+ api_key="test-key",
128
+ service="test-service"
129
+ )
130
+ assert handler.service == "test-service"
131
+ handler.close()
132
+ ```
133
+
134
+ ### Test Fixtures
135
+
136
+ Use the provided fixtures in `tests/conftest.py`:
137
+
138
+ ```python
139
+ def test_log_formatting(handler_config, sample_log_record):
140
+ """Test log record formatting."""
141
+ handler = DatadogHTTPHandler(**handler_config)
142
+ log_item = handler._format_log_item(sample_log_record)
143
+ assert log_item.service == "test-service"
144
+ ```
145
+
146
+ ## Documentation
147
+
148
+ ### Docstring Style
149
+
150
+ Use Google-style docstrings:
151
+
152
+ ```python
153
+ def my_function(param1: str, param2: int = 0) -> bool:
154
+ """Brief description of the function.
155
+
156
+ Longer description if needed.
157
+
158
+ Args:
159
+ param1: Description of param1
160
+ param2: Description of param2 with default value
161
+
162
+ Returns:
163
+ Description of return value
164
+
165
+ Raises:
166
+ ValueError: When param1 is invalid
167
+ ConnectionError: When network request fails
168
+ """
169
+ ```
170
+
171
+ ## Pull Request Process
172
+
173
+ 1. **Fork** the repository
174
+ 2. **Create** a feature branch: `git checkout -b feature/amazing-feature`
175
+ 3. **Make** your changes
176
+ 4. **Add** tests for new functionality
177
+ 5. **Run** quality checks: `uv run pre-commit run --all-files`
178
+ 6. **Commit** your changes: `git commit -m "Add amazing feature"`
179
+ 7. **Push** to your fork: `git push origin feature/amazing-feature`
180
+ 8. **Create** a Pull Request
181
+
182
+ ### PR Requirements
183
+
184
+ - [ ] All tests pass
185
+ - [ ] Code coverage maintained (>95%)
186
+ - [ ] Type checking passes
187
+ - [ ] Linting passes
188
+ - [ ] Documentation updated
189
+ - [ ] CHANGELOG.md updated
190
+
191
+ ## Release Process
192
+
193
+ 1. Update version in `src/datadog_http_handler/__init__.py`
194
+ 2. Update CHANGELOG.md
195
+ 3. Create a tag: `git tag v1.0.0`
196
+ 4. Push tag: `git push origin v1.0.0`
197
+ 5. GitHub Actions will automatically build and publish
198
+
199
+ ## Getting Help
200
+
201
+ - **Issues**: Report bugs and request features on GitHub Issues
202
+ - **Discussions**: Ask questions in GitHub Discussions
203
+ - **Documentation**: Check the README.md and code docstrings
204
+
205
+ ## License
206
+
207
+ By contributing, you agree that your contributions will be licensed under the MIT License.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Parth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.