Skip to content

[File based config] Implement profiler configuration customizer to support JFR#2519

Merged
robsunday merged 19 commits intosignalfx:mainfrom
robsunday:fbc-profiler
Nov 14, 2025
Merged

[File based config] Implement profiler configuration customizer to support JFR#2519
robsunday merged 19 commits intosignalfx:mainfrom
robsunday:fbc-profiler

Conversation

@robsunday
Copy link
Copy Markdown
Contributor

Customizer is required here.

private static final JFR instance = new JFR();
private static final boolean jfrAvailable = checkJfr();

public static JFR getInstance() {
Copy link
Copy Markdown
Contributor Author

@robsunday robsunday Nov 7, 2025

Choose a reason for hiding this comment

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

[for reviewer] Refactored to make it more OO and mockable.

@robsunday robsunday marked this pull request as ready for review November 7, 2025 14:07
@robsunday robsunday requested review from a team as code owners November 7, 2025 14:07
Comment on lines +39 to +40
if (isProfilerEnabled(model)) {
if (jfrIsAvailable()) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could merge these

}

@VisibleForTesting
OpenTelemetryConfigurationModel customizeModel(OpenTelemetryConfigurationModel model) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do you need to use DeclarativeConfigurationCustomizer for this at all? You aren't changing the configuration model but just reading it. Couldn't you just use something like AgentInstrumentationConfig.get().getBoolean(SplunkConfiguration.PROFILER_ENABLED_PROPERTY) to get the value for both declarative config and system properties based config (at least in upstream instrumentation conf can be read like that)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So this is a port of SdkCustomizer that runs when env var based configuration is in use. I had to implement similar solution for declarative configuration.
I agree I don't modify the configuration here, but SdkCustomizer does not do it either.
Some time ago I asked on Java SIG where I could implement some validations and I was advised to do it in DeclarativeConfigurationCustomizer. That's why I assumed it is OK to utilize it here as well.

There is a call to ContextStorage.addWrapper in line 41. Where, in your opinion, I could safely make this call if I do not use DeclarativeConfigurationCustomizer, so the wrapper is attached early enough?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess the SdkCustomizer is written they way it is to get access to config properties. I think you could consider deleting it and using a AgentListener or BeforeAgentListener. There you can get access to config properties using https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/runtime-telemetry/runtime-telemetry-java8/javaagent/src/main/java/io/opentelemetry/instrumentation/javaagent/runtimemetrics/java8/JarAnalyzerInstaller.java or you could use AgentInstrumentationConfig like in https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/runtime-telemetry/runtime-telemetry-java8/javaagent/src/main/java/io/opentelemetry/instrumentation/javaagent/runtimemetrics/java8/Java8RuntimeMetricsInstaller.java I don't know about config properties but AgentInstrumentationConfig should be able to handle both the declarative and sysprop based configuration.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Getting rid of customizers (for both: declarative config and env var config) worked. It was enough to call ContextStorage.addWrapper from JfrActivator.
Nice suggestion!

import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfigurationModel;
import java.util.Map;

public class ProfilerDeclarativeConfigUtil {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is this class used anywhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not any longer, removed

@robsunday robsunday requested a review from laurit November 14, 2025 06:30
@robsunday robsunday merged commit 4586f85 into signalfx:main Nov 14, 2025
28 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants