{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls/comments/30352138","id":30352138,"diff_hunk":"@@ -0,0 +1,157 @@\n+/*\n+ * ApplicationInsights-Java\n+ * Copyright (c) Microsoft Corporation\n+ * All rights reserved.\n+ *\n+ * MIT License\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this\n+ * software and associated documentation files (the \"\"Software\"\"), to deal in the Software\n+ * without restriction, including without limitation the rights to use, copy, modify, merge,\n+ * publish, distribute, sublicense, and/or sell copies of the Software, and to permit\n+ * persons to whom the Software is furnished to do so, subject to the following conditions:\n+ * The above copyright notice and this permission notice shall be included in all copies or\n+ * substantial portions of the Software.\n+ * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n+ * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE\n+ * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n+ * DEALINGS IN THE SOFTWARE.\n+ */\n+\n+package com.microsoft.applicationinsights.collectd.internal;\n+\n+import java.util.Dictionary;\n+import java.util.Hashtable;\n+import java.util.List;\n+import com.microsoft.applicationinsights.collectd.ConfigurationException;\n+import com.microsoft.applicationinsights.internal.util.LocalStringsUtils;\n+import org.collectd.api.OConfigItem;\n+import org.collectd.api.OConfigValue;\n+\n+/**\n+ * Created by yonisha on 5/5/2015.\n+ *\n+ * This class purpose is to parse configuration passed from CollectD framework.\n+ */\n+public class WriterConfiguration {\n+\n+    // region Consts\n+\n+    public static final String EXCLUDE_CONFIGURATION_KEY = \"Exclude\";\n+    public static final String INSTRUMENTATION_KEY_CONFIGURATION_KEY = \"InstrumentationKey\";\n+    public static final String SDK_LOGGER_CONFIGURATION_KEY = \"SDKLogger\";\n+\n+    // endregion Consts\n+\n+    // region Members\n+\n+    private static ApplicationInsightsWriterLogger logger = new ApplicationInsightsWriterLogger();\n+    private Dictionary<String, PluginExclusion> pluginExclusions = new Hashtable<String, PluginExclusion>();\n+    private String instrumentationKey;\n+    private boolean isLoggerEnabled;\n+\n+    // endregion Members\n+\n+    /**\n+     * Gets the instrumentation key.\n+     * @return The instrumentation key.\n+     */\n+    public String getInstrumentationKey() {\n+        return this.instrumentationKey;\n+    }\n+\n+    /**\n+     * Gets a value indicating whether the logger is enabled or not.\n+     * @return True if the logger is enabled, false otherwise.\n+     */\n+    public boolean getIsLoggerEnabled() {\n+        return this.isLoggerEnabled;\n+    }\n+\n+    /**\n+     * Gets a dictionary of excluded plugins and data sources.\n+     * @return Dictionary of excluded plugins and data sources.\n+     */\n+    public Dictionary<String, PluginExclusion> getPluginExclusions() {\n+        return this.pluginExclusions;\n+    }\n+\n+    /**\n+     * Builds @WriterConfiguration from the given CollectD configuration object.\n+     * @param configuration The CollectD configuration.\n+     * @return The configuration for Application Insights writer plugin.\n+     * @throws ConfigurationException Thrown if the configuration is invalid.\n+     */\n+    public static WriterConfiguration buildConfiguration(OConfigItem configuration) throws ConfigurationException {\n+        logger.logDebug(\"Parsing configuration: \" + configuration);\n+\n+        WriterConfiguration writerConfiguration = new WriterConfiguration();\n+        List<OConfigItem> children = configuration.getChildren();\n+\n+        for (OConfigItem child : children) {\n+            String key = child.getKey();\n+\n+            if (key.equalsIgnoreCase(INSTRUMENTATION_KEY_CONFIGURATION_KEY)) {","path":"collectd/src/main/java/com/microsoft/applicationinsights/collectd/internal/WriterConfiguration.java","position":95,"original_position":95,"commit_id":"e598676fc87ec9b008e74669b1af400da3c58065","original_commit_id":"e598676fc87ec9b008e74669b1af400da3c58065","user":{"login":"amnonshmsft","id":10062845,"avatar_url":"https://avatars.githubusercontent.com/u/10062845?v=3","gravatar_id":"","url":"https://api.github.com/users/amnonshmsft","html_url":"https://github.com/amnonshmsft","followers_url":"https://api.github.com/users/amnonshmsft/followers","following_url":"https://api.github.com/users/amnonshmsft/following{/other_user}","gists_url":"https://api.github.com/users/amnonshmsft/gists{/gist_id}","starred_url":"https://api.github.com/users/amnonshmsft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amnonshmsft/subscriptions","organizations_url":"https://api.github.com/users/amnonshmsft/orgs","repos_url":"https://api.github.com/users/amnonshmsft/repos","events_url":"https://api.github.com/users/amnonshmsft/events{/privacy}","received_events_url":"https://api.github.com/users/amnonshmsft/received_events","type":"User","site_admin":false},"body":"For improved readability and cleaner code consider handling each key in its own function, i.e.\r\n\r\n    if (key.equalsIgnoreCase(INSTRUMENTATION_KEY_CONFIGURATION_KEY)) {\r\n        writerConfiguration.instrumentationKey = parseInstrumentationKey(child);\r\n    } else if (key.equalsIgnoreCase(SDK_LOGGER_CONFIGURATION_KEY)) {\r\n        writerConfiguration.isLoggerEnabled = parseIsLoggerEnabled(child);\r\n    } else if ...","created_at":"2015-05-14T19:07:02Z","updated_at":"2015-05-14T19:07:02Z","html_url":"https://github.com/Microsoft/ApplicationInsights-Java/pull/177#discussion_r30352138","pull_request_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls/177","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls/comments/30352138"},"html":{"href":"https://github.com/Microsoft/ApplicationInsights-Java/pull/177#discussion_r30352138"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls/177"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls/177","id":34706621,"html_url":"https://github.com/Microsoft/ApplicationInsights-Java/pull/177","diff_url":"https://github.com/Microsoft/ApplicationInsights-Java/pull/177.diff","patch_url":"https://github.com/Microsoft/ApplicationInsights-Java/pull/177.patch","issue_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/issues/177","number":177,"state":"open","locked":false,"title":"Writer implementation","user":{"login":"Yonisha","id":10218080,"avatar_url":"https://avatars.githubusercontent.com/u/10218080?v=3","gravatar_id":"","url":"https://api.github.com/users/Yonisha","html_url":"https://github.com/Yonisha","followers_url":"https://api.github.com/users/Yonisha/followers","following_url":"https://api.github.com/users/Yonisha/following{/other_user}","gists_url":"https://api.github.com/users/Yonisha/gists{/gist_id}","starred_url":"https://api.github.com/users/Yonisha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yonisha/subscriptions","organizations_url":"https://api.github.com/users/Yonisha/orgs","repos_url":"https://api.github.com/users/Yonisha/repos","events_url":"https://api.github.com/users/Yonisha/events{/privacy}","received_events_url":"https://api.github.com/users/Yonisha/received_events","type":"User","site_admin":false},"body":"Writer configuration schema (as part of CollectD configuration file):\r\nPerformance Counters - CollectD Integration - Adding an Application Insights writer:\r\n\r\n<Plugin ApplicationInsightsWriter>\r\n    InstrumetationKey 123-123-123-123-123\r\n    SDKLogger true\r\n    Exclude Plugin1:DataSource1,DataSource2 Plugin2 Plugin3:DataSource1","created_at":"2015-05-05T09:08:15Z","updated_at":"2015-05-14T19:07:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"41b1b0b031d97c8d2fc33d937c297fb824ca7263","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls/177/commits","review_comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls/177/comments","review_comment_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/issues/177/comments","statuses_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/statuses/e598676fc87ec9b008e74669b1af400da3c58065","head":{"label":"Microsoft:features/collectd","ref":"features/collectd","sha":"e598676fc87ec9b008e74669b1af400da3c58065","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","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":27460436,"name":"ApplicationInsights-Java","full_name":"Microsoft/ApplicationInsights-Java","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","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-Java","description":"Application Insights SDK for Java","fork":false,"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java","forks_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/forks","keys_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/teams","hooks_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/events","assignees_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/tags","blobs_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/languages","stargazers_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/subscription","commits_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/merges","archive_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/downloads","issues_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/releases{/id}","created_at":"2014-12-03T00:13:22Z","updated_at":"2015-05-07T20:35:36Z","pushed_at":"2015-05-14T14:27:56Z","git_url":"git://github.com/Microsoft/ApplicationInsights-Java.git","ssh_url":"git@github.com:Microsoft/ApplicationInsights-Java.git","clone_url":"https://github.com/Microsoft/ApplicationInsights-Java.git","svn_url":"https://github.com/Microsoft/ApplicationInsights-Java","homepage":"http://azure.microsoft.com/en-us/services/application-insights/","size":5602,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":8,"forks":3,"open_issues":8,"watchers":5,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"1a465592db5419dd9818f86b3f707f087d5f9fb3","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","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":27460436,"name":"ApplicationInsights-Java","full_name":"Microsoft/ApplicationInsights-Java","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","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-Java","description":"Application Insights SDK for Java","fork":false,"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java","forks_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/forks","keys_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/teams","hooks_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/events","assignees_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/tags","blobs_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/languages","stargazers_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/subscription","commits_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/merges","archive_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/downloads","issues_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/releases{/id}","created_at":"2014-12-03T00:13:22Z","updated_at":"2015-05-07T20:35:36Z","pushed_at":"2015-05-14T14:27:56Z","git_url":"git://github.com/Microsoft/ApplicationInsights-Java.git","ssh_url":"git@github.com:Microsoft/ApplicationInsights-Java.git","clone_url":"https://github.com/Microsoft/ApplicationInsights-Java.git","svn_url":"https://github.com/Microsoft/ApplicationInsights-Java","homepage":"http://azure.microsoft.com/en-us/services/application-insights/","size":5602,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":8,"forks":3,"open_issues":8,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls/177"},"html":{"href":"https://github.com/Microsoft/ApplicationInsights-Java/pull/177"},"issue":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/issues/177"},"comments":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/issues/177/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls/177/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/pulls/177/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-Java/statuses/e598676fc87ec9b008e74669b1af400da3c58065"}}}}