Skip to content

Commit declarative config schema pojos to git#8408

Open
jack-berg wants to merge 4 commits into
open-telemetry:mainfrom
jack-berg:commit-declarative-config-pojos
Open

Commit declarative config schema pojos to git#8408
jack-berg wants to merge 4 commits into
open-telemetry:mainfrom
jack-berg:commit-declarative-config-pojos

Conversation

@jack-berg

Copy link
Copy Markdown
Member

Related to #8402

Currently, we publish config schema pojos in our artifacts but they are produced to a generated source set which is not checked into version control.

As we look to stabilize, we need to be able to see these pojos so that"

  • We can understand what we're looking at for API surface area maintainability and adjust if necessary
  • When schema updates occur, we can understand how those changes actually manifest in the classes

This commits generated pojos to version control as is. Or rather, with as few changes as possible:

  • Build tooling is adjusted to put them in src/main/java instead of generated source set
  • Build tooling automatically runs spotless to reformat them
  • Now that the classes are in main src set and subject to errorprone static analysis, needed to suppress "BoxedPrimitiveEquality" since the generated equals implementation uses optimistic instance equality checks before checking .equals(..). TODO to look into if alternative equals implementations are possible.

In a followup PR, I'm going to rework the generation to produce experimental types to an internal package.

@jack-berg jack-berg requested a review from a team as a code owner May 14, 2026 18:52

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the changes you really want to review. The shape of the pojos themselves are the result of the jsonschema2pojo config defined in this file.

|| ((this.exporter != null) && this.exporter.equals(rhs.exporter))))
&& ((this.exportTimeout == rhs.exportTimeout)
|| ((this.exportTimeout != null)
&& this.exportTimeout.equals(rhs.exportTimeout))))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example (line 207) of the boxed primitive comparison which is flagged by error prone but which we suppress. Its not a real problem because it later does an equals check.

@codecov

codecov Bot commented May 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.77993% with 3022 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.14%. Comparing base (56224f3) to head (4a61e76).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...config/model/ExperimentalInstrumentationModel.java 11.90% 111 Missing ⚠️
...econfig/model/OpenTelemetryConfigurationModel.java 41.04% 87 Missing and 15 partials ⚠️
...model/ExperimentalGeneralInstrumentationModel.java 9.89% 82 Missing ⚠️
...ativeconfig/model/OtlpGrpcMetricExporterModel.java 24.21% 72 Missing ⚠️
...del/ExperimentalPrometheusMetricExporterModel.java 34.31% 66 Missing and 1 partial ⚠️
...declarativeconfig/model/OtlpGrpcExporterModel.java 23.61% 55 Missing ⚠️
...ativeconfig/model/OtlpHttpMetricExporterModel.java 63.04% 39 Missing and 12 partials ⚠️
...clarativeconfig/model/ParentBasedSamplerModel.java 23.88% 51 Missing ⚠️
...model/ExperimentalOtlpFileMetricExporterModel.java 8.00% 46 Missing ⚠️
...el/ExperimentalHttpClientInstrumentationModel.java 8.16% 45 Missing ⚠️
... and 105 more

❌ Your patch check has failed because the patch coverage (40.77%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8408      +/-   ##
============================================
- Coverage     91.04%   82.14%   -8.90%     
- Complexity     7822     8607     +785     
============================================
  Files           893     1008     +115     
  Lines         23721    28824    +5103     
  Branches       2364     3569    +1205     
============================================
+ Hits          21597    23678    +2081     
- Misses         1406     4148    +2742     
- Partials        718      998     +280     

☔ 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.

})
@Generated("jsonschema2pojo")
@SuppressWarnings({"NullAway", "rawtypes", "BoxedPrimitiveEquality"})
public class BatchSpanProcessorModel {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No constructor means jackson is currently relying on initializing using the public constructor, and using a reflection approval to identify all the fields and set using @JsonProperty annotations.

I want to see if we can / should change this.

return maxQueueSize;
}

public BatchSpanProcessorModel withMaxQueueSize(Integer maxQueueSize) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These with* methods are convenient, but are more like setters because they don't create a new immutable instance each time their called. Should investigate whether we can configure to name the set* instead.

StringBuilder sb = new StringBuilder();
sb.append(BatchSpanProcessorModel.class.getName())
.append('@')
.append(Integer.toHexString(System.identityHashCode(this)))

@jack-berg jack-berg May 14, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this toString implementation which includes the identity hash. Should look into whether its configurable to disable. Also, the "" and bracket formatting (i.e. "[=]") are inconsistent with other toString implementations in this repo, so should look into that as well.

@github-actions github-actions Bot mentioned this pull request May 14, 2026
This was referenced May 26, 2026

@jaydeluca jaydeluca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably doesn't matter too much, but when I ran this locally I got a diff on a dozen or so files because of hashcode and equals ordering. I was on Java 17 and when I switched to 21 and regenerated it, it fixed it

Comment thread sdk-extensions/declarative-config/build.gradle.kts
@jack-berg

Copy link
Copy Markdown
Member Author

Thanks @jaydeluca I pushed a commit which adds a check to syncPojoModelsToSrc which requires using java 21. This should deal with the generation order determinism.

@jack-berg

Copy link
Copy Markdown
Member Author

Hey @open-telemetry/java-approvers - will merge this at end of week if nobody has any concerns.

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.

2 participants