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

Enable using JMX Metrics instrumation as a library, not only through javaagent #12308

Open
adamw opened this issue Sep 20, 2024 · 6 comments
Open
Labels
enhancement New feature or request needs triage New issue that requires triage

Comments

@adamw
Copy link

adamw commented Sep 20, 2024

Is your feature request related to a problem? Please describe.

I'd like to use the Otel <-> JMX integration as a library, without the need to install a Java Agent, as described currently on: https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/jmx-metrics/javaagent/README.md

I don't think the javaagent code is published, I've been only able to find the library on Maven Central:

<dependency>
    <groupId>io.opentelemetry.instrumentation</groupId>
    <artifactId>opentelemetry-jmx-metrics</artifactId>
    <version>2.8.0-alpha</version>
    <scope>runtime</scope>
</dependency>

Describe the solution you'd like

My goal is to include all observability-related setup as code, in the main method of the application. I've got OTEL working without problems using AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk(), but to get the JMX integration I think I'll have to copy the initialisation code from JmxMetricInsightInstaller.java for now.

Ideally. I'd be able to do sth like JmxMetrics.initialise(openTelemetry), given an instance of OpenTelemetry.

Describe alternatives you've considered

No response

Additional context

No response

@adamw adamw added enhancement New feature or request needs triage New issue that requires triage labels Sep 20, 2024
@trask
Copy link
Member

trask commented Sep 23, 2024

hi @adamw!

<dependency>
    <groupId>io.opentelemetry.instrumentation</groupId>
    <artifactId>opentelemetry-jmx-metrics</artifactId>
    <version>2.8.0-alpha</version>
    <scope>runtime</scope>
</dependency>

I think this is what you want.

Ideally. I'd be able to do sth like JmxMetrics.initialise(openTelemetry), given an instance of OpenTelemetry.

check out

@adamw
Copy link
Author

adamw commented Sep 24, 2024

@trask Thanks, I do have that, and I'm calling JmxMetricInsight.createService. However, I had to copy the code which calls .start on the created instance with the proper configuration. The JmxMetricInsightInstaller.java does exactly that: reads configuration and calls JmxMetricInsight.createService. I suppose the configuration parsing/reading class could also be part of a published jar, so that it would be usable in a no-agent setup?

@adamw
Copy link
Author

adamw commented Sep 24, 2024

In my case, the proper way to solve my problem (exposing runtime JVM metrics) was to use a dedicated library: opentelemetry-runtime-telemetry-java8, instead of using the JMX metrics (see #12310).

However, I still think that having a way of using the JMX metrics bridge without the java agent would be beneficial, so I'm keeping this open.

@trask
Copy link
Member

trask commented Sep 24, 2024

@trask Thanks, I do have that, and I'm calling JmxMetricInsight.createService. However, I had to copy the code which calls .start on the created instance with the proper configuration. The JmxMetricInsightInstaller.java does exactly that: reads configuration and calls JmxMetricInsight.createService. I suppose the configuration parsing/reading class could also be part of a published jar, so that it would be usable in a no-agent setup?

cc @PeterF778

@PeterF778
Copy link
Contributor

PeterF778 commented Sep 25, 2024

If I remember correctly, JMX Metric Insight uses two different calls for building the configuration (parser) and for starting the collection to make sure that no attempts to report metrics happen before the agent is fully initialized (metric exporter, etc.). I'll have another look to see if this can be made more user friendly.

@PeterF778
Copy link
Contributor

I revisited the code. The opentelemetry-jmx-metrics.jar contains both the yaml parser and instrumentation. However, the default configuration files for supported platforms, as well as the controlling properties otel.jmx.target.system, otel.jmx.config (and others), are Java Agent specific. Hence, JmxMetricInsightInstaller uses two steps: it creates a MetricConfiguration and creates a service instance, passing the configuration as well.
It is easy to introduce a new entry createAndStartService(OpenTelemetry otel, MetricConfiguration conf), but I do not think it will make a big difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage New issue that requires triage
Projects
None yet
Development

No branches or pull requests

3 participants