Skip to content

Commit

Permalink
Register service provider for insights before get insights client (#4710
Browse files Browse the repository at this point in the history
)

Co-authored-by: Andy Xu(devdiv) <andxu@microsoft.com>
  • Loading branch information
Flanker32 and andxu authored Nov 4, 2020
1 parent d5f1af4 commit dbc77ec
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public abstract class AzureManagerBase implements AzureManager {
private static final String GLOBAL_SCM_SUFFIX = ".scm.azurewebsites.net";

private static final Logger LOGGER = Logger.getLogger(AzureManagerBase.class.getName());
private static final String MICROSOFT_INSIGHTS_NAMESPACE = "microsoft.insights";

protected Map<String, Azure> sidToAzureMap = new ConcurrentHashMap<>();
protected Map<String, AppPlatformManager> sidToAzureSpringCloudManagerMap = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -171,6 +172,13 @@ public InsightsManager getInsightsManager(String sid) throws IOException {
return null;
}
return sidToInsightsManagerMap.computeIfAbsent(sid, s -> {
try {
// Register insights namespace first
final Azure azure = getAzure(sid);
azure.providers().register(MICROSOFT_INSIGHTS_NAMESPACE);
} catch (IOException e) {
// swallow exception while get azure client
}
String tid = this.subscriptionManager.getSubscriptionTenant(sid);
return authApplicationInsights(sid, tid);
});
Expand Down

0 comments on commit dbc77ec

Please sign in to comment.