Skip to content

Commit declarative config schema pojos to git#8408

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

Commit declarative config schema pojos to git#8408
jack-berg wants to merge 1 commit 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
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

❌ Patch coverage is 42.40643% with 2939 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.41%. Comparing base (83f947f) to head (d9226cf).

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 ⚠️
...model/ExperimentalOtlpFileMetricExporterModel.java 8.00% 46 Missing ⚠️
...el/ExperimentalHttpClientInstrumentationModel.java 8.16% 45 Missing ⚠️
...el/ExperimentalHttpServerInstrumentationModel.java 8.16% 45 Missing ⚠️
... and 105 more

❌ Your patch check has failed because the patch coverage (42.40%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.
❌ Your project check has failed because the head coverage (82.24%) is below the target coverage (89.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8408      +/-   ##
============================================
- Coverage     90.88%   82.41%   -8.47%     
- Complexity     7985     8793     +808     
============================================
  Files           898     1013     +115     
  Lines         24107    29210    +5103     
  Branches       2406     3611    +1205     
============================================
+ Hits          21909    24073    +2164     
- Misses         1455     4117    +2662     
- Partials        743     1020     +277     

☔ View full report in Codecov by Sentry.
📢 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)))
Copy link
Copy Markdown
Member Author

@jack-berg jack-berg May 14, 2026

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.

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