Skip to content

[OpAmp] Memory profiling support for remote config#2919

Open
robsunday wants to merge 25 commits into
signalfx:mainfrom
robsunday:opamp-memory-profiling
Open

[OpAmp] Memory profiling support for remote config#2919
robsunday wants to merge 25 commits into
signalfx:mainfrom
robsunday:opamp-memory-profiling

Conversation

@robsunday

Copy link
Copy Markdown
Contributor

PR includes:

  • Memory profiler can be enabled/disabled by remote config
  • JVM memory related metrics are enabled/disabled according to memory profiler settings
  • Redundant classes cleanup

@robsunday robsunday requested review from a team as code owners July 1, 2026 12:51
@laurit laurit requested a review from Copilot July 1, 2026 13:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds remote-configuration-driven control over profiling, including a new “reinitialize” path to apply updated profiler settings without requiring separate start/stop commands, and ties JVM memory-metrics installation to the memory-profiler enablement state. It also refactors periodic recording construction from a builder API into a factory and removes now-redundant JVM metrics installer wiring.

Changes:

  • Add requestReinitializeProfiling() and implement reinitialize logic in ProfilingSupervisor (stop if active, restart if enabled), including JVM memory-metrics install/uninstall based on config + property override.
  • Update OpAMP remote config processing to update profiler settings and trigger reinitialization only when effective profiler configuration changes; improve failure handling by reporting FAILED status without rethrowing.
  • Refactor periodic recording flusher creation into PeriodicRecordingFlusherFactory and make JVM memory metrics installers idempotent with explicit uninstall support (plus updated/added tests).

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
testing/jmh-benchmarks/src/main/java/com/splunk/opentelemetry/profiler/old/AgentInternalsFilter.java Update filtered JFR thread name from “Sequencer” to “Flusher”.
profiler/src/test/java/com/splunk/opentelemetry/profiler/ProfilingSupervisorTest.java Rework supervisor tests for factory-based flusher creation, reinitialize behavior, and JVM memory metrics toggling.
profiler/src/test/java/com/splunk/opentelemetry/profiler/ProfilerConfigurationTest.java Adjust tests to validate new equals/hashCode behavior.
profiler/src/test/java/com/splunk/opentelemetry/profiler/PeriodicRecordingFlusherFactoryTest.java Rename and adapt tests to factory create(...) API.
profiler/src/main/java/com/splunk/opentelemetry/profiler/StackTraceFilter.java Update filtered JFR thread name from “Sequencer” to “Flusher”.
profiler/src/main/java/com/splunk/opentelemetry/profiler/ProfilingSupervisor.java Add reinitialize command, integrate JVM memory metrics install/uninstall, and use PeriodicRecordingFlusherFactory.
profiler/src/main/java/com/splunk/opentelemetry/profiler/ProfilerConfiguration.java Introduce equals/hashCode to support change detection in remote config application logic.
profiler/src/main/java/com/splunk/opentelemetry/profiler/PeriodicRecordingFlusherFactory.java Replace builder with factory that constructs PeriodicRecordingFlusher instances.
profiler/src/main/java/com/splunk/opentelemetry/profiler/PeriodicRecordingFlusher.java Remove static builder entrypoint (now created via factory).
profiler/build.gradle.kts Add dependency on :instrumentation:jvm-metrics for new supervisor-managed metrics integration (compile/test).
opamp/src/test/java/com/splunk/opentelemetry/opamp/RemoteConfigProcessorTest.java Update expectations to use reinitialize and add failure + “update while running” coverage.
opamp/src/main/java/com/splunk/opentelemetry/opamp/RemoteConfigProcessor.java Apply profiler config updates conditionally and request reinitialize on change; report failures without rethrowing.
instrumentation/jvm-metrics/src/test/java/com/splunk/opentelemetry/instrumentation/jvmmetrics/otel/OtelGcMemoryMetricsTest.java Add tests for idempotent install/uninstall behavior.
instrumentation/jvm-metrics/src/test/java/com/splunk/opentelemetry/instrumentation/jvmmetrics/otel/OtelAllocatedMemoryMetricsTest.java Add tests for idempotent install/uninstall behavior.
instrumentation/jvm-metrics/src/test/java/com/splunk/opentelemetry/instrumentation/jvmmetrics/JvmMetricsInstallerTest.java Remove tests for deleted JvmMetricsInstaller.
instrumentation/jvm-metrics/src/main/java/com/splunk/opentelemetry/instrumentation/jvmmetrics/otel/OtelGcMemoryMetrics.java Make install idempotent and add uninstall/cleanup.
instrumentation/jvm-metrics/src/main/java/com/splunk/opentelemetry/instrumentation/jvmmetrics/otel/OtelAllocatedMemoryMetrics.java Make install idempotent and add uninstall/cleanup.
instrumentation/jvm-metrics/src/main/java/com/splunk/opentelemetry/instrumentation/jvmmetrics/JvmMetricsInstaller.java Remove agent listener installer (metrics now managed by profiler supervisor).
instrumentation/jvm-metrics/build.gradle.kts Remove unneeded dependencies after deleting JvmMetricsInstaller.
custom/src/main/java/com/splunk/opentelemetry/logging/SplunkSlf4jLoggingCustomizer.java Update log message example thread name to “JFR Recording Flusher”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mergify

mergify Bot commented Jul 2, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Comment thread agent/build.gradle.kts Outdated
val otelInstrumentationVersion: String = rootProject.extra["otelInstrumentationVersion"] as String
val javaagentInstrumentationProjects =
project(":instrumentation").subprojects.filter {
it.name !in setOf("compile-stub", "nocode-testing")

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.

what was wrong with using splunk.instrumentation-conventions as the marker?

@robsunday robsunday Jul 3, 2026

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.

There were two reasons:

  1. After profiler included :instrumentation:jmv-metrics there were errors from gradle: "Cannot mutate the dependencies of configuration ':agent:javaagentLibs' after the configuration was resolved"
  2. This marker caused including ":instrumentation:servlet-3-testing" module into production code.

I finally decided to explicitly list all relevant ":instrumentation" submodules.

Comment thread agent/build.gradle.kts

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.

The way of handling :instrumentation submodules was changed because after :profiler included :instrumentation:jmv-metrics there were errors from gradle:

"Cannot mutate the dependencies of configuration ':agent:javaagentLibs' after the configuration was resolved"

The splunk.instrumentation-conventions marker also caused including :instrumentation:servlet-3-testing module into production code.

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 wasn't able to reproduce the Cannot mutate the dependencies of configuration failure.

The splunk.instrumentation-conventions marker also caused including :instrumentation:servlet-3-testing module into production code.

This can be avoided by renaming splunk.instrumentation-conventions to splunk.instrumentation-testing-conventions and creating splunk.instrumentation-conventions that adds the splunk.instrumentation-testing-conventions plugin. Then the testing module should still function and not get included. Upstream uses a similar split.

@robsunday robsunday requested a review from laurit July 6, 2026 07:12
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.

3 participants