Skip to content

Commit 8ceb146

Browse files
authored
Merge pull request #5013 from microsoft/mysql/telemetry
Fix telemetries for Azure MySQL support
2 parents 28292f7 + 5fe0985 commit 8ceb146

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/mysql/action/MySQLConnectToServerAction.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.intellij.openapi.extensions.PluginId;
1010
import com.intellij.openapi.project.Project;
1111
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
12+
import com.microsoft.azuretools.ActionConstants;
1213
import com.microsoft.azuretools.authmanage.AuthMethodManager;
1314
import com.microsoft.intellij.actions.AzureSignInAction;
1415
import com.microsoft.intellij.AzurePlugin;
@@ -61,6 +62,16 @@ public void actionPerformed(NodeActionEvent e) {
6162
});
6263
}
6364

65+
@Override
66+
protected String getServiceName(NodeActionEvent event) {
67+
return ActionConstants.parse(ActionConstants.MySQL.CONNECT_TO_SERVER).getServiceName();
68+
}
69+
70+
@Override
71+
protected String getOperationName(NodeActionEvent event) {
72+
return ActionConstants.parse(ActionConstants.MySQL.CONNECT_TO_SERVER).getOperationName();
73+
}
74+
6475
private void doActionPerformed(NodeActionEvent e, boolean isLoggedIn, Project project) {
6576
try {
6677
if (!isLoggedIn ||

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/lib/mysql/AzureMySQLService.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
import com.microsoft.azuretools.ActionConstants;
1515
import com.microsoft.azuretools.authmanage.AuthMethodManager;
1616
import com.microsoft.azuretools.core.mvp.model.mysql.MySQLMvpModel;
17-
import com.microsoft.azuretools.telemetrywrapper.Operation;
18-
import com.microsoft.azuretools.telemetrywrapper.TelemetryManager;
17+
import com.microsoft.azuretools.telemetry.TelemetryConstants;
18+
import com.microsoft.azuretools.telemetrywrapper.*;
19+
20+
import java.util.Collections;
21+
import java.util.Map;
1922

2023
public class AzureMySQLService {
2124
private static final AzureMySQLService instance = new AzureMySQLService();
@@ -36,10 +39,11 @@ public Server createMySQL(final AzureMySQLConfig config) {
3639
final Operation operation = TelemetryManager.createOperation(ActionConstants.MySQL.CREATE);
3740
try {
3841
operation.start();
39-
String subscrptionId = config.getSubscription().subscriptionId();
42+
final String subscriptionId = config.getSubscription().subscriptionId();
43+
EventUtil.logEvent(EventType.info, operation, Collections.singletonMap(TelemetryConstants.SUBSCRIPTIONID, subscriptionId));
4044
// create resource group if necessary.
4145
if (config.getResourceGroup() instanceof Draft) {
42-
Azure azure = AuthMethodManager.getInstance().getAzureClient(subscrptionId);
46+
Azure azure = AuthMethodManager.getInstance().getAzureClient(subscriptionId);
4347
ResourceGroup newResourceGroup = azure.resourceGroups().define(config.getResourceGroup().name()).withRegion(config.getRegion()).create();
4448
config.setResourceGroup(newResourceGroup);
4549
}
@@ -48,13 +52,14 @@ public Server createMySQL(final AzureMySQLConfig config) {
4852
parameters.withAdministratorLogin(config.getAdminUsername())
4953
.withAdministratorLoginPassword(String.valueOf(config.getPassword()))
5054
.withVersion(config.getVersion());
51-
Server server = MySQLMvpModel.create(subscrptionId, config.getResourceGroup().name(), config.getServerName(), config.getRegion(), parameters);
55+
Server server = MySQLMvpModel.create(subscriptionId, config.getResourceGroup().name(), config.getServerName(), config.getRegion(), parameters);
5256
// update access from azure services
53-
MySQLMvpModel.FirewallRuleMvpModel.updateAllowAccessFromAzureServices(subscrptionId, server, config.isAllowAccessFromAzureServices());
57+
MySQLMvpModel.FirewallRuleMvpModel.updateAllowAccessFromAzureServices(subscriptionId, server, config.isAllowAccessFromAzureServices());
5458
// update access from local machine
55-
MySQLMvpModel.FirewallRuleMvpModel.updateAllowAccessToLocalMachine(subscrptionId, server, config.isAllowAccessFromLocalMachine());
59+
MySQLMvpModel.FirewallRuleMvpModel.updateAllowAccessToLocalMachine(subscriptionId, server, config.isAllowAccessFromLocalMachine());
5660
return server;
5761
} catch (final RuntimeException e) {
62+
EventUtil.logError(operation, ErrorType.systemError, e, null, null);
5863
throw e;
5964
} finally {
6065
operation.complete();

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import com.microsoft.azuretools.ActionConstants;
1212
import com.microsoft.azuretools.azurecommons.helpers.Nullable;
1313
import com.microsoft.azuretools.core.mvp.model.mysql.MySQLMvpModel;
14+
import com.microsoft.azuretools.telemetry.TelemetryConstants;
15+
import com.microsoft.azuretools.telemetry.TelemetryProperties;
1416
import com.microsoft.tooling.msservices.components.DefaultLoader;
1517
import com.microsoft.tooling.msservices.serviceexplorer.AzureActionEnum;
1618
import com.microsoft.tooling.msservices.serviceexplorer.AzureIconSymbol;
@@ -22,9 +24,11 @@
2224
import com.microsoft.tooling.msservices.serviceexplorer.Sortable;
2325
import lombok.Getter;
2426

27+
import java.util.Collections;
2528
import java.util.List;
29+
import java.util.Map;
2630

27-
public class MySQLNode extends Node {
31+
public class MySQLNode extends Node implements TelemetryProperties {
2832

2933
private static final ServerState SERVER_UPDATING = ServerState.fromString("Updating");
3034

@@ -123,4 +127,8 @@ private void showProperties() {
123127
DefaultLoader.getUIHelper().openMySQLPropertyView(MySQLNode.this);
124128
}
125129

130+
@Override
131+
public Map<String, String> toProperties() {
132+
return Collections.singletonMap(TelemetryConstants.SUBSCRIPTIONID, this.subscriptionId);
133+
}
126134
}

0 commit comments

Comments
 (0)