Skip to content

Commit

Permalink
test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gagan Juneja committed May 16, 2024
1 parent 1fe3245 commit 136e419
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.opensearch.core.indices.breaker.CircuitBreakerService;
import org.opensearch.env.Environment;
import org.opensearch.indices.IndicesService;
import org.opensearch.telemetry.service.TelemetryService;
import org.opensearch.telemetry.metrics.MetricsRegistry;
import org.opensearch.threadpool.ThreadPool;

public final class OpenSearchResources {
Expand All @@ -26,7 +26,7 @@ public final class OpenSearchResources {
private java.nio.file.Path configPath;
private String pluginFileLocation;
private Client client;
private TelemetryService telemetryService;
private MetricsRegistry metricsRegistry;

private OpenSearchResources() {
threadPool = null;
Expand Down Expand Up @@ -111,11 +111,11 @@ public Client getClient() {
return client;
}

public TelemetryService getTelemetryService() {
return telemetryService;
public MetricsRegistry getMetricsRegistry() {
return metricsRegistry;
}

public void setTelemetryService(TelemetryService telemetryService) {
this.telemetryService = telemetryService;
public void setMetricsRegistry(MetricsRegistry metricsRegistry) {
this.metricsRegistry = metricsRegistry;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,19 @@
import org.opensearch.plugins.NetworkPlugin;
import org.opensearch.plugins.Plugin;
import org.opensearch.plugins.SearchPlugin;
import org.opensearch.plugins.TelemetryAwarePlugin;
import org.opensearch.repositories.RepositoriesService;
import org.opensearch.rest.RestController;
import org.opensearch.script.ScriptService;
import org.opensearch.telemetry.service.TelemetryService;
import org.opensearch.telemetry.metrics.MetricsRegistry;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.Transport;
import org.opensearch.transport.TransportInterceptor;
import org.opensearch.watcher.ResourceWatcherService;

public final class PerformanceAnalyzerPlugin extends Plugin
implements ActionPlugin, NetworkPlugin, SearchPlugin {
implements ActionPlugin, NetworkPlugin, SearchPlugin, TelemetryAwarePlugin {
private static final Logger LOG = LogManager.getLogger(PerformanceAnalyzerPlugin.class);
public static final String PLUGIN_NAME = "opensearch-performance-analyzer";
private static final String ADD_FAULT_DETECTION_METHOD = "addFaultDetectionListener";
Expand Down Expand Up @@ -384,7 +385,21 @@ public List<Setting<?>> getSettings() {
}

@Override
public void setTelemetryService(TelemetryService telemetryService) {
OpenSearchResources.INSTANCE.setTelemetryService(telemetryService);
public Collection<Object> createComponents(
Client client,
ClusterService clusterService,
ThreadPool threadPool,
ResourceWatcherService resourceWatcherService,
ScriptService scriptService,
NamedXContentRegistry xContentRegistry,
Environment environment,
NodeEnvironment nodeEnvironment,
NamedWriteableRegistry namedWriteableRegistry,
IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<RepositoriesService> repositoriesServiceSupplier,
Tracer tracer,
MetricsRegistry metricsRegistry) {
OpenSearchResources.INSTANCE.setMetricsRegistry(metricsRegistry);
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ public class PerformanceAnalyzerSearchListener

public PerformanceAnalyzerSearchListener(final PerformanceAnalyzerController controller) {
this.controller = controller;
if (OpenSearchResources.INSTANCE.getTelemetryService() != null
&& OpenSearchResources.INSTANCE.getTelemetryService().getMetricsRegistry()
!= null) {
this.metricsRegistry =
OpenSearchResources.INSTANCE.getTelemetryService().getMetricsRegistry();
if (OpenSearchResources.INSTANCE.getMetricsRegistry() != null) {
this.metricsRegistry = OpenSearchResources.INSTANCE.getMetricsRegistry();
searchCPUUtilizationCounter =
metricsRegistry.createCounter(
"pa.core.search.cpuUtilization", "test counter", "1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public class PerformanceAnalyzerTransportRequestHandler<T extends TransportReque
TransportRequestHandler<T> actualHandler, PerformanceAnalyzerController controller) {
this.actualHandler = actualHandler;
this.controller = controller;
this.metricsRegistry =
OpenSearchResources.INSTANCE.getTelemetryService().getMetricsRegistry();
this.metricsRegistry = OpenSearchResources.INSTANCE.getMetricsRegistry();
this.cpuUtilizationCounter =
metricsRegistry.createCounter(
"pa.core.cpuUtilizationCounter", "cpuUtilizationCounter", "time");
Expand Down

0 comments on commit 136e419

Please sign in to comment.