{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls/comments/173920987","pull_request_review_id":103189695,"id":173920987,"diff_hunk":"@@ -1,23 +1,59 @@\n ﻿namespace Microsoft.Extensions.DependencyInjection\n {\n     using System.Collections.Generic;\n+    using System.Linq;\n     using Microsoft.ApplicationInsights.Extensibility;\n     using Microsoft.Extensions.Options;\n \n     /// <summary>\n-    /// The <see cref=\"IOptions{TelemetryConfiguration}\"/> implementation that uses <see cref=\"TelemetryConfiguration.Active\"/> as initial value.\n+    /// The <see cref=\"IOptions{TelemetryConfiguration}\"/> implementation that create new <see cref=\"TelemetryConfiguration\"/> every time when called\".\n     /// </summary>\n     internal class TelemetryConfigurationOptions : IOptions<TelemetryConfiguration>\n     {\n         public TelemetryConfigurationOptions(IEnumerable<IConfigureOptions<TelemetryConfiguration>> configureOptions)\n         {\n-            foreach (var c in configureOptions)\n+            // workaround for Microsoft/ApplicationInsights-dotnet#613\n+            this.Value = TelemetryConfiguration.CreateDefault();\n+\n+            var configureOptionsArray = configureOptions.ToArray();\n+            foreach (var c in configureOptionsArray)\n             {\n                 c.Configure(this.Value);\n             }\n+\n+            // as we expect some customers to use TelemetryConfiguration.Active together with dependency injection\n+            // we make sure it has been set up, it must be done only once even if there are multiple Web Hosts in the process\n+            if (!IsActiveConfigured(this.Value.InstrumentationKey))\n+            { \n+                foreach (var c in configureOptionsArray)\n+                {\n+                    c.Configure(TelemetryConfiguration.Active);\n+                }\n+            }\n         }\n \n         /// <inheritdoc />\n-        public TelemetryConfiguration Value => TelemetryConfiguration.Active;\n+        public TelemetryConfiguration Value { get; }\n+\n+        /// <summary>\n+        /// Determines if TelemetryConfiguration.Active needs to be configured.\n+        /// </summary>\n+        /// <param name=\"instrumentationKey\">Instrumentation key.</param>\n+        /// <returns>True is TelemertryConfiguration.Active was previously configured.</returns>\n+        private static bool IsActiveConfigured(string instrumentationKey)\n+        {\n+            var active = TelemetryConfiguration.Active;\n+            if (string.IsNullOrEmpty(active.InstrumentationKey) && !string.IsNullOrEmpty(instrumentationKey))\n+            {\n+                return false;\n+            }\n+\n+            if (active.TelemetryInitializers.Count <= 1)","path":"src/Microsoft.ApplicationInsights.AspNetCore/Implementation/TelemetryConfigurationOptions.cs","position":54,"original_position":54,"commit_id":"e1770a4eb86cf9e0e8c7e2a571e9e0df9e33a348","original_commit_id":"e1770a4eb86cf9e0e8c7e2a571e9e0df9e33a348","user":{"login":"Dmitry-Matveev","id":12158043,"avatar_url":"https://avatars0.githubusercontent.com/u/12158043?v=4","gravatar_id":"","url":"https://api.github.com/users/Dmitry-Matveev","html_url":"https://github.com/Dmitry-Matveev","followers_url":"https://api.github.com/users/Dmitry-Matveev/followers","following_url":"https://api.github.com/users/Dmitry-Matveev/following{/other_user}","gists_url":"https://api.github.com/users/Dmitry-Matveev/gists{/gist_id}","starred_url":"https://api.github.com/users/Dmitry-Matveev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dmitry-Matveev/subscriptions","organizations_url":"https://api.github.com/users/Dmitry-Matveev/orgs","repos_url":"https://api.github.com/users/Dmitry-Matveev/repos","events_url":"https://api.github.com/users/Dmitry-Matveev/events{/privacy}","received_events_url":"https://api.github.com/users/Dmitry-Matveev/received_events","type":"User","site_admin":false},"body":"This looks like a new enforced condition that we should have at least 2 telemetry initializers for Active to be configured. Should we add a test to actually require it (default TI > 2) and don't miss if some TIs are removed later?","created_at":"2018-03-12T19:34:15Z","updated_at":"2018-03-12T19:43:42Z","html_url":"https://github.com/Microsoft/ApplicationInsights-aspnetcore/pull/622#discussion_r173920987","pull_request_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls/622","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls/comments/173920987"},"html":{"href":"https://github.com/Microsoft/ApplicationInsights-aspnetcore/pull/622#discussion_r173920987"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls/622"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls/622","id":173900220,"html_url":"https://github.com/Microsoft/ApplicationInsights-aspnetcore/pull/622","diff_url":"https://github.com/Microsoft/ApplicationInsights-aspnetcore/pull/622.diff","patch_url":"https://github.com/Microsoft/ApplicationInsights-aspnetcore/pull/622.patch","issue_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues/622","number":622,"state":"open","locked":false,"title":"Prevent reuse and dispose of TelemetryConfiguration by multiple web hosts","user":{"login":"lmolkova","id":2347409,"avatar_url":"https://avatars2.githubusercontent.com/u/2347409?v=4","gravatar_id":"","url":"https://api.github.com/users/lmolkova","html_url":"https://github.com/lmolkova","followers_url":"https://api.github.com/users/lmolkova/followers","following_url":"https://api.github.com/users/lmolkova/following{/other_user}","gists_url":"https://api.github.com/users/lmolkova/gists{/gist_id}","starred_url":"https://api.github.com/users/lmolkova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmolkova/subscriptions","organizations_url":"https://api.github.com/users/lmolkova/orgs","repos_url":"https://api.github.com/users/lmolkova/repos","events_url":"https://api.github.com/users/lmolkova/events{/privacy}","received_events_url":"https://api.github.com/users/lmolkova/received_events","type":"User","site_admin":false},"body":"Fix Issue https://github.com/Microsoft/ApplicationInsights-dotnet/issues/613 .\r\n<Short description of the fix.>\r\nCreates a new instance of telemetry configuration by each Web host and updates TelemteryConfiguration.Active on the first run\r\n- [x] I ran Unit Tests locally.\r\n\r\nFor significant contributions please make sure you have completed the following items:\r\n\r\n- [x] Changes in public surface reviewed\r\n- [ ] Design discussion issue #\r\n- [x] CHANGELOG.md updated with one line description of the fix, and a link to the original issue.\r\n- [ ] The PR will trigger build, unit tests, and functional tests automatically. If your PR was submitted from fork - mention one of committers to initiate the build for you.\r\n\r\n@cijothomas could you please trigger tests for me and add me to the contributors list  in this repo?\r\n\r\n- Please follow [these] (https://github.com/Microsoft/ApplicationInsights-aspnetcore/blob/develop/Readme.md) instructions to build and test locally.\r\n","created_at":"2018-03-09T01:58:03Z","updated_at":"2018-03-12T19:43:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"65254ea7b6a32b55eff218f3e583b8976ea5e99f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls/622/commits","review_comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls/622/comments","review_comment_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues/622/comments","statuses_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/statuses/e1770a4eb86cf9e0e8c7e2a571e9e0df9e33a348","head":{"label":"lmolkova:lmolkova/NullRefMultiWebHost","ref":"lmolkova/NullRefMultiWebHost","sha":"e1770a4eb86cf9e0e8c7e2a571e9e0df9e33a348","user":{"login":"lmolkova","id":2347409,"avatar_url":"https://avatars2.githubusercontent.com/u/2347409?v=4","gravatar_id":"","url":"https://api.github.com/users/lmolkova","html_url":"https://github.com/lmolkova","followers_url":"https://api.github.com/users/lmolkova/followers","following_url":"https://api.github.com/users/lmolkova/following{/other_user}","gists_url":"https://api.github.com/users/lmolkova/gists{/gist_id}","starred_url":"https://api.github.com/users/lmolkova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmolkova/subscriptions","organizations_url":"https://api.github.com/users/lmolkova/orgs","repos_url":"https://api.github.com/users/lmolkova/repos","events_url":"https://api.github.com/users/lmolkova/events{/privacy}","received_events_url":"https://api.github.com/users/lmolkova/received_events","type":"User","site_admin":false},"repo":{"id":83714869,"name":"ApplicationInsights-aspnetcore","full_name":"lmolkova/ApplicationInsights-aspnetcore","owner":{"login":"lmolkova","id":2347409,"avatar_url":"https://avatars2.githubusercontent.com/u/2347409?v=4","gravatar_id":"","url":"https://api.github.com/users/lmolkova","html_url":"https://github.com/lmolkova","followers_url":"https://api.github.com/users/lmolkova/followers","following_url":"https://api.github.com/users/lmolkova/following{/other_user}","gists_url":"https://api.github.com/users/lmolkova/gists{/gist_id}","starred_url":"https://api.github.com/users/lmolkova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmolkova/subscriptions","organizations_url":"https://api.github.com/users/lmolkova/orgs","repos_url":"https://api.github.com/users/lmolkova/repos","events_url":"https://api.github.com/users/lmolkova/events{/privacy}","received_events_url":"https://api.github.com/users/lmolkova/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lmolkova/ApplicationInsights-aspnetcore","description":"ASP.NET Core web applications monitoring middleware","fork":true,"url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore","forks_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/forks","keys_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/teams","hooks_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/hooks","issue_events_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/issues/events{/number}","events_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/events","assignees_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/assignees{/user}","branches_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/branches{/branch}","tags_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/tags","blobs_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/git/refs{/sha}","trees_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/statuses/{sha}","languages_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/languages","stargazers_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/stargazers","contributors_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/contributors","subscribers_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/subscribers","subscription_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/subscription","commits_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/commits{/sha}","git_commits_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/git/commits{/sha}","comments_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/comments{/number}","issue_comment_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/issues/comments{/number}","contents_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/contents/{+path}","compare_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/merges","archive_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/downloads","issues_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/issues{/number}","pulls_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/pulls{/number}","milestones_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/milestones{/number}","notifications_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/labels{/name}","releases_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/releases{/id}","deployments_url":"https://api.github.com/repos/lmolkova/ApplicationInsights-aspnetcore/deployments","created_at":"2017-03-02T19:10:35Z","updated_at":"2017-03-02T19:10:37Z","pushed_at":"2018-03-09T20:38:57Z","git_url":"git://github.com/lmolkova/ApplicationInsights-aspnetcore.git","ssh_url":"git@github.com:lmolkova/ApplicationInsights-aspnetcore.git","clone_url":"https://github.com/lmolkova/ApplicationInsights-aspnetcore.git","svn_url":"https://github.com/lmolkova/ApplicationInsights-aspnetcore","homepage":"","size":6033,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"Microsoft:develop","ref":"develop","sha":"725a7bd3239438415fa82eb1445442cce7f999cf","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":32415843,"name":"ApplicationInsights-aspnetcore","full_name":"Microsoft/ApplicationInsights-aspnetcore","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/ApplicationInsights-aspnetcore","description":"ASP.NET Core web applications monitoring","fork":false,"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore","forks_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/forks","keys_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/teams","hooks_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/events","assignees_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/tags","blobs_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/languages","stargazers_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/subscription","commits_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/merges","archive_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/downloads","issues_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/deployments","created_at":"2015-03-17T19:39:40Z","updated_at":"2018-03-12T19:34:15Z","pushed_at":"2018-03-10T03:53:56Z","git_url":"git://github.com/Microsoft/ApplicationInsights-aspnetcore.git","ssh_url":"git@github.com:Microsoft/ApplicationInsights-aspnetcore.git","clone_url":"https://github.com/Microsoft/ApplicationInsights-aspnetcore.git","svn_url":"https://github.com/Microsoft/ApplicationInsights-aspnetcore","homepage":"","size":6065,"stargazers_count":155,"watchers_count":155,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":87,"mirror_url":null,"archived":false,"open_issues_count":85,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":87,"open_issues":85,"watchers":155,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls/622"},"html":{"href":"https://github.com/Microsoft/ApplicationInsights-aspnetcore/pull/622"},"issue":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues/622"},"comments":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues/622/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls/622/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/pulls/622/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/statuses/e1770a4eb86cf9e0e8c7e2a571e9e0df9e33a348"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Dmitry-Matveev"}}