Skip to content

Commit 224b1d2

Browse files
committed
Enhance TFO-Python-SDK with OTEL Autoinstrumentation (Fixing CI-Builder)
1 parent b45653c commit 224b1d2

File tree

5 files changed

+97
-49
lines changed

5 files changed

+97
-49
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
strategy:
106106
fail-fast: false
107107
matrix:
108-
python-version: ['3.10', '3.11', '3.12']
108+
python-version: ['3.12', '3.13']
109109
steps:
110110
- name: Checkout code
111111
uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434

3535
### Added
3636

37+
- **Build Package in Dev Dependencies**: Added `build>=1.0.0` to dev dependencies for local package building
38+
- **gRPC Header Lowercase Support**: Added `_get_grpc_headers()` method in `OTLPExporterFactory` to ensure gRPC metadata keys are lowercase (required by gRPC specification)
39+
- **Comprehensive Unit Tests**: Added `TestGetGrpcHeaders` test class for gRPC header handling
40+
3741
- **TFO v2 API Configuration Alignment**: Updated SDK configuration to align with TFO-Collector v1.1.2 (OCB-native)
3842
- Added `v2_api` configuration section with `enabled` and `v2_only` options
3943
- Added custom endpoint paths support (`traces_endpoint`, `metrics_endpoint`, `logs_endpoint`)
@@ -73,10 +77,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7377

7478
### Changed
7579

80+
- **CI Python Version Matrix**: Updated CI workflow to test on Python 3.12 and 3.13 only (aligned with `requires-python = ">=3.12"`)
7681
- Updated version to 1.1.2 to align with TFO-Collector v1.1.2 release
7782
- Default endpoint changed from `api.telemetryflow.id:4317` to `localhost:4317` for development
7883
- Added `TELEMETRYFLOW_PROTOCOL` and `TELEMETRYFLOW_TIMEOUT` environment variables
7984

85+
### Fixed
86+
87+
- **gRPC Header Case Sensitivity**: Fixed gRPC exporter to use lowercase header keys (gRPC metadata specification requires lowercase keys)
88+
8089
### SDK Configuration Structure
8190

8291
```yaml

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ By participating in this project, you agree to maintain a respectful and inclusi
5353

5454
### Prerequisites
5555

56-
- Python 3.10 or higher
56+
- Python 3.12 or higher (minimum supported version)
5757
- Git
5858
- Make (optional, for using Makefile commands)
5959

docs/BUILD-SYSTEM.md

Lines changed: 66 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ graph TB
6060

6161
### Python Version
6262

63-
Python 3.12 or higher is required:
63+
Python 3.12 or higher is required (tested on 3.12 and 3.13):
6464

6565
```bash
6666
python --version # Should be 3.12+
@@ -80,17 +80,26 @@ Or with all optional dependencies:
8080
pip install -e ".[dev,http,grpc]"
8181
```
8282

83+
The `[dev]` extra includes all development tools:
84+
85+
- pytest, pytest-asyncio, pytest-cov - Testing
86+
- mypy - Type checking
87+
- ruff - Linting
88+
- black, isort - Formatting
89+
- pre-commit - Git hooks
90+
- build - Package building (wheel/sdist)
91+
8392
### Required Tools
8493

85-
| Tool | Purpose | Installation |
86-
|------|---------|--------------|
87-
| pip | Package installer | Built-in |
88-
| pytest | Testing | `pip install pytest` |
89-
| ruff | Linting/formatting | `pip install ruff` |
90-
| mypy | Type checking | `pip install mypy` |
91-
| black | Code formatting | `pip install black` |
92-
| build | Package building | `pip install build` |
93-
| twine | Package publishing | `pip install twine` |
94+
| Tool | Purpose | Installation |
95+
| ------ | ------------------ | ------------------- |
96+
| pip | Package installer | Built-in |
97+
| pytest | Testing | Included in `[dev]` |
98+
| ruff | Linting/formatting | Included in `[dev]` |
99+
| mypy | Type checking | Included in `[dev]` |
100+
| black | Code formatting | Included in `[dev]` |
101+
| build | Package building | Included in `[dev]` |
102+
| twine | Package publishing | `pip install twine` |
94103

95104
## Project Structure
96105

@@ -279,6 +288,7 @@ make format
279288
```
280289

281290
Equivalent to:
291+
282292
```bash
283293
black src/ tests/
284294
isort src/ tests/
@@ -321,8 +331,9 @@ make build
321331
```
322332

323333
Creates:
324-
- `dist/telemetryflow_sdk-1.1.1-py3-none-any.whl`
325-
- `dist/telemetryflow_sdk-1.1.1.tar.gz`
334+
335+
- `dist/telemetryflow_sdk-1.1.2-py3-none-any.whl`
336+
- `dist/telemetryflow_sdk-1.1.2.tar.gz`
326337

327338
#### make clean
328339

@@ -333,6 +344,7 @@ make clean
333344
```
334345

335346
Removes:
347+
336348
- `build/`
337349
- `dist/`
338350
- `*.egg-info/`
@@ -497,18 +509,18 @@ ls -la dist/
497509

498510
```
499511
dist/
500-
├── telemetryflow_sdk-1.1.1-py3-none-any.whl # Wheel (binary)
501-
└── telemetryflow_sdk-1.1.1.tar.gz # Source distribution
512+
├── telemetryflow_sdk-1.1.2-py3-none-any.whl # Wheel (binary)
513+
└── telemetryflow_sdk-1.1.2.tar.gz # Source distribution
502514
```
503515

504516
### Installing Built Package
505517

506518
```bash
507519
# Install wheel
508-
pip install dist/telemetryflow_sdk-1.1.1-py3-none-any.whl
520+
pip install dist/telemetryflow_sdk-1.1.2-py3-none-any.whl
509521

