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

Remove unused TracingPlugin interface #80799

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 2 additions & 4 deletions server/src/main/java/org/elasticsearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@
import org.elasticsearch.plugins.SearchPlugin;
import org.elasticsearch.plugins.ShutdownAwarePlugin;
import org.elasticsearch.plugins.SystemIndexPlugin;
import org.elasticsearch.plugins.TracingPlugin;
import org.elasticsearch.repositories.RepositoriesModule;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.rest.RestController;
Expand All @@ -169,6 +168,7 @@
import org.elasticsearch.tasks.TaskCancellationService;
import org.elasticsearch.tasks.TaskResultsService;
import org.elasticsearch.tasks.TaskTracer;
import org.elasticsearch.tasks.Tracer;
import org.elasticsearch.threadpool.ExecutorBuilder;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.Transport;
Expand Down Expand Up @@ -753,9 +753,7 @@ protected Node(
final IndexingPressure indexingLimits = new IndexingPressure(settings);

final TaskTracer taskTracer = transportService.getTaskManager().getTaskTracer();
pluginComponents.stream()
.map(c -> c instanceof TracingPlugin.Tracer ? (TracingPlugin.Tracer) c : null)
.forEach(taskTracer::addTracer);
pluginComponents.stream().map(c -> c instanceof Tracer ? (Tracer) c : null).forEach(taskTracer::addTracer);

final RecoverySettings recoverySettings = new RecoverySettings(settings, settingsModule.getClusterSettings());
RepositoriesModule repositoriesModule = new RepositoriesModule(
Expand Down
3 changes: 1 addition & 2 deletions server/src/main/java/org/elasticsearch/tasks/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.NamedWriteable;
import org.elasticsearch.plugins.TracingPlugin;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.ToXContentObject;

Expand All @@ -21,7 +20,7 @@
/**
* Current task information
*/
public class Task implements TracingPlugin.Traceable {
public class Task implements Traceable {

/**
* The request header to mark tasks with specific ids
Expand Down
9 changes: 4 additions & 5 deletions server/src/main/java/org/elasticsearch/tasks/TaskTracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.plugins.TracingPlugin;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
Expand All @@ -20,16 +19,16 @@ public class TaskTracer {

private static final Logger logger = LogManager.getLogger();

private final List<TracingPlugin.Tracer> tracers = new CopyOnWriteArrayList<>();
private final List<Tracer> tracers = new CopyOnWriteArrayList<>();

public void addTracer(TracingPlugin.Tracer tracer) {
public void addTracer(Tracer tracer) {
if (tracer != null) {
tracers.add(tracer);
}
}

public void onTaskRegistered(Task task) {
for (TracingPlugin.Tracer tracer : tracers) {
for (Tracer tracer : tracers) {
try {
tracer.onTraceStarted(task);
} catch (Exception e) {
Expand All @@ -48,7 +47,7 @@ public void onTaskRegistered(Task task) {
}

public void onTaskUnregistered(Task task) {
for (TracingPlugin.Tracer tracer : tracers) {
for (Tracer tracer : tracers) {
try {
tracer.onTraceStopped(task);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,14 @@
* Side Public License, v 1.
*/

package org.elasticsearch.plugins;
package org.elasticsearch.tasks;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we want to make a dedicated package for tracing (as cluster state and auth tracing is not directly related to tasks)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

++ moved to org.elasticsearch.tracing in f73b052.


import java.util.Map;

public interface TracingPlugin {
public interface Traceable {
String getSpanId();

interface Traceable {
String getSpanId();
String getSpanName();

String getSpanName();

Map<String, Object> getAttributes();
}

interface Tracer {
void onTraceStarted(Traceable traceable);

void onTraceStopped(Traceable traceable);
}
Map<String, Object> getAttributes();
}
15 changes: 15 additions & 0 deletions server/src/main/java/org/elasticsearch/tasks/Tracer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

package org.elasticsearch.tasks;

public interface Tracer {
void onTraceStarted(Traceable traceable);

void onTraceStopped(Traceable traceable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.TracingPlugin;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.tasks.TaskTracer;
Expand Down Expand Up @@ -53,7 +52,7 @@ public void clearRecordedSpans() {
}

public void testModule() {
List<TracingPlugin> plugins = internalCluster().getMasterNodeInstance(PluginsService.class).filterPlugins(TracingPlugin.class);
List<APM> plugins = internalCluster().getMasterNodeInstance(PluginsService.class).filterPlugins(APM.class);
assertThat(plugins, hasSize(1));

TransportService transportService = internalCluster().getInstance(TransportService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.plugins.NetworkPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.TracingPlugin;
import org.elasticsearch.repositories.RepositoriesService;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.tasks.Task;
Expand All @@ -38,7 +37,7 @@
import java.util.Set;
import java.util.function.Supplier;

public class APM extends Plugin implements TracingPlugin, NetworkPlugin {
public class APM extends Plugin implements NetworkPlugin {

public static final Set<String> TRACE_HEADERS = Set.of(Task.TRACE_PARENT, Task.TRACE_STATE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.plugins.TracingPlugin;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.Traceable;
import org.elasticsearch.threadpool.ThreadPool;

import java.security.AccessController;
Expand All @@ -55,7 +55,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class APMTracer extends AbstractLifecycleComponent implements TracingPlugin.Tracer {
public class APMTracer extends AbstractLifecycleComponent implements org.elasticsearch.tasks.Tracer {

public static final CapturingSpanExporter CAPTURING_SPAN_EXPORTER = new CapturingSpanExporter();

Expand Down Expand Up @@ -122,7 +122,7 @@ protected void doStop() {
protected void doClose() {}

@Override
public void onTraceStarted(TracingPlugin.Traceable traceable) {
public void onTraceStarted(Traceable traceable) {
final Tracer tracer = this.tracer;
final OpenTelemetry openTelemetry = this.openTelemetry;
if (openTelemetry != null && tracer != null) {
Expand Down Expand Up @@ -190,7 +190,7 @@ public Map<String, String> getSpanHeadersById(String id) {
}

@Override
public void onTraceStopped(TracingPlugin.Traceable traceable) {
public void onTraceStopped(Traceable traceable) {
final Span span = spans.remove(traceable.getSpanId());
if (span != null) {
span.end();
Expand Down