Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Tracer injectable #8696

Merged
merged 5 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Migrate client transports to Apache HttpClient / Core 5.x ([#4459](https://github.com/opensearch-project/OpenSearch/pull/4459))
- Change http code on create index API with bad input raising NotXContentException from 500 to 400 ([#4773](https://github.com/opensearch-project/OpenSearch/pull/4773))
- Improve summary error message for invalid setting updates ([#4792](https://github.com/opensearch-project/OpenSearch/pull/4792))
- Make Tracer injectable
suranjay marked this conversation as resolved.
Show resolved Hide resolved

### Deprecated

Expand Down
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 @@ -57,6 +57,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 @@ -379,7 +380,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