-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Add metric for total downsampling latency #106747
Changes from 8 commits
cda3247
18ee7c3
830bef3
09c4324
130bba4
4745226
e763b15
aa81db6
74e16e7
5ce55f6
a201271
0ad2d3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,7 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.function.Predicate; | ||
|
||
|
@@ -115,6 +116,8 @@ public class TransportDownsampleAction extends AcknowledgedTransportMasterNodeAc | |
private final IndexScopedSettings indexScopedSettings; | ||
private final ThreadContext threadContext; | ||
private final PersistentTasksService persistentTasksService; | ||
private final DownsampleMetrics downsampleMetrics; | ||
private final long startTime; | ||
kkrik-es marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private static final Set<String> FORBIDDEN_SETTINGS = Set.of( | ||
IndexSettings.DEFAULT_PIPELINE.getKey(), | ||
|
@@ -153,7 +156,8 @@ public TransportDownsampleAction( | |
ActionFilters actionFilters, | ||
IndexNameExpressionResolver indexNameExpressionResolver, | ||
IndexScopedSettings indexScopedSettings, | ||
PersistentTasksService persistentTasksService | ||
PersistentTasksService persistentTasksService, | ||
DownsampleMetrics downsampleMetrics | ||
) { | ||
super( | ||
DownsampleAction.NAME, | ||
|
@@ -173,6 +177,12 @@ public TransportDownsampleAction( | |
this.threadContext = threadPool.getThreadContext(); | ||
this.taskQueue = clusterService.createTaskQueue("downsample", Priority.URGENT, STATE_UPDATE_TASK_EXECUTOR); | ||
this.persistentTasksService = persistentTasksService; | ||
this.downsampleMetrics = downsampleMetrics; | ||
this.startTime = client.threadPool().relativeTimeInMillis(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for my education - we actually create new instance of action for every invocation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. My understanding is that actions are initialized once in the plugin, then their methods ( |
||
} | ||
|
||
private long getDurationInMillis() { | ||
return TimeValue.timeValueMillis(client.threadPool().relativeTimeInMillis() - startTime).getMillis(); | ||
} | ||
|
||
@Override | ||
|
@@ -414,6 +424,7 @@ private void performShardDownsampling( | |
// NOTE: before we set the number of replicas to 0, as a result here we are | ||
// only dealing with primary shards. | ||
final AtomicInteger countDown = new AtomicInteger(numberOfShards); | ||
final AtomicBoolean errorReported = new AtomicBoolean(false); | ||
for (int shardNum = 0; shardNum < numberOfShards; shardNum++) { | ||
final ShardId shardId = new ShardId(sourceIndex, shardNum); | ||
final String persistentTaskId = createPersistentTaskId( | ||
|
@@ -465,6 +476,9 @@ public void onResponse(PersistentTasksCustomMetadata.PersistentTask<PersistentTa | |
@Override | ||
public void onFailure(Exception e) { | ||
logger.error("error while waiting for downsampling persistent task", e); | ||
if (errorReported.getAndSet(true) == false) { | ||
downsampleMetrics.recordLatencyMaster(getDurationInMillis(), DownsampleMetrics.ShardActionStatus.FAILED); | ||
kkrik-es marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
listener.onFailure(e); | ||
} | ||
}; | ||
|
@@ -529,6 +543,9 @@ private void updateTargetIndexSettingStep( | |
updateSettingsReq, | ||
new UpdateDownsampleIndexSettingsActionListener(listener, parentTask, downsampleIndexName, request.getWaitTimeout()) | ||
); | ||
|
||
// Record latency for downsampling operation. | ||
downsampleMetrics.recordLatencyMaster(getDurationInMillis(), DownsampleMetrics.ShardActionStatus.SUCCESS); | ||
kkrik-es marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
private static DownsampleShardTaskParams createPersistentTaskParams( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
master
part is leaking implementation details that may change in the future. I think that maybe api latency or operation latency is a better name here. Wdyt?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to
total
.