Skip to content

Conversation

@zeitlinger
Copy link
Member

@zeitlinger zeitlinger commented Nov 17, 2025

to bridge system properties / env vars to declarative config

Relates #14192

Alternative implementation for #14767

@zeitlinger zeitlinger self-assigned this Nov 17, 2025
@zeitlinger zeitlinger requested a review from a team as a code owner November 17, 2025 17:09
@github-actions github-actions bot added the test native This label can be applied to PRs to trigger them to run native tests label Nov 17, 2025
@zeitlinger
Copy link
Member Author

@trask I really like this new bridge based on your idea 😄

@zeitlinger zeitlinger moved this to Awaiting Review in Declarative Configuration: Java Nov 17, 2025
@zeitlinger zeitlinger changed the title Add system properties bridge Add system properties bridge, part 1 Nov 17, 2025
@zeitlinger zeitlinger force-pushed the system-properties-bridge branch from 3a9e285 to 9ae95f1 Compare November 18, 2025 09:54
@zeitlinger zeitlinger changed the title Add system properties bridge, part 1 Add system properties bridge Nov 18, 2025
Comment on lines 26 to 28
private static final boolean isIncubator = isIncubator();

private static boolean isIncubator() {
Copy link
Member

Choose a reason for hiding this comment

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

maybe supportsDeclarativeConfig? based on comment below it sounds like we'll still need this once it's out of incubation?

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea

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, when it's out of incubation, we'll have

  public static boolean isDeclarativeConfig(OpenTelemetry openTelemetry) {
    return openTelemetry instanceof ExtendedOpenTelemetry;
  }

or

  public static boolean isDeclarativeConfig(OpenTelemetry openTelemetry) {
    return openTelemetry.getConfigProvider() != null;
  }

instead of

  public static boolean isDeclarativeConfig(OpenTelemetry openTelemetry) {
    return isIncubator && openTelemetry instanceof ExtendedOpenTelemetry;
  }

depending on how things will evolve.

With the name change, it would be

public static boolean isDeclarativeConfig(OpenTelemetry openTelemetry) {
    return supportsDeclarativeConfig && openTelemetry instanceof ExtendedOpenTelemetry;
  }

which is similar in clarity to what we have now - so I'll go with your proposal

Comment on lines 58 to 59
public static boolean getBoolean(
OpenTelemetry openTelemetry, boolean defaultValue, String... propertyName) {
Copy link
Member

Choose a reason for hiding this comment

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

what about:

public static Optional getBoolean(OpenTelemetry, String...)

then used as:

getBoolean(...).orElse(...)

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 like it, but I want to keep things consistent - so I'll change it for all methods.

The class in internal, so it's allowed.

Comment on lines +34 to +39
// This only happens in OpenTelemetry API instrumentation tests, where an older version of
// OpenTelemetry API is used that does not have ExtendedOpenTelemetry.
// Having the incubator module without ExtendedOpenTelemetry class should still return false
// for those tests to avoid a ClassNotFoundException.
Copy link
Member

Choose a reason for hiding this comment

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

This only happens in OpenTelemetry API instrumentation tests

these are tests of OpenTelemetry API in the users class loader, so not following how that affects this class which is in the agent?

Copy link
Member Author

Choose a reason for hiding this comment

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

without the check, we get tests where the incubator exists, but is too old to have ExtendedOpenTelemetry:

gradle :instrumentation:opentelemetry-api:opentelemetry-api-1.42:javaagent:incubatorTest

	at io.opentelemetry.instrumentation.api.internal.ConfigPropertiesUtil.isDeclarativeConfig(ConfigPropertiesUtil.java:116)
	at io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder.buildSpanSuppressor(InstrumenterBuilder.java:374)
	at io.opentelemetry.instrumentation.api.instrumenter.Instrumenter.<init>(Instrumenter.java:105)
	at io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder.buildInstrumenter(InstrumenterBuilder.java:298)
	at io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder.buildInstrumenter(InstrumenterBuilder.java:287)
	at io.opentelemetry.instrumentation.testing.TestInstrumenters.<init>(TestInstrumenters.java:41)
	at io.opentelemetry.instrumentation.testing.InstrumentationTestRunner.<init>(InstrumentationTestRunner.java:68)
	at io.opentelemetry.instrumentation.testing.AgentTestRunner.<init>(AgentTestRunner.java:47)
	at io.opentelemetry.instrumentation.testing.AgentTestRunner.<clinit>(AgentTestRunner.java:40)
	at io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension.<init>(AgentInstrumentationExtension.java:35)
	at io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension.create(AgentInstrumentationExtension.java:39)
	at io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_42.incubator.logs.LoggerTest.<clinit>(LoggerTest.java:41)
	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160)
	at java.base/java.lang.reflect.Field.acquireOverrideFieldAccessor(Field.java:1200)
	at java.base/java.lang.reflect.Field.getOverrideFieldAccessor(Field.java:1169)
	at java.base/java.lang.reflect.Field.get(Field.java:444)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
	at java.base/java.util.stream.DistinctOps$1$2.end(DistinctOps.java:168)
	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:261)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.ClassNotFoundException: io.opentelemetry.api.incubator.ExtendedOpenTelemetry
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	... 29 more

Comment on lines 142 to 128
/** Returns true if the given OpenTelemetry instance supports Declarative Config. */
public static boolean isDeclarativeConfig(OpenTelemetry openTelemetry) {
return isIncubator && openTelemetry instanceof ExtendedOpenTelemetry;
}

Copy link
Member

Choose a reason for hiding this comment

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

is isIncubator needed, since instrumentation-api (unfortunately) already depends on the api-incubator?

Copy link
Member Author

Choose a reason for hiding this comment

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

only for the test (see last comment)

@zeitlinger zeitlinger force-pushed the system-properties-bridge branch from 0138d4f to 16e62ea Compare November 25, 2025 08:15
@zeitlinger
Copy link
Member Author

I have no idea what could have caused this failure:

11:31:59.660 [Test worker] INFO  t.g.i.19421579350 - Pulling docker image: ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-zulu-openjdk-8u31:20251117.19421579350. Please be patient; this may take some time but only needs to be done once.
11:32:00.526 [docker-java-stream--1576344563] INFO  t.g.i.19421579350 - Starting to pull image
11:32:00.527 [docker-java-stream--1576344563] INFO  t.g.i.19421579350 - Pulling image layers:  0 pending,  0 downloaded,  0 extracted, (0 bytes/0 bytes)
11:32:00.983 [docker-java-stream--1576344563] INFO  t.g.i.19421579350 - Pulling image layers:  1 pending,  1 downloaded,  0 extracted, (13 MB/? MB)
11:32:01.834 [docker-java-stream--1576344563] INFO  t.g.i.19421579350 - Pulling image layers:  1 pending,  1 downloaded,  1 extracted, (129 MB/? MB)
11:32:01.972 [docker-java-stream--1576344563] INFO  t.g.i.19421579350 - Pulling image layers:  0 pending,  2 downloaded,  1 extracted, (143 MB/148 MB)
11:32:03.747 [docker-java-stream--1576344563] INFO  t.g.i.19421579350 - Pulling image layers:  0 pending,  2 downloaded,  2 extracted, (148 MB/148 MB)
11:32:03.751 [Test worker] INFO  t.g.i.19421579350 - Image ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-zulu-openjdk-8u31:20251117.19421579350 pull took PT4.090551S
11:32:03.751 [docker-java-stream--1576344563] INFO  t.g.i.19421579350 - Pull complete. 2 layers, pulled in 3s (downloaded 148 MB at 49 MB/s)
11:32:03.753 [Test worker] INFO  t.g.i.19421579350 - Creating container for image: ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-zulu-openjdk-8u31:20251117.19421579350
11:32:04.376 [Test worker] INFO  t.g.i.19421579350 - Container ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-zulu-openjdk-8u31:20251117.19421579350 is starting: d09147ceccc4abd46f5c923ad2025cb51e2f7d27659e9b20370bf9c4d5e45420
11:32:04.459 [docker-java-stream-822006274] INFO  i.o.smoketest.CrashEarlyJdk8Test - STDOUT: started
11:32:04.467 [Test worker] INFO  t.g.i.19421579350 - Container ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-zulu-openjdk-8u31:20251117.19421579350 started in PT0.713852S
Container.ExecResult(exitCode=134, stdout=compiling
finish compiling
executing
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000076e60fe08, pid=31, tid=140468591523520
#
# JRE version: OpenJDK Runtime Environment (8.0_31-b13) (build 1.8.0_31-b13)
# Java VM: OpenJDK 64-Bit Server VM (25.31-b07 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  0x000000076e60fe08
#
# Core dump written. Default location: //core or core.31
#
# An error report file with more information is saved as:
# //hs_err_pid31.log
Compiled method (c1)     807 1777       3       java.util.stream.AbstractPipeline::wrapSink (37 bytes)
 total in heap  [0x00007fc150965350,0x00007fc150965a78] = 1832
 relocation     [0x00007fc150965478,0x00007fc1509654e0] = 104
 main code      [0x00007fc1509654e0,0x00007fc150965840] = 864
 stub code      [0x00007fc150965840,0x00007fc1509658f8] = 184
 metadata       [0x00007fc1509658f8,0x00007fc150965908] = 16
 scopes data    [0x00007fc150965908,0x00007fc1509659a8] = 160
 scopes pcs     [0x00007fc1509659a8,0x00007fc150965a58] = 176
 dependencies   [0x00007fc150965a58,0x00007fc150965a60] = 8
 nul chk table  [0x00007fc150965a60,0x00007fc150965a78] = 24
Compiled method (c1)     807 1782       3       java.util.stream.StreamSpliterators$WrappingSpliterator$$Lambda$254/1777443462::get$Lambda (9 bytes)
 total in heap  [0x00007fc15096f350,0x00007fc15096f7e8] = 1176
 relocation     [0x00007fc15096f478,0x00007fc15096f4b8] = 64
 main code      [0x00007fc15096f4c0,0x00007fc15096f680] = 448
 stub code      [0x00007fc15096f680,0x00007fc15096f710] = 144
 oops           [0x00007fc15096f710,0x00007fc15096f718] = 8
 metadata       [0x00007fc15096f718,0x00007fc15096f730] = 24
 scopes data    [0x00007fc15096f730,0x00007fc15096f780] = 80
 scopes pcs     [0x00007fc15096f780,0x00007fc15096f7e0] = 96
 dependencies   [0x00007fc15096f7e0,0x00007fc15096f7e8] = 8
#
# If you would like to submit a bug report, please visit:
#   http://www.azulsystems.com/support/
#
, stderr=[otel.javaagent 2025-11-25 11:32:05:162 +0000] [main] INFO io.opentelemetry.javaagent.tooling.VersionLogger - opentelemetry-javaagent - version: 2.23.0-SNAPSHOT
/test.sh: line 7:    31 Aborted                 (core dumped) java -javaagent:opentelemetry-javaagent.jar CrashEarlyJdk8
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test native This label can be applied to PRs to trigger them to run native tests

Projects

Status: Awaiting Review

Development

Successfully merging this pull request may close these issues.

2 participants