Skip to content

[File based config] Initial configuration refactoring for profiler#2505

Merged
robsunday merged 11 commits intosignalfx:mainfrom
robsunday:fbc-profiler
Nov 3, 2025
Merged

[File based config] Initial configuration refactoring for profiler#2505
robsunday merged 11 commits intosignalfx:mainfrom
robsunday:fbc-profiler

Conversation

@robsunday
Copy link
Copy Markdown
Contributor

@robsunday robsunday commented Oct 29, 2025

Initial PR for profiler support with declarative config.
It is a cleanup and refactoring of profiler Configuration class. This refactoring makes Configuration class reusable between env var config and declarative config approach.

There were some inconsistencies how code retrieved values from the config. In most places the code called utility methods form Configuration class, but in some places it called directly ConfigProperties::getXXX() instead (see JfrActivator, JfrSettingsOverride). Now the code consistently use Configuration class methods.

@Override
public void customize(AutoConfigurationCustomizer autoConfiguration) {
autoConfiguration.addPropertiesSupplier(this::defaultProperties);
public static void log(ConfigProperties config) {
Copy link
Copy Markdown
Contributor Author

@robsunday robsunday Oct 29, 2025

Choose a reason for hiding this comment

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

[for reviewer] This method was moved from ConfigurationLogger class to follow an approach present in SnapshotProfilingConfiguration class.
It mostly logs what utility methods of Configuration class return, not the real property values from ConfigProperties.
This makes more sense, I think, because in the logs you can see what the code is actually using. This is also consistent with the implementation of SnapshotProfilingConfiguration class.


private boolean notClearForTakeoff(ConfigProperties config) {
if (!config.getBoolean(CONFIG_KEY_ENABLE_PROFILER, false)) {
if (!SplunkConfiguration.isProfilerEnabled(config)) {
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.

[for reviewer] Use utility method of Configuration instead of direct accessing the property from ConfigProperties.

logger.info("-----------------------");
}

Map<String, String> defaultProperties() {
Copy link
Copy Markdown
Contributor Author

@robsunday robsunday Oct 29, 2025

Choose a reason for hiding this comment

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

[for reviewer] There is no point of setting these defaults as every utility method from this class declares default value when reading property value from ConfigProperties

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The point is that you have one place to go where you can see all the defaults... but it's fine to remove.

}

private Duration getCustomInterval() {
Duration customInterval = config.getDuration(CONFIG_KEY_CALL_STACK_INTERVAL, Duration.ZERO);
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.

[for reviewer] Default here did not make any sense because Configuration.defaultProperties() did set another default for it: Duration.ofSeconds(10).
Default Duration.ofSeconds(10) is also returned from Configuration::getCallStackInterval

private static final Logger logger = Logger.getLogger(Configuration.class.getName());
private static final boolean HAS_OBJECT_ALLOCATION_SAMPLE_EVENT = getJavaVersion() >= 16;

private static final String DEFAULT_RECORDING_DURATION = "20s";
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.

[for reviewer] This value is changed to avoid confusion due to discrepancy between env var config and declarative config data types accepted for duration properties.

Env var config supports nonstandard format with numeric value specified together with a time unit.
This is incompatible with the declarative config where specification clearly states that duration must be provided as an integer number.

@robsunday robsunday marked this pull request as ready for review October 30, 2025 10:17
@robsunday robsunday requested review from a team as code owners October 30, 2025 10:17
Copy link
Copy Markdown
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

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

A few small comments, but totally fine to merge. Thanks!

logger.info("-----------------------");
}

Map<String, String> defaultProperties() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The point is that you have one place to go where you can see all the defaults... but it's fine to remove.

Comment on lines -38 to -43
public static final boolean DEFAULT_MEMORY_ENABLED = false;
public static final Duration DEFAULT_CALL_STACK_INTERVAL = Duration.ofSeconds(10);
public static final boolean DEFAULT_INCLUDE_INTERNAL_STACKS = false;
public static final boolean DEFAULT_TRACING_STACKS_ONLY = false;
private static final int DEFAULT_STACK_DEPTH = 1024;
private static final boolean DEFAULT_MEMORY_EVENT_RATE_LIMIT_ENABLED = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When someone asks what the default value behavior is for foo, you're going to have to go hunting now. I think this makes it way less findable, but whatever.

Copy link
Copy Markdown
Contributor Author

@robsunday robsunday Nov 3, 2025

Choose a reason for hiding this comment

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

I think there is no perfect solution here. Both approaches have pros and cons. I decided to refactor it because it made the class smaller and simplified analyzing of methods' behavior. You see immediately what is the default value if you look at method's code. I left only definitions of defaults that require some additional processing / heap allocation

@robsunday robsunday merged commit 2de28e8 into signalfx:main Nov 3, 2025
28 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 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.

3 participants