-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-support-for-scored-named-queries
Signed-off-by: Dharin Shah <[email protected]>
- Loading branch information
Showing
40 changed files
with
1,871 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
libs/telemetry/src/main/java/org/opensearch/telemetry/metrics/Histogram.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.telemetry.metrics; | ||
|
||
import org.opensearch.common.annotation.ExperimentalApi; | ||
import org.opensearch.telemetry.metrics.tags.Tags; | ||
|
||
/** | ||
* Histogram records the value for an existing metric. | ||
* {@opensearch.experimental} | ||
*/ | ||
@ExperimentalApi | ||
public interface Histogram { | ||
|
||
/** | ||
* record value. | ||
* @param value value to be added. | ||
*/ | ||
void record(double value); | ||
|
||
/** | ||
* record value along with the attributes. | ||
* | ||
* @param value value to be added. | ||
* @param tags attributes/dimensions of the metric. | ||
*/ | ||
void record(double value, Tags tags); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
libs/telemetry/src/main/java/org/opensearch/telemetry/metrics/noop/NoopHistogram.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.telemetry.metrics.noop; | ||
|
||
import org.opensearch.common.annotation.InternalApi; | ||
import org.opensearch.telemetry.metrics.Histogram; | ||
import org.opensearch.telemetry.metrics.tags.Tags; | ||
|
||
/** | ||
* No-op {@link Histogram} | ||
* {@opensearch.internal} | ||
*/ | ||
@InternalApi | ||
public class NoopHistogram implements Histogram { | ||
|
||
/** | ||
* No-op Histogram instance | ||
*/ | ||
public final static NoopHistogram INSTANCE = new NoopHistogram(); | ||
|
||
private NoopHistogram() {} | ||
|
||
@Override | ||
public void record(double value) { | ||
|
||
} | ||
|
||
@Override | ||
public void record(double value, Tags tags) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
opensearchplugin { | ||
description 'OpenSearch Query Insights Plugin.' | ||
classname 'org.opensearch.plugin.insights.QueryInsightsPlugin' | ||
} | ||
|
||
dependencies { | ||
} |
112 changes: 112 additions & 0 deletions
112
plugins/query-insights/src/main/java/org/opensearch/plugin/insights/QueryInsightsPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.plugin.insights; | ||
|
||
import org.opensearch.action.ActionRequest; | ||
import org.opensearch.client.Client; | ||
import org.opensearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.opensearch.cluster.node.DiscoveryNodes; | ||
import org.opensearch.cluster.service.ClusterService; | ||
import org.opensearch.common.settings.ClusterSettings; | ||
import org.opensearch.common.settings.IndexScopedSettings; | ||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.common.settings.SettingsFilter; | ||
import org.opensearch.common.unit.TimeValue; | ||
import org.opensearch.common.util.concurrent.OpenSearchExecutors; | ||
import org.opensearch.core.action.ActionResponse; | ||
import org.opensearch.core.common.io.stream.NamedWriteableRegistry; | ||
import org.opensearch.core.xcontent.NamedXContentRegistry; | ||
import org.opensearch.env.Environment; | ||
import org.opensearch.env.NodeEnvironment; | ||
import org.opensearch.plugin.insights.core.service.QueryInsightsService; | ||
import org.opensearch.plugin.insights.settings.QueryInsightsSettings; | ||
import org.opensearch.plugins.ActionPlugin; | ||
import org.opensearch.plugins.Plugin; | ||
import org.opensearch.repositories.RepositoriesService; | ||
import org.opensearch.rest.RestController; | ||
import org.opensearch.rest.RestHandler; | ||
import org.opensearch.script.ScriptService; | ||
import org.opensearch.threadpool.ExecutorBuilder; | ||
import org.opensearch.threadpool.ScalingExecutorBuilder; | ||
import org.opensearch.threadpool.ThreadPool; | ||
import org.opensearch.watcher.ResourceWatcherService; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Plugin class for Query Insights. | ||
*/ | ||
public class QueryInsightsPlugin extends Plugin implements ActionPlugin { | ||
/** | ||
* Default constructor | ||
*/ | ||
public QueryInsightsPlugin() {} | ||
|
||
@Override | ||
public Collection<Object> createComponents( | ||
final Client client, | ||
final ClusterService clusterService, | ||
final ThreadPool threadPool, | ||
final ResourceWatcherService resourceWatcherService, | ||
final ScriptService scriptService, | ||
final NamedXContentRegistry xContentRegistry, | ||
final Environment environment, | ||
final NodeEnvironment nodeEnvironment, | ||
final NamedWriteableRegistry namedWriteableRegistry, | ||
final IndexNameExpressionResolver indexNameExpressionResolver, | ||
final Supplier<RepositoriesService> repositoriesServiceSupplier | ||
) { | ||
// create top n queries service | ||
final QueryInsightsService queryInsightsService = new QueryInsightsService(threadPool); | ||
return List.of(queryInsightsService); | ||
} | ||
|
||
@Override | ||
public List<ExecutorBuilder<?>> getExecutorBuilders(final Settings settings) { | ||
return List.of( | ||
new ScalingExecutorBuilder( | ||
QueryInsightsSettings.QUERY_INSIGHTS_EXECUTOR, | ||
1, | ||
Math.min((OpenSearchExecutors.allocatedProcessors(settings) + 1) / 2, QueryInsightsSettings.MAX_THREAD_COUNT), | ||
TimeValue.timeValueMinutes(5) | ||
) | ||
); | ||
} | ||
|
||
@Override | ||
public List<RestHandler> getRestHandlers( | ||
final Settings settings, | ||
final RestController restController, | ||
final ClusterSettings clusterSettings, | ||
final IndexScopedSettings indexScopedSettings, | ||
final SettingsFilter settingsFilter, | ||
final IndexNameExpressionResolver indexNameExpressionResolver, | ||
final Supplier<DiscoveryNodes> nodesInCluster | ||
) { | ||
return List.of(); | ||
} | ||
|
||
@Override | ||
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() { | ||
return List.of(); | ||
} | ||
|
||
@Override | ||
public List<Setting<?>> getSettings() { | ||
return List.of( | ||
// Settings for top N queries | ||
QueryInsightsSettings.TOP_N_LATENCY_QUERIES_ENABLED, | ||
QueryInsightsSettings.TOP_N_LATENCY_QUERIES_SIZE, | ||
QueryInsightsSettings.TOP_N_LATENCY_QUERIES_WINDOW_SIZE | ||
); | ||
} | ||
} |
Oops, something went wrong.