| | 1 | | // Copyright (c) Microsoft. All rights reserved. |
| | 2 | | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| | 3 | |
|
| | 4 | | namespace Microsoft.Azure.EventHubs |
| | 5 | | { |
| | 6 | | using System; |
| | 7 | | using System.Diagnostics.Tracing; |
| | 8 | |
|
| | 9 | | /// <summary> |
| | 10 | | /// EventSource for Microsoft-Azure-EventHubs-Processor traces. |
| | 11 | | /// |
| | 12 | | /// When defining Start/Stop tasks, the StopEvent.Id must be exactly StartEvent.Id + 1. |
| | 13 | | /// |
| | 14 | | /// Do not explicity include the Guid here, since EventSource has a mechanism to automatically |
| | 15 | | /// map to an EventSource Guid based on the Name (Microsoft-Azure-EventHubs-Processor). |
| | 16 | | /// </summary> |
| | 17 | | [EventSource(Name = "Microsoft-Azure-EventHubs-Processor")] |
| | 18 | | internal class ProcessorEventSource : EventSource |
| | 19 | | { |
| 0 | 20 | | public static ProcessorEventSource Log { get; } = new ProcessorEventSource(); |
| | 21 | |
|
| 0 | 22 | | ProcessorEventSource() { } |
| | 23 | |
|
| | 24 | | // |
| | 25 | | // 1-50 reserved for EventProcessorHost traces |
| | 26 | | // |
| | 27 | | [Event(1, Level = EventLevel.Informational, Message = "{0}: created. EventHub: {1}.")] |
| | 28 | | public void EventProcessorHostCreated(string hostId, string path) |
| | 29 | | { |
| 0 | 30 | | if (IsEnabled()) |
| | 31 | | { |
| 0 | 32 | | WriteEvent(1, hostId, path); |
| | 33 | | } |
| 0 | 34 | | } |
| | 35 | |
|
| | 36 | | [Event(2, Level = EventLevel.Informational, Message = "{0}: closing.")] |
| | 37 | | public void EventProcessorHostCloseStart(string hostId) |
| | 38 | | { |
| 0 | 39 | | if (IsEnabled()) |
| | 40 | | { |
| 0 | 41 | | WriteEvent(2, hostId); |
| | 42 | | } |
| 0 | 43 | | } |
| | 44 | |
|
| | 45 | | [Event(3, Level = EventLevel.Informational, Message = "{0}: closed.")] |
| | 46 | | public void EventProcessorHostCloseStop(string hostId) |
| | 47 | | { |
| 0 | 48 | | if (IsEnabled()) |
| | 49 | | { |
| 0 | 50 | | WriteEvent(3, hostId); |
| | 51 | | } |
| 0 | 52 | | } |
| | 53 | |
|
| | 54 | | [Event(4, Level = EventLevel.Error, Message = "{0}: close failed: {1}.")] |
| | 55 | | public void EventProcessorHostCloseError(string hostId, string exception) |
| | 56 | | { |
| 0 | 57 | | if (IsEnabled()) |
| | 58 | | { |
| 0 | 59 | | WriteEvent(4, hostId, exception); |
| | 60 | | } |
| 0 | 61 | | } |
| | 62 | |
|
| | 63 | | [Event(5, Level = EventLevel.Informational, Message = "{0}: opening. Factory:{1}.")] |
| | 64 | | public void EventProcessorHostOpenStart(string hostId, string factoryType) |
| | 65 | | { |
| 0 | 66 | | if (IsEnabled()) |
| | 67 | | { |
| 0 | 68 | | WriteEvent(5, hostId, factoryType ?? string.Empty); |
| | 69 | | } |
| 0 | 70 | | } |
| | 71 | |
|
| | 72 | | [Event(6, Level = EventLevel.Informational, Message = "{0}: opened.")] |
| | 73 | | public void EventProcessorHostOpenStop(string hostId) |
| | 74 | | { |
| 0 | 75 | | if (IsEnabled()) |
| | 76 | | { |
| 0 | 77 | | WriteEvent(6, hostId); |
| | 78 | | } |
| 0 | 79 | | } |
| | 80 | |
|
| | 81 | | [Event(7, Level = EventLevel.Error, Message = "{0}: open failed: {1}.")] |
| | 82 | | public void EventProcessorHostOpenError(string hostId, string exception) |
| | 83 | | { |
| 0 | 84 | | if (IsEnabled()) |
| | 85 | | { |
| 0 | 86 | | WriteEvent(7, hostId, exception); |
| | 87 | | } |
| 0 | 88 | | } |
| | 89 | |
|
| | 90 | | [Event(8, Level = EventLevel.Informational, Message = "{0}: {1}")] |
| | 91 | | public void EventProcessorHostInfo(string hostId, string details) |
| | 92 | | { |
| 0 | 93 | | if (IsEnabled()) |
| | 94 | | { |
| 0 | 95 | | WriteEvent(8, hostId, details); |
| | 96 | | } |
| 0 | 97 | | } |
| | 98 | |
|
| | 99 | | [Event(9, Level = EventLevel.Warning, Message = "{0}: Warning: {1}. {2}")] |
| | 100 | | public void EventProcessorHostWarning(string hostId, string details, string exception) |
| | 101 | | { |
| 0 | 102 | | if (IsEnabled()) |
| | 103 | | { |
| 0 | 104 | | WriteEvent(9, hostId, details, exception ?? string.Empty); |
| | 105 | | } |
| 0 | 106 | | } |
| | 107 | |
|
| | 108 | | [Event(10, Level = EventLevel.Error, Message = "{0}: Error: {1}. {2}")] |
| | 109 | | public void EventProcessorHostError(string hostId, string details, string exception) |
| | 110 | | { |
| 0 | 111 | | if (IsEnabled()) |
| | 112 | | { |
| 0 | 113 | | WriteEvent(10, hostId, details, exception ?? string.Empty); |
| | 114 | | } |
| 0 | 115 | | } |
| | 116 | |
|
| | 117 | | // |
| | 118 | | // 51-100 reserved for PartitionPump traces |
| | 119 | | // |
| | 120 | | [Event(51, Level = EventLevel.Informational, Message = "{0}: Partition {1}: Pump closing. Reason:{2}.")] |
| | 121 | | public void PartitionPumpCloseStart(string hostId, string partitionId, string reason) |
| | 122 | | { |
| 0 | 123 | | if (IsEnabled()) |
| | 124 | | { |
| 0 | 125 | | WriteEvent(51, hostId, partitionId, reason); |
| | 126 | | } |
| 0 | 127 | | } |
| | 128 | |
|
| | 129 | | [Event(52, Level = EventLevel.Informational, Message = "{0}: Partition {1}: Pump closed.")] |
| | 130 | | public void PartitionPumpCloseStop(string hostId, string partitionId) |
| | 131 | | { |
| 0 | 132 | | if (IsEnabled()) |
| | 133 | | { |
| 0 | 134 | | WriteEvent(52, hostId, partitionId); |
| | 135 | | } |
| 0 | 136 | | } |
| | 137 | |
|
| | 138 | | [Event(53, Level = EventLevel.Error, Message = "{0}: Partition {1}: Pump close error: {2}.")] |
| | 139 | | public void PartitionPumpCloseError(string hostId, string partitionId, string exception) |
| | 140 | | { |
| 0 | 141 | | if (IsEnabled()) |
| | 142 | | { |
| 0 | 143 | | WriteEvent(53, hostId, partitionId, exception ?? string.Empty); |
| | 144 | | } |
| 0 | 145 | | } |
| | 146 | |
|
| | 147 | | [Event(54, Level = EventLevel.Informational, Message = "{0}: Partition {1}: Saving checkpoint at Offset:{2}/Sequ |
| | 148 | | public void PartitionPumpCheckpointStart(string hostId, string partitionId, string offset, long sequenceNumber) |
| | 149 | | { |
| 0 | 150 | | if (IsEnabled()) |
| | 151 | | { |
| 0 | 152 | | WriteEvent(54, hostId, partitionId, offset ?? string.Empty, sequenceNumber); |
| | 153 | | } |
| 0 | 154 | | } |
| | 155 | |
|
| | 156 | | [Event(55, Level = EventLevel.Informational, Message = "{0}: Partition {1}: Done saving checkpoint.")] |
| | 157 | | public void PartitionPumpCheckpointStop(string hostId, string partitionId) |
| | 158 | | { |
| 0 | 159 | | if (IsEnabled()) |
| | 160 | | { |
| 0 | 161 | | WriteEvent(55, hostId, partitionId); |
| | 162 | | } |
| 0 | 163 | | } |
| | 164 | |
|
| | 165 | | [Event(56, Level = EventLevel.Error, Message = "{0}: Partition {1}: Error saving checkpoint: {2}.")] |
| | 166 | | public void PartitionPumpCheckpointError(string hostId, string partitionId, string exception) |
| | 167 | | { |
| 0 | 168 | | if (IsEnabled()) |
| | 169 | | { |
| 0 | 170 | | WriteEvent(56, hostId, partitionId, exception ?? string.Empty); |
| | 171 | | } |
| 0 | 172 | | } |
| | 173 | |
|
| | 174 | | [Event(57, Level = EventLevel.Informational, Message = "{0}: Partition {1}: Creating EventHubClient and Partitio |
| | 175 | | public void PartitionPumpCreateClientsStart(string hostId, string partitionId, long epoch, string startAt) |
| | 176 | | { |
| 0 | 177 | | if (IsEnabled()) |
| | 178 | | { |
| 0 | 179 | | WriteEvent(57, hostId, partitionId, epoch, startAt ?? string.Empty); |
| | 180 | | } |
| 0 | 181 | | } |
| | 182 | |
|
| | 183 | | [Event(58, Level = EventLevel.Informational, Message = "{0}: Partition {1}: Done creating EventHubClient and Par |
| | 184 | | public void PartitionPumpCreateClientsStop(string hostId, string partitionId) |
| | 185 | | { |
| 0 | 186 | | if (IsEnabled()) |
| | 187 | | { |
| 0 | 188 | | WriteEvent(58, hostId, partitionId); |
| | 189 | | } |
| 0 | 190 | | } |
| | 191 | |
|
| | 192 | | [Event(59, Level = EventLevel.Informational, Message = "{0}: Partition {1}: IEventProcessor opening. Type: {2}." |
| | 193 | | public void PartitionPumpInvokeProcessorOpenStart(string hostId, string partitionId, string processorType) |
| | 194 | | { |
| 0 | 195 | | if (IsEnabled()) |
| | 196 | | { |
| 0 | 197 | | WriteEvent(59, hostId, partitionId, processorType); |
| | 198 | | } |
| 0 | 199 | | } |
| | 200 | |
|
| | 201 | | [Event(60, Level = EventLevel.Informational, Message = "{0}: Partition {1}: IEventProcessor opened.")] |
| | 202 | | public void PartitionPumpInvokeProcessorOpenStop(string hostId, string partitionId) |
| | 203 | | { |
| 0 | 204 | | if (IsEnabled()) |
| | 205 | | { |
| 0 | 206 | | WriteEvent(60, hostId, partitionId); |
| | 207 | | } |
| 0 | 208 | | } |
| | 209 | |
|
| | 210 | | [Event(61, Level = EventLevel.Informational, Message = "{0}: Partition {1}: IEventProcessor closing. Reason: {2} |
| | 211 | | public void PartitionPumpInvokeProcessorCloseStart(string hostId, string partitionId, string reason) |
| | 212 | | { |
| 0 | 213 | | if (IsEnabled()) |
| | 214 | | { |
| 0 | 215 | | WriteEvent(61, hostId, partitionId, reason); |
| | 216 | | } |
| 0 | 217 | | } |
| | 218 | |
|
| | 219 | | [Event(62, Level = EventLevel.Informational, Message = "{0}: Partition {1}: IEventProcessor closed.")] |
| | 220 | | public void PartitionPumpInvokeProcessorCloseStop(string hostId, string partitionId) |
| | 221 | | { |
| 0 | 222 | | if (IsEnabled()) |
| | 223 | | { |
| 0 | 224 | | WriteEvent(62, hostId, partitionId); |
| | 225 | | } |
| 0 | 226 | | } |
| | 227 | |
|
| | 228 | | [Event(63, Level = EventLevel.Informational, Message = "{0}: Partition {1}: Invoking IEventProcessor.ProcessEven |
| | 229 | | public void PartitionPumpInvokeProcessorEventsStart(string hostId, string partitionId, int eventCount) |
| | 230 | | { |
| 0 | 231 | | if (IsEnabled()) |
| | 232 | | { |
| 0 | 233 | | WriteEvent(63, hostId, partitionId, eventCount); |
| | 234 | | } |
| 0 | 235 | | } |
| | 236 | |
|
| | 237 | | [Event(64, Level = EventLevel.Informational, Message = "{0}: Partition {1}: Done invoking IEventProcessor.Proces |
| | 238 | | public void PartitionPumpInvokeProcessorEventsStop(string hostId, string partitionId) |
| | 239 | | { |
| 0 | 240 | | if (IsEnabled()) |
| | 241 | | { |
| 0 | 242 | | WriteEvent(64, hostId, partitionId); |
| | 243 | | } |
| 0 | 244 | | } |
| | 245 | |
|
| | 246 | | [Event(65, Level = EventLevel.Error, Message = "{0}: Partition {1}: Error invoking IEventProcessor.ProcessEvents |
| | 247 | | public void PartitionPumpInvokeProcessorEventsError(string hostId, string partitionId, string exception) |
| | 248 | | { |
| 0 | 249 | | if (IsEnabled()) |
| | 250 | | { |
| 0 | 251 | | WriteEvent(65, hostId, partitionId, exception); |
| | 252 | | } |
| 0 | 253 | | } |
| | 254 | |
|
| | 255 | | [Event(66, Level = EventLevel.Informational, Message = "{0}: Partition {1}: {2}")] |
| | 256 | | public void PartitionPumpInfo(string hostId, string partitionId, string details) |
| | 257 | | { |
| 0 | 258 | | if (IsEnabled()) |
| | 259 | | { |
| 0 | 260 | | WriteEvent(66, hostId, partitionId, details); |
| | 261 | | } |
| 0 | 262 | | } |
| | 263 | |
|
| | 264 | | [Event(67, Level = EventLevel.Warning, Message = "{0}: Partition {1}: Warning: {2} {3}")] |
| | 265 | | public void PartitionPumpWarning(string hostId, string partitionId, string details, string exception = null) |
| | 266 | | { |
| 0 | 267 | | if (IsEnabled()) |
| | 268 | | { |
| 0 | 269 | | WriteEvent(67, hostId, partitionId, details, exception ?? string.Empty); |
| | 270 | | } |
| 0 | 271 | | } |
| | 272 | |
|
| | 273 | | [Event(68, Level = EventLevel.Error, Message = "{0}: Partition {1}: Error: {2} {3}")] |
| | 274 | | public void PartitionPumpError(string hostId, string partitionId, string details, string exception = null) |
| | 275 | | { |
| 0 | 276 | | if (IsEnabled()) |
| | 277 | | { |
| 0 | 278 | | WriteEvent(68, hostId, partitionId, details, exception ?? string.Empty); |
| | 279 | | } |
| 0 | 280 | | } |
| | 281 | |
|
| | 282 | | [Event(69, Level = EventLevel.Informational, Message = "{0}: Partition {1}: Attempting to steal lease")] |
| | 283 | | public void PartitionPumpStealLeaseStart(string hostId, string partitionId) |
| | 284 | | { |
| 0 | 285 | | if (IsEnabled()) |
| | 286 | | { |
| 0 | 287 | | WriteEvent(69, hostId, partitionId); |
| | 288 | | } |
| 0 | 289 | | } |
| | 290 | |
|
| | 291 | | [Event(70, Level = EventLevel.Informational, Message = "{0}: Partition {1}: Steal lease succeeded")] |
| | 292 | | public void PartitionPumpStealLeaseStop(string hostId, string partitionId) |
| | 293 | | { |
| 0 | 294 | | if (IsEnabled()) |
| | 295 | | { |
| 0 | 296 | | WriteEvent(70, hostId, partitionId); |
| | 297 | | } |
| 0 | 298 | | } |
| | 299 | |
|
| | 300 | | // |
| | 301 | | // 101-150 reserved for AzureStorageManager traces |
| | 302 | | // |
| | 303 | | [Event(101, Level = EventLevel.Informational, Message = "{0}: Partition {1}: AzureStorage: {2}")] |
| | 304 | | public void AzureStorageManagerInfo(string hostId, string partitionId, string details) |
| | 305 | | { |
| 0 | 306 | | if (IsEnabled()) |
| | 307 | | { |
| 0 | 308 | | WriteEvent(101, hostId, partitionId, details); |
| | 309 | | } |
| 0 | 310 | | } |
| | 311 | |
|
| | 312 | | [Event(102, Level = EventLevel.Warning, Message = "{0}: Partition {1}: AzureStorage Warning: {2} {3}")] |
| | 313 | | public void AzureStorageManagerWarning(string hostId, string partitionId, string details, string exception) |
| | 314 | | { |
| 0 | 315 | | if (IsEnabled()) |
| | 316 | | { |
| 0 | 317 | | WriteEvent(102, hostId, partitionId, details, exception ?? string.Empty); |
| | 318 | | } |
| 0 | 319 | | } |
| | 320 | |
|
| | 321 | | [Event(103, Level = EventLevel.Error, Message = "{0}: Partition {1}: AzureStorage Error: {2} {3}")] |
| | 322 | | public void AzureStorageManagerError(string hostId, string partitionId, string details, string exception) |
| | 323 | | { |
| 0 | 324 | | if (IsEnabled()) |
| | 325 | | { |
| 0 | 326 | | WriteEvent(103, hostId, partitionId, details, exception); |
| | 327 | | } |
| 0 | 328 | | } |
| | 329 | |
|
| | 330 | | // TODO: Add Keywords if desired. |
| | 331 | | //public class Keywords // This is a bitvector |
| | 332 | | //{ |
| | 333 | | // public const EventKeywords Amqp = (EventKeywords)0x0001; |
| | 334 | | // public const EventKeywords Debug = (EventKeywords)0x0002; |
| | 335 | | //} |
| | 336 | | } |
| | 337 | | } |