Skip to content

Commit 4b5075f

Browse files
authored
Merge pull request #5020 from microsoft/telemetry/background
Fix service name and operation name in background tasks
2 parents 2dba4dd + 12cc809 commit 4b5075f

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/BasicActionBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,17 @@ protected void actionPerformed(NodeActionEvent e) {
116116
runnable.run();
117117
}
118118
};
119+
// TODO (Qianjin) : remove after migrate all telemetry data by @AzureOperation annotation.
120+
final String actionName2 = Optional.ofNullable(action).map(AzureActionEnum::getName).orElse(null);
121+
String realActionName = StringUtils.firstNonBlank(actionName, actionName2, "unknown").toLowerCase();
122+
delegate = new DelegateActionListener.TelemetricActionListener(delegate, MODULE_NAME_TO_SERVICE_NAME_MAP.get(moduleName), realActionName);
119123
if (backgroundable) {
120124
delegate = new DelegateActionListener.BackgroundActionListener(delegate,
121125
getProgressMessage(doingName), backgroundCancellable, backgroundConditionalModal);
122126
}
123127
if (promptable) {
124128
delegate = new DelegateActionListener.PromptActionListener(delegate, getPromptMessage(actionName));
125129
}
126-
// TODO (Qianjin) : remove after migrate all telemetry data by @AzureOperation annotation.
127-
final String actionName2 = Optional.ofNullable(action).map(AzureActionEnum::getName).orElse(null);
128-
String realActionName = StringUtils.firstNonBlank(actionName, actionName2, "unknown").toLowerCase();
129-
delegate = new DelegateActionListener.TelemetricActionListener(delegate, MODULE_NAME_TO_SERVICE_NAME_MAP.get(moduleName), realActionName);
130130
return delegate;
131131
}
132132

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/DelegateActionListener.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package com.microsoft.tooling.msservices.serviceexplorer;
77

88
import com.google.common.base.Preconditions;
9+
import com.microsoft.azure.toolkit.lib.common.operation.IAzureOperationTitle;
910
import com.microsoft.azure.toolkit.lib.common.task.AzureTask;
1011
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
1112
import com.microsoft.azuretools.ActionConstants;
@@ -76,7 +77,12 @@ public void actionPerformed(NodeActionEvent e) {
7677
}
7778
};
7879
final Object project = e.getAction().getNode().getProject();
79-
AzureTask task = new AzureTask(project, progressMessage, cancellable, runnable);
80+
AzureTask task = new AzureTask(project, new IAzureOperationTitle.Simple(progressMessage) {
81+
@Override
82+
public String getName() {
83+
return String.format("%s.%s", BackgroundActionListener.super.getServiceName(e), BackgroundActionListener.super.getOperationName(e));
84+
}
85+
}, cancellable, runnable);
8086
if (conditionalModal) {
8187
AzureTaskManager.getInstance().runInModal(task);
8288
} else {
@@ -88,7 +94,7 @@ public void actionPerformed(NodeActionEvent e) {
8894

8995
static final class PromptActionListener extends DelegateActionListener {
9096
private static final String PROMPT_TITLE = "Azure Explorer";
91-
private static final String[] PROMPT_OPTIONS = new String[] {"Yes", "No"};
97+
private static final String[] PROMPT_OPTIONS = new String[]{"Yes", "No"};
9298

9399
private String promptMessage;
94100

0 commit comments

Comments
 (0)