Skip to content

fix(proto): accept omitted and proto-named OTLP JSON collector fields#3602

Open
bruno-espino wants to merge 2 commits into
open-telemetry:mainfrom
pydantic:fix/otlp-json-collector-defaults
Open

fix(proto): accept omitted and proto-named OTLP JSON collector fields#3602
bruno-espino wants to merge 2 commits into
open-telemetry:mainfrom
pydantic:fix/otlp-json-collector-defaults

Conversation

@bruno-espino

@bruno-espino bruno-espino commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Changes

The OTLP collector request schemas define their resource arrays as repeated fields. The ProtoJSON mapping omits empty repeated fields by default, and requires parsers to accept both the lowerCamelCase JSON name and the original proto field name. OTLP uses that mapping and says empty telemetry requests should succeed.

The generated collector request types instead require the resource array and only recognize its lowerCamelCase name. For example, an empty logs request ({}) fails with missing field resourceLogs, while a valid resource_logs field is not recognized.

Add serde defaults and proto-name aliases for the trace, log, metric, and profile request roots, and configure the generator to preserve them. Regression tests cover omitted roots and both accepted field-name forms.

This was also tested through an OTLP receiver's JSON ingest path: upstream main rejected {} with missing field resourceLogs; with this change, {} decodes as an empty request and {"resource_logs":[{}]} retains its resource entry.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated
  • Appropriate CHANGELOG.md updated
  • No public API changes

@bruno-espino
bruno-espino requested a review from a team as a code owner July 22, 2026 21:23
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.2%. Comparing base (0e78170) to head (2d2c504).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3602   +/-   ##
=====================================
  Coverage   83.2%   83.2%           
=====================================
  Files        130     130           
  Lines      28246   28246           
=====================================
  Hits       23506   23506           
  Misses      4740    4740           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bruno-espino bruno-espino changed the title Accept omitted and proto-named OTLP JSON collector fields fix(proto): accept omitted and proto-named OTLP JSON collector fields Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant