Skip to content
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

check if the agentArgs are null during bootstrap #918

Closed
wants to merge 1 commit into from

Conversation

sergekh42
Copy link

Fixes #

PR #910 broke the ability to use the standard Java agnet OPTS:
JAVA_OPTS="-javaagent:grafana-opentelemetry-java.jar"

it requires us now to use:
JAVA_OPTS="-javaagent:grafana-opentelemetry-java.jar="

Notice the equal symbol at the end. The agentArgs are null if the equal symbol is not entered. Causing the isEmpty check to fail.

Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source)
Caused by: java.lang.NullPointerException: Cannot invoke "String.isEmpty()" because "agentArgs" is null
	at com.grafana.AgentStarted.run(AgentStarted.java:12)
	at com.grafana.GrafanaOpenTelemetryAgent.startAgent(GrafanaOpenTelemetryAgent.java:53)
	at com.grafana.GrafanaOpenTelemetryAgent.premain(GrafanaOpenTelemetryAgent.java:45)
	... 4 more
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed

Changes

Check if agentArgs is not null AND the string is not empty.

Merge requirement checklist

  • Unit tests added/updated
  • CHANGELOG.md file updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

PR grafana#910 broke the ability to use this:
JAVA_OPTS="-javaagent:grafana-opentelemetry-java.jar"

it requires us now to use:
JAVA_OPTS="-javaagent:grafana-opentelemetry-java.jar="

Notice the equal symbol at the end. The agentArgs are null if the equal symbol is not entered. Causing the isEmpty check to fail.
@sergekh42 sergekh42 requested a review from zeitlinger as a code owner March 3, 2025 20:21
@CLAassistant
Copy link

CLAassistant commented Mar 3, 2025

CLA assistant check
All committers have signed the CLA.

@sergekh42
Copy link
Author

We use Grafana at our org. Requiring us to go to each app to update the JAVA_OPTS to have an equal symbol at the end is a real pain. We use environment variables to configure our agents, not agent arguments. Please consider making this change.

@sergekh42
Copy link
Author

Closing, just saw there is already a PR open - #917

@sergekh42 sergekh42 closed this Mar 3, 2025
@sergekh42 sergekh42 deleted the patch-1 branch March 3, 2025 20:26
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.

2 participants