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

[Tracing Instrumentation] Add instrumentation in transport action #10096

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -94,6 +94,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Allow parameterization of tests with OpenSearchIntegTestCase.SuiteScopeTestCase annotation ([#9916](https://github.com/opensearch-project/OpenSearch/pull/9916))
- Mute the query profile IT with concurrent execution ([#9840](https://github.com/opensearch-project/OpenSearch/pull/9840))
- Add instrumentation in transport service. ([#10042](https://github.com/opensearch-project/OpenSearch/pull/10042))
- Add instrumentation in transport action. ([#10096](https://github.com/opensearch-project/OpenSearch/pull/10096))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.index.shard.ShardId;
import org.opensearch.tasks.Task;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.transport.TransportService;

public class TransportNoopBulkAction extends HandledTransportAction<BulkRequest, BulkResponse> {
Expand All @@ -53,8 +54,8 @@ public class TransportNoopBulkAction extends HandledTransportAction<BulkRequest,
);

@Inject
public TransportNoopBulkAction(TransportService transportService, ActionFilters actionFilters) {
super(NoopBulkAction.NAME, transportService, actionFilters, BulkRequest::new);
public TransportNoopBulkAction(TransportService transportService, ActionFilters actionFilters, Tracer tracer) {
super(NoopBulkAction.NAME, transportService, actionFilters, BulkRequest::new, tracer);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@
import org.opensearch.search.profile.SearchProfileShardResults;
import org.opensearch.search.suggest.Suggest;
import org.opensearch.tasks.Task;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.transport.TransportService;

import java.util.Collections;

public class TransportNoopSearchAction extends HandledTransportAction<SearchRequest, SearchResponse> {
@Inject
public TransportNoopSearchAction(TransportService transportService, ActionFilters actionFilters) {
super(NoopSearchAction.NAME, transportService, actionFilters, (Writeable.Reader<SearchRequest>) SearchRequest::new);
public TransportNoopSearchAction(TransportService transportService, ActionFilters actionFilters, Tracer tracer) {
super(NoopSearchAction.NAME, transportService, actionFilters, (Writeable.Reader<SearchRequest>) SearchRequest::new, tracer);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.opensearch.rest.RestRequest;
import org.opensearch.rest.action.RestToXContentListener;
import org.opensearch.tasks.Task;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.transport.TransportService;

import java.io.IOException;
Expand Down Expand Up @@ -134,13 +135,13 @@ public static class TransportAction extends HandledTransportAction<Request, Resp
private final Map<String, String> sortedGrokPatterns;

@Inject
public TransportAction(TransportService transportService, ActionFilters actionFilters) {
this(transportService, actionFilters, Grok.BUILTIN_PATTERNS);
public TransportAction(TransportService transportService, ActionFilters actionFilters, Tracer tracer) {
this(transportService, actionFilters, Grok.BUILTIN_PATTERNS, tracer);
}

// visible for testing
TransportAction(TransportService transportService, ActionFilters actionFilters, Map<String, String> grokPatterns) {
super(NAME, transportService, actionFilters, Request::new);
TransportAction(TransportService transportService, ActionFilters actionFilters, Map<String, String> grokPatterns, Tracer tracer) {
super(NAME, transportService, actionFilters, Request::new, tracer);
this.grokPatterns = grokPatterns;
this.sortedGrokPatterns = new TreeMap<>(this.grokPatterns);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.telemetry.tracing.noop.NoopTracer;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.transport.TransportService;

Expand Down Expand Up @@ -84,7 +85,8 @@ public void testResponseSorting() {
GrokProcessorGetAction.TransportAction transportAction = new GrokProcessorGetAction.TransportAction(
mock(TransportService.class),
mock(ActionFilters.class),
TEST_PATTERNS
TEST_PATTERNS,
NoopTracer.INSTANCE
);
GrokProcessorGetAction.Response[] receivedResponse = new GrokProcessorGetAction.Response[1];
transportAction.doExecute(null, new GrokProcessorGetAction.Request(true), new ActionListener<GrokProcessorGetAction.Response>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.script.ScriptService;
import org.opensearch.tasks.Task;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.transport.TransportService;

import java.util.ArrayList;
Expand All @@ -62,9 +63,10 @@ public TransportMultiSearchTemplateAction(
ActionFilters actionFilters,
ScriptService scriptService,
NamedXContentRegistry xContentRegistry,
NodeClient client
NodeClient client,
Tracer tracer
) {
super(MultiSearchTemplateAction.NAME, transportService, actionFilters, MultiSearchTemplateRequest::new);
super(MultiSearchTemplateAction.NAME, transportService, actionFilters, MultiSearchTemplateRequest::new, tracer);
this.scriptService = scriptService;
this.xContentRegistry = xContentRegistry;
this.client = client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.opensearch.search.builder.SearchSourceBuilder;
import org.opensearch.search.internal.SearchContext;
import org.opensearch.tasks.Task;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.transport.TransportService;

import java.io.IOException;
Expand All @@ -71,9 +72,10 @@ public TransportSearchTemplateAction(
ActionFilters actionFilters,
ScriptService scriptService,
NamedXContentRegistry xContentRegistry,
NodeClient client
NodeClient client,
Tracer tracer
) {
super(SearchTemplateAction.NAME, transportService, actionFilters, SearchTemplateRequest::new);
super(SearchTemplateAction.NAME, transportService, actionFilters, SearchTemplateRequest::new, tracer);
this.scriptService = scriptService;
this.xContentRegistry = xContentRegistry;
this.client = client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.opensearch.rest.action.RestToXContentListener;
import org.opensearch.script.ScriptContext;
import org.opensearch.tasks.Task;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.transport.TransportService;

import java.io.IOException;
Expand Down Expand Up @@ -166,8 +167,13 @@ public static class TransportAction extends HandledTransportAction<Request, Resp
private final PainlessScriptEngine painlessScriptEngine;

@Inject
public TransportAction(TransportService transportService, ActionFilters actionFilters, PainlessScriptEngine painlessScriptEngine) {
super(NAME, transportService, actionFilters, (Writeable.Reader<Request>) Request::new);
public TransportAction(
TransportService transportService,
ActionFilters actionFilters,
PainlessScriptEngine painlessScriptEngine,
Tracer tracer
) {
super(NAME, transportService, actionFilters, (Writeable.Reader<Request>) Request::new, tracer);
this.painlessScriptEngine = painlessScriptEngine;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import org.opensearch.script.ScriptContext;
import org.opensearch.script.ScriptService;
import org.opensearch.script.ScriptType;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

Expand Down Expand Up @@ -475,7 +476,8 @@ public TransportAction(
IndexNameExpressionResolver indexNameExpressionResolver,
ScriptService scriptService,
ClusterService clusterService,
IndicesService indicesServices
IndicesService indicesServices,
Tracer tracer
) {
super(
NAME,
Expand All @@ -488,7 +490,8 @@ public TransportAction(
// Creating a in-memory index is not light weight
// TODO: is MANAGEMENT TP the right TP? Right now this is an admin api (see action name).
Request::new,
ThreadPool.Names.MANAGEMENT
ThreadPool.Names.MANAGEMENT,
tracer
);
this.scriptService = scriptService;
this.indicesServices = indicesServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.opensearch.search.SearchHit;
import org.opensearch.search.builder.SearchSourceBuilder;
import org.opensearch.tasks.Task;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.transport.TransportService;

import java.io.IOException;
Expand Down Expand Up @@ -90,9 +91,10 @@ public TransportRankEvalAction(
Client client,
TransportService transportService,
ScriptService scriptService,
NamedXContentRegistry namedXContentRegistry
NamedXContentRegistry namedXContentRegistry,
Tracer tracer
) {
super(RankEvalAction.NAME, transportService, actionFilters, (Writeable.Reader<RankEvalRequest>) RankEvalRequest::new);
super(RankEvalAction.NAME, transportService, actionFilters, (Writeable.Reader<RankEvalRequest>) RankEvalRequest::new, tracer);
this.scriptService = scriptService;
this.namedXContentRegistry = namedXContentRegistry;
this.client = client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.opensearch.env.Environment;
import org.opensearch.script.ScriptService;
import org.opensearch.search.builder.SearchSourceBuilder;
import org.opensearch.telemetry.tracing.noop.NoopTracer;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.transport.TransportService;

Expand Down Expand Up @@ -103,7 +104,8 @@ public void multiSearch(MultiSearchRequest request, ActionListener<MultiSearchRe
client,
mock(TransportService.class),
mock(ScriptService.class),
NamedXContentRegistry.EMPTY
NamedXContentRegistry.EMPTY,
NoopTracer.INSTANCE
);
action.doExecute(null, rankEvalRequest, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.script.ScriptService;
import org.opensearch.tasks.Task;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

Expand All @@ -59,13 +60,15 @@ public TransportDeleteByQueryAction(
Client client,
TransportService transportService,
ScriptService scriptService,
ClusterService clusterService
ClusterService clusterService,
Tracer tracer
) {
super(
DeleteByQueryAction.NAME,
transportService,
actionFilters,
(Writeable.Reader<DeleteByQueryRequest>) DeleteByQueryRequest::new
(Writeable.Reader<DeleteByQueryRequest>) DeleteByQueryRequest::new,
tracer
);
this.threadPool = threadPool;
this.client = client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.opensearch.index.reindex.spi.RemoteReindexExtension;
import org.opensearch.script.ScriptService;
import org.opensearch.tasks.Task;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

Expand Down Expand Up @@ -87,9 +88,10 @@ public TransportReindexAction(
AutoCreateIndex autoCreateIndex,
Client client,
TransportService transportService,
ReindexSslConfig sslConfig
ReindexSslConfig sslConfig,
Tracer tracer
) {
super(ReindexAction.NAME, transportService, actionFilters, ReindexRequest::new);
super(ReindexAction.NAME, transportService, actionFilters, ReindexRequest::new, tracer);
this.reindexValidator = new ReindexValidator(settings, clusterService, indexNameExpressionResolver, autoCreateIndex);
this.reindexer = new Reindexer(clusterService, client, threadPool, scriptService, sslConfig, remoteExtension);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.tasks.TaskId;
import org.opensearch.tasks.TaskInfo;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

Expand All @@ -57,7 +58,8 @@ public TransportRethrottleAction(
ClusterService clusterService,
TransportService transportService,
ActionFilters actionFilters,
Client client
Client client,
Tracer tracer
) {
super(
RethrottleAction.NAME,
Expand All @@ -67,7 +69,8 @@ public TransportRethrottleAction(
RethrottleRequest::new,
ListTasksResponse::new,
TaskInfo::new,
ThreadPool.Names.MANAGEMENT
ThreadPool.Names.MANAGEMENT,
tracer
);
this.client = client;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.opensearch.script.Script;
import org.opensearch.script.ScriptService;
import org.opensearch.tasks.Task;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

Expand All @@ -69,13 +70,15 @@ public TransportUpdateByQueryAction(
Client client,
TransportService transportService,
ScriptService scriptService,
ClusterService clusterService
ClusterService clusterService,
Tracer tracer
) {
super(
UpdateByQueryAction.NAME,
transportService,
actionFilters,
(Writeable.Reader<UpdateByQueryRequest>) UpdateByQueryRequest::new
(Writeable.Reader<UpdateByQueryRequest>) UpdateByQueryRequest::new,
tracer
);
this.threadPool = threadPool;
this.client = client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import org.opensearch.search.internal.InternalSearchResponse;
import org.opensearch.tasks.Task;
import org.opensearch.tasks.TaskManager;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.test.client.NoOpClient;
import org.opensearch.threadpool.TestThreadPool;
Expand Down Expand Up @@ -818,8 +819,13 @@ private static class DummyTransportAsyncBulkByScrollAction extends TransportActi
DummyAbstractBulkByScrollRequest,
BulkByScrollResponse> {

protected DummyTransportAsyncBulkByScrollAction(String actionName, ActionFilters actionFilters, TaskManager taskManager) {
super(actionName, actionFilters, taskManager);
protected DummyTransportAsyncBulkByScrollAction(
String actionName,
ActionFilters actionFilters,
TaskManager taskManager,
Tracer tracer
) {
super(actionName, actionFilters, taskManager, tracer);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.opensearch.action.support.ActionFilters;
import org.opensearch.cluster.ClusterState;
import org.opensearch.script.ScriptService;
import org.opensearch.telemetry.tracing.noop.NoopTracer;
import org.opensearch.transport.TransportService;

import java.util.Collections;
Expand Down Expand Up @@ -79,7 +80,8 @@ protected TransportUpdateByQueryAction.AsyncIndexBySearchAction action(ScriptSer
null,
transportService,
scriptService,
null
null,
NoopTracer.INSTANCE
);
return new TransportUpdateByQueryAction.AsyncIndexBySearchAction(
task,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.opensearch.plugin.correlation.utils.IndexUtils;
import org.opensearch.rest.RestRequest;
import org.opensearch.tasks.Task;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.transport.TransportService;

import java.io.IOException;
Expand Down Expand Up @@ -68,9 +69,10 @@ public TransportIndexCorrelationRuleAction(
Client client,
ActionFilters actionFilters,
ClusterService clusterService,
CorrelationRuleIndices correlationRuleIndices
CorrelationRuleIndices correlationRuleIndices,
Tracer tracer
) {
super(IndexCorrelationRuleAction.NAME, transportService, actionFilters, IndexCorrelationRuleRequest::new);
super(IndexCorrelationRuleAction.NAME, transportService, actionFilters, IndexCorrelationRuleRequest::new, tracer);
this.client = client;
this.clusterService = clusterService;
this.correlationRuleIndices = correlationRuleIndices;
Expand Down
Loading
Loading