{"action":"opened","issue":{"url":"https://api.github.com/repos/rajinders/nlog-targets-azureeventhub/issues/5","repository_url":"https://api.github.com/repos/rajinders/nlog-targets-azureeventhub","labels_url":"https://api.github.com/repos/rajinders/nlog-targets-azureeventhub/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/rajinders/nlog-targets-azureeventhub/issues/5/comments","events_url":"https://api.github.com/repos/rajinders/nlog-targets-azureeventhub/issues/5/events","html_url":"https://github.com/rajinders/nlog-targets-azureeventhub/issues/5","id":166281663,"number":5,"title":"PartitionKey is not distributed in a round robin manner","user":{"login":"andrejohansson","id":2828428,"avatar_url":"https://avatars.githubusercontent.com/u/2828428?v=3","gravatar_id":"","url":"https://api.github.com/users/andrejohansson","html_url":"https://github.com/andrejohansson","followers_url":"https://api.github.com/users/andrejohansson/followers","following_url":"https://api.github.com/users/andrejohansson/following{/other_user}","gists_url":"https://api.github.com/users/andrejohansson/gists{/gist_id}","starred_url":"https://api.github.com/users/andrejohansson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrejohansson/subscriptions","organizations_url":"https://api.github.com/users/andrejohansson/orgs","repos_url":"https://api.github.com/users/andrejohansson/repos","events_url":"https://api.github.com/users/andrejohansson/events{/privacy}","received_events_url":"https://api.github.com/users/andrejohansson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-19T09:03:08Z","updated_at":"2016-07-19T09:03:08Z","closed_at":null,"body":"According to [this comment](https://github.com/rajinders/nlog-targets-azureeventhub/blob/master/src/NLog.Targets.AzureEventHub/AzureEventHubTarget.cs#L26) for the PartitionKey property the key should be distributed evenly using round robin if no partition key is set. \r\n\r\n```\r\n        /// <summary>\r\n        /// PartitionKey is optional. If no partition key is supplied the log messages are sent to eventhub\r\n        /// and distributed to various partitions in a round robin manner.\r\n        /// </summary>\r\n        public string PartitionKey { get; set; }\r\n```\r\n\r\nFrom what I can see there is, [no code](https://github.com/rajinders/nlog-targets-azureeventhub/blob/master/src/NLog.Targets.AzureEventHub/AzureEventHubTarget.cs#L54) doing anything with the key if it is not set?\r\n\r\n```\r\nusing (var eventHubData = new EventData(Encoding.UTF8.GetBytes(logMessage)) { PartitionKey = partitionKey })\r\n {\r\n                foreach (var key in logEvent.Properties.Keys)\r\n                {\r\n                    eventHubData.Properties.Add(key.ToString(), logEvent.Properties[key]);\r\n                }\r\n\r\n                await _eventHubClient.SendAsync(eventHubData);\r\n                return true;\r\n} \r\n```\r\n\r\nAs such the behaviour defaults back to whatever the [SendAsync](https://github.com/rajinders/nlog-targets-azureeventhub/blob/master/src/NLog.Targets.AzureEventHub/AzureEventHubTarget.cs#L61) method does with a blank partition key.\r\n\r\nAccording to the [MSDN documentation](https://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.eventhubclient.sendasync.aspx) it must have the partitionkey set.\r\n\r\n> Remarks\r\n> Any EventData instance send operation using this method must have the PartitionKey set.\r\n\r\nIn our case this leads to that we are only writing to one of the partitions all the time since the partitionkey is not changing and thus all scale advantages with the eventhub is gone."}}
{"actor":{"display_login":"andrejohansson"}}