Skip to content

Conversation

@zeitlinger
Copy link
Member

@zeitlinger zeitlinger commented Nov 17, 2025

to bridge system properties / env vars to declarative config

Fixes #14192

Alternative implementation for #14767

Breaking Changes:

  • otel.experimental.javascript-snippet becomes otel.instrumentation.servlet.experimental.javascript-snippet

@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 142 to 151
/** 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
)

@laurit
Copy link
Contributor

laurit commented Nov 25, 2025

I have no idea what could have caused this failure:

CrashEarlyJdk8 fails when you use lambdas too early in the agent initalization.

@zeitlinger
Copy link
Member Author

I have no idea what could have caused this failure:

CrashEarlyJdk8 fails when you use lambdas too early in the agent initalization.

thank you!

@zeitlinger
Copy link
Member Author

@trask please check again

@zeitlinger
Copy link
Member Author

@trask I've split the PR - please have another look

.orElse(false))
.setMessagingReceiveInstrumentationEnabled(
ConfigPropertiesUtil.getBoolean(
openTelemetry, "messaging", "experimental", "receive_telemetry", "enabled")
Copy link
Member

Choose a reason for hiding this comment

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

and here

"messaging", "receive_telemetry/development", "enabled"

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I think so.

We'd also need to add this translation to the declarative config bridge - but we can first add it here

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 have these cases - and both are currently used about equally as much:

  • experimental-foo -> foo/development
  • experimental.foo -> foo/development

We can't translate back from foo/development - unless we try multiple properties - and that gets harder to troubleshoot.

(this is why the tests are failing)

Copy link
Member Author

Choose a reason for hiding this comment

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

just realized that we can just map all system properties with "otel." prefix to the corresponding declarative config value - and thus avoid the problem.

I think this is similar to what you suggested @trask

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

found a solution now

@zeitlinger zeitlinger force-pushed the system-properties-bridge branch from 55146b8 to deddaa1 Compare December 3, 2025 10:59
@zeitlinger zeitlinger force-pushed the system-properties-bridge branch from 2df0753 to 6c889a7 Compare December 4, 2025 16:54
…tal-foo" and "experimental.foo" that both translate to "foo/development"
…tal-foo" and "experimental.foo" that both translate to "foo/development"
…tal-foo" and "experimental.foo" that both translate to "foo/development"
@zeitlinger
Copy link
Member Author

@trask please check again

@zeitlinger zeitlinger added this to the v2.23.0 milestone Dec 5, 2025
Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

nice

}

protected abstract boolean getBoolean(String name, boolean defaultValue);
protected abstract boolean getBoolean(boolean defaultValue, String... name);
Copy link
Member

Choose a reason for hiding this comment

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

do we need this abstract method now that (I think) we have unified access between agent and library instrumentation?

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 have almost - but you can only use property customizers (for system properties) in the agent.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not following why that's a problem, IIUC that happens at startup, then declarative config is backed by the result?

Copy link
Member Author

Choose a reason for hiding this comment

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

This issue exists when NOT using declarative config:

  • Agent: You can set the property using a customizer, e.g. via default properties
  • Library: property is directly read from system properties or environment variables

String result = ConfigPropertiesUtil.getString("otel.experimental.javascript-snippet");
return result == null ? "" : result;
return ConfigPropertiesUtil.getString(
GlobalOpenTelemetry.get(), "servlet", "javascript-snippet/development")
Copy link
Member

Choose a reason for hiding this comment

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

can you add breaking label and add this to the CHANGELOG so I don't forget?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do

Comment on lines +374 to +379
ConfigPropertiesUtil.isDeclarativeConfig(openTelemetry)
? ConfigPropertiesUtil.getString(
openTelemetry, "common", "span_suppression_strategy/development")
.orElse(null)
: ConfigPropertiesUtil.getString(
"otel.instrumentation.experimental.span-suppression-strategy");
Copy link
Member

Choose a reason for hiding this comment

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

can this be unified now?

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 can if we accept another breaking change (the common part)

Copy link
Member

Choose a reason for hiding this comment

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

ah, I missed that, this one may be more used, can you open an issue to change it in next major version bump (3.0)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do

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.

use InstrumentationConfig where possible

3 participants