{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Python/issues/103","repository_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Python","labels_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Python/issues/103/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Python/issues/103/comments","events_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Python/issues/103/events","html_url":"https://github.com/Microsoft/ApplicationInsights-Python/issues/103","id":335849377,"node_id":"MDU6SXNzdWUzMzU4NDkzNzc=","number":103,"title":"Allow setting custom context properties for applicationinsights.exceptions.enable()","user":{"login":"letmaik","id":530988,"node_id":"MDQ6VXNlcjUzMDk4OA==","avatar_url":"https://avatars1.githubusercontent.com/u/530988?v=4","gravatar_id":"","url":"https://api.github.com/users/letmaik","html_url":"https://github.com/letmaik","followers_url":"https://api.github.com/users/letmaik/followers","following_url":"https://api.github.com/users/letmaik/following{/other_user}","gists_url":"https://api.github.com/users/letmaik/gists{/gist_id}","starred_url":"https://api.github.com/users/letmaik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/letmaik/subscriptions","organizations_url":"https://api.github.com/users/letmaik/orgs","repos_url":"https://api.github.com/users/letmaik/repos","events_url":"https://api.github.com/users/letmaik/events{/privacy}","received_events_url":"https://api.github.com/users/letmaik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-26T14:33:41Z","updated_at":"2018-06-26T15:59:42Z","closed_at":null,"author_association":"MEMBER","body":"Currently there doesn't seem to be an easy way to use `applicationinsights.exceptions.enable()` while also sending context properties for those unhandled exceptions. Looking at the code it seems that one has to do something like the following currently (not tested):\r\n\r\n```py\r\nfrom applicationinsights import channel, TelemetryClient\r\nfrom applicationinsights.exceptions import enable\r\n\r\nchannel = channel.TelemetryChannel()\r\nclient = TelemetryClient(\"my-key\", channel)\r\nclient.context.properties[\"foo\"] = \"bar\"\r\nenable(\"my-key\", telemetry_channel=channel) # must be kw arg\r\n```\r\n\r\nI think https://github.com/Microsoft/ApplicationInsights-Python/issues/56 would help for this case as well so that the user doesn't have to deal with TelemetryChannel objects.\r\n\r\nGiven bug https://github.com/Microsoft/ApplicationInsights-Python/pull/102 I think that the above code currently wouldn't work anyway since the `track_exception` call that happens in the background doesn't get `properties` which triggers the bug where the context properties are ignored as well."},"comment":{"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Python/issues/comments/400365739","html_url":"https://github.com/Microsoft/ApplicationInsights-Python/issues/103#issuecomment-400365739","issue_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Python/issues/103","id":400365739,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDM2NTczOQ==","user":{"login":"letmaik","id":530988,"node_id":"MDQ6VXNlcjUzMDk4OA==","avatar_url":"https://avatars1.githubusercontent.com/u/530988?v=4","gravatar_id":"","url":"https://api.github.com/users/letmaik","html_url":"https://github.com/letmaik","followers_url":"https://api.github.com/users/letmaik/followers","following_url":"https://api.github.com/users/letmaik/following{/other_user}","gists_url":"https://api.github.com/users/letmaik/gists{/gist_id}","starred_url":"https://api.github.com/users/letmaik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/letmaik/subscriptions","organizations_url":"https://api.github.com/users/letmaik/orgs","repos_url":"https://api.github.com/users/letmaik/repos","events_url":"https://api.github.com/users/letmaik/events{/privacy}","received_events_url":"https://api.github.com/users/letmaik/received_events","type":"User","site_admin":false},"created_at":"2018-06-26T15:59:42Z","updated_at":"2018-06-26T15:59:42Z","author_association":"MEMBER","body":"Correction, my example code should probably be:\r\n```py\r\nchannel = channel.TelemetryChannel()\r\nchannel.context.properties[\"foo\"] = \"bar\"\r\nenable(\"my-key\", telemetry_channel=channel) # must be kw arg\r\n```"}}
{"actor":{"display_login":"letmaik"}}