Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…8783)

* Make Tracer injectable



* Add changelog entry



* Remove entry from CHANGELOG.md



---------


(cherry picked from commit 83a4b6e)

Signed-off-by: suranjay <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 0ea7210 commit d83147f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions server/src/main/java/org/opensearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.opensearch.plugins.ExtensionAwarePlugin;
import org.opensearch.plugins.SearchPipelinePlugin;
import org.opensearch.telemetry.tracing.NoopTracerFactory;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.telemetry.tracing.TracerFactory;
import org.opensearch.search.backpressure.SearchBackpressureService;
import org.opensearch.search.backpressure.settings.SearchBackpressureSettings;
Expand Down Expand Up @@ -380,7 +381,7 @@ public static class DiscoverySettings {
private final Collection<LifecycleComponent> pluginLifecycleComponents;
private final LocalNodeFactory localNodeFactory;
private final NodeService nodeService;
private final TracerFactory tracerFactory;
private final Tracer tracer;
final NamedWriteableRegistry namedWriteableRegistry;
private final AtomicReference<RunnableTaskExecutionListener> runnableTaskListener;
private FileCache fileCache;
Expand Down Expand Up @@ -1029,6 +1030,7 @@ protected Node(
searchModule.getIndexSearcherExecutor(threadPool)
);

TracerFactory tracerFactory;
if (FeatureFlags.isEnabled(TELEMETRY)) {
final TelemetrySettings telemetrySettings = new TelemetrySettings(settings, clusterService.getClusterSettings());
List<TelemetryPlugin> telemetryPlugins = pluginsService.filterPlugins(TelemetryPlugin.class);
Expand All @@ -1037,7 +1039,8 @@ protected Node(
} else {
tracerFactory = new NoopTracerFactory();
}
resourcesToClose.add(tracerFactory::close);
tracer = tracerFactory.getTracer();
resourcesToClose.add(tracer::close);

final List<PersistentTasksExecutor<?>> tasksExecutors = pluginsService.filterPlugins(PersistentTaskPlugin.class)
.stream()
Expand Down Expand Up @@ -1144,7 +1147,7 @@ protected Node(
b.bind(FsHealthService.class).toInstance(fsHealthService);
b.bind(SystemIndices.class).toInstance(systemIndices);
b.bind(IdentityService.class).toInstance(identityService);
b.bind(TracerFactory.class).toInstance(this.tracerFactory);
b.bind(Tracer.class).toInstance(tracer);
});
injector = modules.createInjector();

Expand Down Expand Up @@ -1501,7 +1504,7 @@ public synchronized void close() throws IOException {
toClose.add(injector.getInstance(NodeEnvironment.class));
toClose.add(stopWatch::stop);
if (FeatureFlags.isEnabled(TELEMETRY)) {
toClose.add(injector.getInstance(TracerFactory.class));
toClose.add(injector.getInstance(Tracer.class));
}

if (logger.isTraceEnabled()) {
Expand Down

0 comments on commit d83147f

Please sign in to comment.