Skip to content

Commit 99b47df

Browse files
codebotenMikeGoldsmithclaudexrmx
authored
config: generate model code from json schema (#4879)
* config: generate model code from json schema Proposing that the first step towards implementing OpenTelemetry Configuration is to produce the model code from the json schema. I did a quick search for tools available to do this and came across datamodel-codegen which seems to do what i expected. Will open following pull requests (in draft) to use this model code, i just want to keep these as clearly separated as possible to make reviewing them easier. Signed-off-by: alex boten <223565+codeboten@users.noreply.github.com> * update tox command’s deps and allowlist * add use-union-operator to datamodel-codegen and regenerate models file * add changelog * disable union-operator and set target python to 3.10 * ignore generated file for linting * fix TypeAlias import for python 3.9 in generated models file * update uv.lock with new dev dependencies * run precommit Signed-off-by: alex boten <223565+codeboten@users.noreply.github.com> * Fix pyright config structure in pyproject.toml datamodel-codegen section was inserted between [tool.pyright] and its include/exclude config, causing pyright to check entire repo (599 files) instead of just included paths. Moved datamodel-codegen section after pyright config. * set use-union-operator to true * Exclude generated models.py from pyright checks Pyright doesn't recognize that pipe operators are valid with from __future__ import annotations on Python 3.9. * Revert uv.lock to test contrib failures Testing if dev dependency updates in uv.lock are causing contrib test failures. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Update uv.lock for datamodel-code-generator dependencies * add test to verify can import models across python versions * add ruff ignore for models file and inline imports * add pylint excludes to test * set use-union-operator to false & regenerate models --------- Signed-off-by: alex boten <223565+codeboten@users.noreply.github.com> Co-authored-by: Mike Goldsmith <goldsmith.mike@gmail.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
1 parent 9a658ac commit 99b47df

File tree

9 files changed

+1589
-1
lines changed

9 files changed

+1589
-1
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ignore=CVS,gen,proto
1111

1212
# Add files or directories matching the regex patterns to be excluded. The
1313
# regex matches against base names, not paths.
14-
ignore-patterns=
14+
ignore-patterns=^models\.py$
1515

1616
# Python code to execute, usually for sys.path manipulation such as
1717
# pygtk.require().

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5252
([#4913](https://github.com/open-telemetry/opentelemetry-python/pull/4913))
5353
- bump semantic-conventions to v1.39.0
5454
([#4914](https://github.com/open-telemetry/opentelemetry-python/pull/4914))
55+
- `opentelemetry-sdk`: automatically generate configuration models using OTel config JSON schema
56+
([#4879](https://github.com/open-telemetry/opentelemetry-python/pull/4879))
5557

5658
## Version 1.39.0/0.60b0 (2025-12-03)
5759

0 commit comments

Comments
 (0)