8000 make declarative config bridge usable by spring starter and contrib by zeitlinger · Pull Request #14497 · open-telemetry/opentelemetry-java-instrumentation · GitHub
[go: up one dir, main page]

Skip to content

Conversation

zeitlinger
Copy link
Member

No description provided.

@zeitlinger zeitlinger self-assigned this Aug 22, 2025
@zeitlinger zeitlinger requested a review from a team as a code owner August 22, 2025 07:10
@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from generateLicenseReport was committed to the PR branch.

@otelbot-java-instrumentation
Copy link
Contributor

❌ The result from spotlessApply could not be committed to the PR branch, see logs: https://github.com/open-telemetry/opentelemetry-java-instrumentation/actions/runs/17149887945.

@zeitlinger
Copy link
Member Author
zeitlinger commented Aug 22, 2025

got

OpenTelemetry Javaagent failed to start	
java.lang.NoClassDefFoundError: io/opentelemetry/sdk/autoconfigure/spi/ConfigProperties	
	at io.opentelemetry.javaagent.shaded.instrumentation.api.incubator.config.bridge.DeclarativeConfigPropertiesBridgeBuilder.build(DeclarativeConfigPropertiesBridgeBuilder.java:89)	
	at io.opentelemetry.javaagent.shaded.instrumentation.api.incubator.config.bridge.DeclarativeConfigPropertiesBridgeBuilder.buildFromInstrumentationConfig(DeclarativeConfigPropertiesBridgeBuilder.java:105)	
	at io.opentelemetry.javaagent.tooling.OpenTelemetryInstaller.installOpenTelemetrySdk(OpenTelemetryInstaller.java:56)	
	at io.opentelemetry.javaagent.tooling.AgentInstaller.installBytebuddyAgent(AgentInstaller.java:165)	
	at io.opentelemetry.javaagent.tooling.AgentInstaller.installBytebuddyAgent(AgentInstaller.java:112)	
	at io.opentelemetry.javaagent.tooling.AgentStarterImpl.start(AgentStarterImpl.java:104)	
	at io.opentelemetry.javaagent.bootstrap.AgentInitializer$2.run(AgentInitializer.java:66)	
	at io.opentelemetry.javaagent.bootstrap.AgentInitializer$2.run(AgentInitializer.java:60)	
	at io.opentelemetry.javaagent.bootstrap.AgentInitializer.execute(AgentInitializer.java:82)	
	at io.opentelemetry.javaagent.bootstrap.AgentInitializer.initialize(AgentInitializer.java:59)	
	at io.opentelemetry.javaagent.OpenTelemetryAgent.startAgent(OpenTelemetryAgent.java:59)

the agent jar has this - so I don't understand why the class won't load

  • inst/io/opentelemetry/sdk/autoconfigure/spi/ConfigProperties.classdata
  • io/opentelemetry/javaagent/shaded/instrumentation/api/incubator/config/bridge/DeclarativeConfigPropertiesBridgeBuilder.class

I think I'd have to remove the bridle from bootstrap here - but that only works for entire modules

  bootstrapLibs(project(":instrumentation-api-incubator")) {
    exclude("io.opentelemetry", "opentelemetry-sdk-extension-autoconfigure-spi")
  }

@laurit do you have an idea?

@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@zeitlinger
Copy link
Member Author

It worked!

@laurit can you check if this makes sense?

@zeitlinger
Copy link
Member Author

@trask here's the bridge moved to the agent repo

Comment on lines +50 to +51
The auto configuration **with declarative config** uses the Declarative Config Bridge to be able to
use common configuration method:
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be worth adding for extra clarity that this allows to use declarative/yaml configuration in addition to the java properties and environment variables, in short we have to change how configuration is consumed to support both, not how it's being set.

Copy link
Member Author

Choose a reason for hiding this comment

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

no, if you use declarative config you can't use env vars any more

Copy link
Contributor

Choose a reason for hiding this comment

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

Do the java properties still work ? Also, do we still have a way to handle compatibility with existing dotted syntax even when configuration options do not strictly fit yaml structure ? (disclamer: I have little knowledge about declarative configuration, maybe this is documented somewhere).

Copy link
Member Author
@zeitlinger zeitlinger Aug 26, 2025

Choose a reason for hiding this comment

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

Do the java properties still work ?

Not by default - but you can add that capability back.
The migration schema provides the same capabilities as before, e.g. value: ${OTEL_SERVICE_NAME:-unknown_service} adds support for the env var and sys property for the service name

Also, do we still have a way to handle compatibility with existing dotted syntax even when configuration options do not strictly fit yaml structure ?

  • this PR allows existing instrumentations to read simple values or lists from either yaml or sys props
  • if a new instrumentation needs to access data that only fits in yaml, then it can't use the bridge - e.g. here
    InstrumentationConfig config = AgentInstrumentationConfig.get();
    List<TypeInstrumentation> list =
        config.isDeclarative()
            ? MethodsConfig.parseDeclarativeConfig(config.getDeclarativeConfig("methods")) <-- this has access to yaml tree
            : parseConfigProperties();

(disclamer: I have little knowledge about declarative configuration, maybe this is documented somewhere).

no worries - the user facing documentation is not there yet

Copy link
Contributor

Choose a reason for hiding this comment

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

The only thing that I worry (at least for now) is having the capability to preserve the current support for environment variables and JVM system properties in a distribution (also includes some elements from contrib), so any documentation how to achieve this would be welcome. If users decide to use declarative configuration, then it's a breaking change and we don't have such requirement (and they should be able to use system properties and env variables in yaml if needed).

Copy link
Member Author

Choose a reason for hiding this comment

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

we're not changing anything for user that are not using declarative config

exclude("io/opentelemetry/instrumentation/api/incubator/config/**")
exclude("io/opentelemetry/instrumentation/api/incubator/instrumenter/**")
exclude("io/opentelemetry/instrumentation/api/incubator/log/**")
exclude("io/opentelemetry/instrumentation/api/incubator/semconv/**")
Copy link
Member

Choose a reason for hiding this comment

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

if a new package was added and we forgot to add an exclusion for it here, would something fail in a way we'd know to add it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe this would fail

"Failed to load bootstrap class: " + info.getName() + " in " + bootstrapPrefix, e);

It failed for me until I changed this at least.

57A6 Copy link
Member

Choose a reason for hiding this comment

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

cool, i was wondering how that change was related

@trask trask merged commit 136efcb into open-telemetry:main Aug 28, 2025
89 checks passed
@zeitlinger zeitlinger deleted the declarative-config-bridge branch August 28, 2025 15:54
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.

4 participants
0