opentelemetry-sdk: add support for file exporter with declarative config#5311
opentelemetry-sdk: add support for file exporter with declarative config#5311herin049 wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the opentelemetry-sdk declarative configuration pipeline to support the experimental OTLP JSON Lines file exporter for traces, metrics, and logs by wiring new factory functions into the existing exporter registries and adding output_stream parsing/validation.
Changes:
- Add
otlp_file_developmentexporter factories for spans, metrics, and logs (with helpful “missing package”ConfigurationErrors). - Introduce
_parse_otlp_file_output_stream()and corresponding unit tests forstdout,file://...URIs, and invalid schemes/inputs. - Add changelog entry for the new declarative-config capability.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| opentelemetry-sdk/src/opentelemetry/sdk/_configuration/_common.py | Adds output_stream parsing helper used by file exporters. |
| opentelemetry-sdk/src/opentelemetry/sdk/_configuration/_tracer_provider.py | Registers and constructs OTLP JSON file span exporter via declarative config. |
| opentelemetry-sdk/src/opentelemetry/sdk/_configuration/_meter_provider.py | Registers and constructs OTLP JSON file metric exporter via declarative config. |
| opentelemetry-sdk/src/opentelemetry/sdk/_configuration/_logger_provider.py | Registers and constructs OTLP JSON file log exporter via declarative config. |
| opentelemetry-sdk/tests/_configuration/test_common.py | Adds tests for _parse_otlp_file_output_stream(). |
| opentelemetry-sdk/tests/_configuration/test_tracer_provider.py | Adds trace pipeline tests for otlp_file_development exporter behavior. |
| opentelemetry-sdk/tests/_configuration/test_meter_provider.py | Adds metric pipeline tests for otlp_file_development exporter behavior. |
| opentelemetry-sdk/tests/_configuration/test_logger_provider.py | Adds log pipeline tests for otlp_file_development exporter behavior. |
| .changelog/5311.added | Changelog entry for the new feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ocelotl
left a comment
There was a problem hiding this comment.
I think there is an issue with a function accepting directories when it should only accept paths to files, added a comment.
| preferred_temporality=preferred_temporality, | ||
| preferred_aggregation=preferred_aggregation, | ||
| ) | ||
| if path is not None |
There was a problem hiding this comment.
Is this check really necessary?
There was a problem hiding this comment.
This will give you a type error:
opentelemetry-sdk/src/opentelemetry/sdk/_configuration/_meter_provider.py:368:13 - error: Argument of type "str | None" cannot be assigned to parameter "path" of type "str | PathLike[str]" in function "__init__"
Type "str | None" is not assignable to type "str | PathLike[str]"
Type "None" is not assignable to type "str | PathLike[str]"
"None" is not assignable to "str"
"None" is incompatible with protocol "PathLike[str]"
"__fspath__" is not present (reportArgumentType)
1 error, 0 warnings, 0 informations
Description
Add support for the newly added OTLP JSON File exporter to declarative config.
Refs #3631
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Contrib Repo Change?
Checklist: