-
Notifications
You must be signed in to change notification settings - Fork 1k
Add system properties bridge #15339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add system properties bridge #15339
Conversation
|
@trask I really like this new bridge based on your idea 😄 |
3a9e285 to
9ae95f1
Compare
| private static final boolean isIncubator = isIncubator(); | ||
|
|
||
| private static boolean isIncubator() { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
There was a problem hiding this comment.
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
| public static boolean getBoolean( | ||
| OpenTelemetry openTelemetry, boolean defaultValue, String... propertyName) { |
There was a problem hiding this comment.
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(...)
There was a problem hiding this comment.
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.
| // 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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
| /** Returns true if the given OpenTelemetry instance supports Declarative Config. */ | ||
| public static boolean isDeclarativeConfig(OpenTelemetry openTelemetry) { | ||
| return isIncubator && openTelemetry instanceof ExtendedOpenTelemetry; | ||
| } | ||
|
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
0138d4f to
16e62ea
Compare
to bridge system properties / env vars to declarative config
Relates #14192
Alternative implementation for #14767