opentelemetry-java icon indicating copy to clipboard operation
opentelemetry-java copied to clipboard

move declarative config ObjectMapper instance to internal class

Open zeitlinger opened this issue 2 months ago • 3 comments

Is your feature request related to a problem? Please describe.

Spring starter with declarative config needs to use the same settings for object mapper as https://github.com/open-telemetry/opentelemetry-java/blob/e6584623ccd2c626d66b357fd7c2c837a9c862bb/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/DeclarativeConfiguration.java#L66

See https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/14062#discussion_r2527602568

Describe the solution you'd like

Move the instance to an internal class where it can be read without reflection.

Describe alternatives you've considered

Read the instance using reflection.

zeitlinger avatar Nov 14 '25 15:11 zeitlinger

any other options? it would be nice not to introduce new reliance on internals where possible (#6970)

trask avatar Nov 14 '25 16:11 trask

any other options? it would be nice not to introduce new reliance on internals where possible (#6970)

This is what I can think of - there really is a strong reliance on the jackson settings after all:

  • copy-paste (what we have now)
  • reflection
  • internal class

zeitlinger avatar Nov 14 '25 16:11 zeitlinger

I personally prefer a bit of copy-paste over relying on internal APIs

trask avatar Nov 14 '25 17:11 trask