Skip to content

Commit

Permalink
Merge pull request #244 from solarwinds/cc/NH-86006
Browse files Browse the repository at this point in the history
NH-86006: enable profiling for benchmark
  • Loading branch information
cleverchuk authored Jul 11, 2024
2 parents b84c495 + 7abeeef commit 4291f56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@

import com.solarwinds.joboe.config.ConfigManager;
import com.solarwinds.joboe.config.ConfigProperty;
import com.solarwinds.joboe.core.ReporterFactory;
import com.solarwinds.joboe.core.profiler.Profiler;
import com.solarwinds.joboe.core.profiler.ProfilerSetting;
import com.solarwinds.joboe.core.rpc.ClientException;
import com.solarwinds.joboe.core.rpc.RpcClientManager;
import com.solarwinds.joboe.logging.Logger;
import com.solarwinds.joboe.logging.LoggerFactory;
import com.solarwinds.joboe.sampling.Metadata;
import com.solarwinds.joboe.shaded.javax.annotation.Nonnull;
import com.solarwinds.opentelemetry.core.Util;
Expand All @@ -39,29 +34,11 @@

/** Span process to perform code profiling */
public class SolarwindsProfilingSpanProcessor implements SpanProcessor {
private static final Logger logger = LoggerFactory.getLogger();
private static final ProfilerSetting profilerSetting =
(ProfilerSetting) ConfigManager.getConfig(ConfigProperty.PROFILER);
private static final boolean PROFILER_ENABLED =
profilerSetting != null && profilerSetting.isEnabled();

static {
if (PROFILER_ENABLED) {
try {
Profiler.initialize(
profilerSetting,
ReporterFactory.getInstance()
.createQueuingEventReporter(
RpcClientManager.getClient(RpcClientManager.OperationType.PROFILING)));
} catch (ClientException e) {
logger.error("Error creating profiling report", e);
throw new RuntimeException(e);
}
} else {
logger.info("Profiler is disabled.");
}
}

@Override
public void onStart(@Nonnull Context parentContext, ReadWriteSpan span) {
if (span.getSpanContext().isSampled()) { // only profile on sampled spans
Expand Down
4 changes: 4 additions & 0 deletions long-running-test-arch/k8s/deployment-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ spec:
value: "petclinic"
- name: spring_datasource_password
value: "petclinic"
- name: SW_APM_PROFILER_ENABLED
value: "true"

---
apiVersion: apps/v1
Expand Down Expand Up @@ -124,6 +126,8 @@ spec:
value: "petclinic"
- name: spring_datasource_password
value: "petclinic"
- name: SW_APM_PROFILER_ENABLED
value: "true"

---
apiVersion: apps/v1
Expand Down

0 comments on commit 4291f56

Please sign in to comment.