510522
# Install from source
511-
pip install dist/telemetryflow_sdk-1.1.1.tar.gz
523+
pip install dist/telemetryflow_sdk-1.1.2.tar.gz
512524
```
513525

514526
## Publishing
@@ -669,7 +681,7 @@ build-backend = "setuptools.build_meta"
669681

670682
[project]
671683
name = "telemetryflow-sdk"
672-
version = "1.1.1"
684+
version = "1.1.2"
673685
requires-python = ">=3.12"
674686

675687
[tool.pytest.ini_options]
@@ -697,7 +709,36 @@ line-length = 100
697709

698710
### GitHub Actions
699711

700-
Create `.github/workflows/ci.yml`:
712+
The project uses GitHub Actions for CI/CD with the following workflows:
713+
714+
| Workflow | Trigger | Purpose |
715+
| ------------- | ----------------- | -------------------------------------- |
716+
| `ci.yml` | Push/PR | Lint, test, build verification |
717+
| `docker.yml` | Push to main/tags | Build Docker images |
718+
| `release.yml` | Tags (v*.*.\*) | Publish to PyPI, create GitHub release |
719+
720+
### Python Version Matrix
721+
722+
CI tests are run on **Python 3.12 and 3.13** to ensure compatibility:
723+
724+
```yaml
725+
strategy:
726+
matrix:
727+
python-version: ["3.12", "3.13"]
728+
```
729+
730+
### CI Jobs
731+
732+
The CI workflow includes:
733+
734+
1. **Lint & Code Quality** - Runs `make ci-lint` (ruff, mypy, format checks)
735+
2. **Unit Tests** - Runs `make ci-test-unit` on Python 3.12 and 3.13
736+
3. **Integration Tests** - Runs `make ci-test-integration`
737+
4. **Build Verification** - Tests on Ubuntu, macOS, and Windows
738+
5. **Security Scan** - Runs `make ci-security` (bandit)
739+
6. **Coverage Report** - Generates and uploads coverage reports
740+
741+
### Example CI Configuration
701742

702743
```yaml
703744
name: CI
@@ -724,16 +765,13 @@ jobs:
724765
python-version: ${{ matrix.python-version }}
725766
726767
- name: Install dependencies
727-
run: pip install -e ".[dev]"
768+
run: make ci-deps
728769
729770
- name: Lint
730-
run: make lint
731-
732-
- name: Type check
733-
run: make typecheck
771+
run: make ci-lint
734772
735773
- name: Test
736-
run: make test-coverage
774+
run: make ci-test-unit
737775
738776
build:
739777
runs-on: ubuntu-latest
@@ -747,10 +785,11 @@ jobs:
747785
with:
748786
python-version: "3.12"
749787
788+
- name: Install dependencies
789+
run: make ci-deps
790+
750791
- name: Build
751-
run: |
752-
pip install build
753-
make build
792+
run: make ci-build
754793
755794
- name: Upload artifacts
756795
uses: actions/upload-artifact@v4

docs/TESTING.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -449,15 +449,22 @@ pie title Coverage Targets by Layer
449449
"Client (85%+)" : 85
450450
```
451451

452-
| Layer | Target | Focus Areas |
453-
|-------|--------|-------------|
454-
| Domain | 90%+ | Value objects, validation |
455-
| Application | 85%+ | Commands, queries, buses |
456-
| Infrastructure | 80%+ | Handlers, exporters |
457-
| Client | 85%+ | Public API, lifecycle |
452+
| Layer | Target | Focus Areas |
453+
| -------------- | ------ | ------------------------- |
454+
| Domain | 90%+ | Value objects, validation |
455+
| Application | 85%+ | Commands, queries, buses |
456+
| Infrastructure | 80%+ | Handlers, exporters |
457+
| Client | 85%+ | Public API, lifecycle |
458458

459459
## CI/CD Integration
460460

461+
### Supported Python Versions
462+
463+
The SDK is tested on **Python 3.12 and 3.13**:
464+
465+
- **Python 3.12**: Minimum supported version (LTS)
466+
- **Python 3.13**: Latest stable version
467+
461468
### GitHub Actions Example
462469

463470
```yaml
@@ -484,27 +491,19 @@ jobs:
484491
with:
485492
python-version: ${{ matrix.python-version }}
486493

487-
- name: Install dependencies
488-
run: |
489-
python -m pip install --upgrade pip
490-
pip install -e ".[dev]"
494+
- name: Install CI dependencies
495+
run: make ci-deps
491496

492497
- name: Run linting
493-
run: |
494-
ruff check src/ tests/
498+
run: make ci-lint
495499

496-
- name: Run type checking
497-
run: |
498-
mypy src/
499-
500-
- name: Run tests with coverage
501-
run: |
502-
pytest --cov=telemetryflow --cov-report=xml
500+
- name: Run unit tests
501+
run: make ci-test-unit
503502

504503
- name: Upload coverage
505504
uses: codecov/codecov-action@v4
506505
with:
507-
file: ./coverage.xml
506+
file: ./coverage-unit.xml
508507
```
509508
510509
### Pre-commit Hooks
@@ -618,6 +617,7 @@ def test_record_histogram_with_attributes(self, client):
618617
### Tests Hanging
619618

620619
If tests hang, check for:
620+
621621
- Unended spans
622622
- Unclosed connections
623623
- Missing shutdown calls

0 commit comments

Comments
 (0)