| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.Diagnostics.Tracing; |
| | 5 | | using Azure.Core.Diagnostics; |
| | 6 | |
|
| | 7 | | namespace Azure.Messaging.EventHubs.Processor.Diagnostics |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// EventSource for Azure-Messaging-EventHubs-Processor-BlobEventStore traces. |
| | 11 | | /// </summary> |
| | 12 | | /// |
| | 13 | | /// <remarks> |
| | 14 | | /// When defining Start/Stop tasks, the StopEvent.Id must be exactly StartEvent.Id + 1. |
| | 15 | | /// |
| | 16 | | /// Do not explicitly include the Guid here, since EventSource has a mechanism to automatically |
| | 17 | | /// map to an EventSource Guid based on the Name (Azure-Messaging-EventHubs-Processor-BlobEventStore). |
| | 18 | | /// </remarks> |
| | 19 | | /// |
| | 20 | | [EventSource(Name = EventSourceName)] |
| | 21 | | internal class BlobEventStoreEventSource : EventSource |
| | 22 | | { |
| | 23 | | /// <summary>The name to use for the event source.</summary> |
| | 24 | | private const string EventSourceName = "Azure-Messaging-EventHubs-Processor-BlobEventStore"; |
| | 25 | |
|
| | 26 | | /// <summary> |
| | 27 | | /// Provides a singleton instance of the event source for callers to |
| | 28 | | /// use for logging. |
| | 29 | | /// </summary> |
| | 30 | | /// |
| 138 | 31 | | public static BlobEventStoreEventSource Log { get; } = new BlobEventStoreEventSource(EventSourceName); |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// Prevents an instance of the <see cref="BlobEventStoreEventSource"/> class from being created |
| | 35 | | /// outside the scope of this library. Exposed for testing purposes only. |
| | 36 | | /// </summary> |
| | 37 | | /// |
| 36 | 38 | | protected BlobEventStoreEventSource() |
| | 39 | | { |
| 36 | 40 | | } |
| | 41 | |
|
| | 42 | | /// <summary> |
| | 43 | | /// Prevents an instance of the <see cref="BlobEventStoreEventSource"/> class from being created |
| | 44 | | /// outside the scope of this library. Exposed for testing purposes only. |
| | 45 | | /// </summary> |
| | 46 | | /// |
| | 47 | | /// <param name="eventSourceName">The name to assign to the event source.</param> |
| | 48 | | /// |
| 2 | 49 | | private BlobEventStoreEventSource(string eventSourceName) : base(eventSourceName, EventSourceSettings.Default, A |
| | 50 | | { |
| 2 | 51 | | } |
| | 52 | |
|
| | 53 | | /// <summary> |
| | 54 | | /// Indicates that a <see cref="BlobsCheckpointStore" /> was created. |
| | 55 | | /// </summary> |
| | 56 | | /// |
| | 57 | | /// <param name="typeName">The type name for the checkpoint store.</param> |
| | 58 | | /// <param name="accountName">The Storage account name corresponding to the associated container client.</param> |
| | 59 | | /// <param name="containerName">The name of the associated container client.</param> |
| | 60 | | /// |
| | 61 | | [Event(20, Level = EventLevel.Verbose, Message = "{0} created. AccountName: '{1}'; ContainerName: '{2}'.")] |
| | 62 | | public virtual void BlobsCheckpointStoreCreated(string typeName, |
| | 63 | | string accountName, |
| | 64 | | string containerName) |
| | 65 | | { |
| 132 | 66 | | if (IsEnabled()) |
| | 67 | | { |
| 0 | 68 | | WriteEvent(20, typeName, accountName ?? string.Empty, containerName ?? string.Empty); |
| | 69 | | } |
| 132 | 70 | | } |
| | 71 | |
|
| | 72 | | /// <summary> |
| | 73 | | /// Indicates that an attempt to retrieve a list of ownership has started. |
| | 74 | | /// </summary> |
| | 75 | | /// |
| | 76 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership are associated |
| | 77 | | /// <param name="eventHubName">The name of the specific Event Hub the ownership are associated with, relative to |
| | 78 | | /// <param name="consumerGroup">The name of the consumer group the ownership are associated with.</param> |
| | 79 | | /// |
| | 80 | | [Event(21, Level = EventLevel.Informational, Message = "Starting to list ownership for FullyQualifiedNamespace: |
| | 81 | | public virtual void ListOwnershipStart(string fullyQualifiedNamespace, |
| | 82 | | string eventHubName, |
| | 83 | | string consumerGroup) |
| | 84 | | { |
| 12 | 85 | | if (IsEnabled()) |
| | 86 | | { |
| 0 | 87 | | WriteEvent(21, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? string.Empty, consumerGroup ?? s |
| | 88 | | } |
| 12 | 89 | | } |
| | 90 | |
|
| | 91 | | /// <summary> |
| | 92 | | /// Indicates that an attempt to retrieve a list of ownership has completed. |
| | 93 | | /// </summary> |
| | 94 | | /// |
| | 95 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership are associated |
| | 96 | | /// <param name="eventHubName">The name of the specific Event Hub the ownership are associated with, relative to |
| | 97 | | /// <param name="consumerGroup">The name of the consumer group the ownership are associated with.</param> |
| | 98 | | /// <param name="ownershipCount">The amount of ownership received from the storage service.</param> |
| | 99 | | /// |
| | 100 | | [Event(22, Level = EventLevel.Informational, Message = "Completed listing ownership for FullyQualifiedNamespace: |
| | 101 | | public virtual void ListOwnershipComplete(string fullyQualifiedNamespace, |
| | 102 | | string eventHubName, |
| | 103 | | string consumerGroup, |
| | 104 | | int ownershipCount) |
| | 105 | | { |
| 12 | 106 | | if (IsEnabled()) |
| | 107 | | { |
| 0 | 108 | | WriteEvent(22, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? string.Empty, consumerGroup ?? s |
| | 109 | | } |
| 12 | 110 | | } |
| | 111 | |
|
| | 112 | | /// <summary> |
| | 113 | | /// Indicates that an unhandled exception was encountered while retrieving a list of ownership. |
| | 114 | | /// </summary> |
| | 115 | | /// |
| | 116 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership are associated |
| | 117 | | /// <param name="eventHubName">The name of the specific Event Hub the ownership are associated with, relative to |
| | 118 | | /// <param name="consumerGroup">The name of the consumer group the ownership are associated with.</param> |
| | 119 | | /// <param name="errorMessage">The message for the exception that occurred.</param> |
| | 120 | | /// |
| | 121 | | [Event(23, Level = EventLevel.Error, Message = "An exception occurred when listing ownership for FullyQualifiedN |
| | 122 | | public virtual void ListOwnershipError(string fullyQualifiedNamespace, |
| | 123 | | string eventHubName, |
| | 124 | | string consumerGroup, |
| | 125 | | string errorMessage) |
| | 126 | | { |
| 0 | 127 | | if (IsEnabled()) |
| | 128 | | { |
| 0 | 129 | | WriteEvent(23, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? string.Empty, consumerGroup ?? s |
| | 130 | | } |
| 0 | 131 | | } |
| | 132 | |
|
| | 133 | | /// <summary> |
| | 134 | | /// Indicates that an attempt to claim a partition ownership has started. |
| | 135 | | /// </summary> |
| | 136 | | /// |
| | 137 | | /// <param name="partitionId">The identifier of the partition being claimed.</param> |
| | 138 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership is associated w |
| | 139 | | /// <param name="eventHubName">The name of the specific Event Hub the ownership is associated with, relative to |
| | 140 | | /// <param name="consumerGroup">The name of the consumer group the ownership is associated with.</param> |
| | 141 | | /// <param name="ownerIdentifier">The identifier of the processor that attempted to claim the ownership for.</pa |
| | 142 | | /// |
| | 143 | | [Event(24, Level = EventLevel.Informational, Message = "Starting to claim ownership of partition: `{0}` of Fully |
| | 144 | | public virtual void ClaimOwnershipStart(string partitionId, |
| | 145 | | string fullyQualifiedNamespace, |
| | 146 | | string eventHubName, |
| | 147 | | string consumerGroup, |
| | 148 | | string ownerIdentifier) |
| | 149 | | { |
| 24 | 150 | | if (IsEnabled()) |
| | 151 | | { |
| 0 | 152 | | WriteEvent(24, partitionId ?? string.Empty, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? str |
| | 153 | | } |
| 24 | 154 | | } |
| | 155 | |
|
| | 156 | | /// <summary> |
| | 157 | | /// Indicates that an attempt to retrieve claim partition ownership has completed. |
| | 158 | | /// </summary> |
| | 159 | | /// |
| | 160 | | /// <param name="partitionId">The identifier of the partition being claimed.</param> |
| | 161 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership is associated w |
| | 162 | | /// <param name="eventHubName">The name of the specific Event Hub the ownership is associated with, relative to |
| | 163 | | /// <param name="consumerGroup">The name of the consumer group the ownership is associated with.</param> |
| | 164 | | /// <param name="ownerIdentifier">The identifier of the processor that attempted to claim the ownership for.</pa |
| | 165 | | /// |
| | 166 | | [Event(25, Level = EventLevel.Informational, Message = "Completed the attempt to claim ownership of partition: ` |
| | 167 | | public virtual void ClaimOwnershipComplete(string partitionId, |
| | 168 | | string fullyQualifiedNamespace, |
| | 169 | | string eventHubName, |
| | 170 | | string consumerGroup, |
| | 171 | | string ownerIdentifier) |
| | 172 | | { |
| 24 | 173 | | if (IsEnabled()) |
| | 174 | | { |
| 0 | 175 | | WriteEvent(25, partitionId ?? string.Empty, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? str |
| | 176 | | } |
| 24 | 177 | | } |
| | 178 | |
|
| | 179 | | /// <summary> |
| | 180 | | /// Indicates that an exception was encountered while attempting to retrieve claim partition ownership. |
| | 181 | | /// </summary> |
| | 182 | | /// |
| | 183 | | /// <param name="partitionId">The identifier of the partition being claimed.</param> |
| | 184 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership is associated w |
| | 185 | | /// <param name="eventHubName">The name of the specific Event Hub the ownership is associated with, relative to |
| | 186 | | /// <param name="consumerGroup">The name of the consumer group the ownership is associated with.</param> |
| | 187 | | /// <param name="ownerIdentifier">The identifier of the processor that attempted to claim the ownership for.</pa |
| | 188 | | /// <param name="errorMessage">The message for the exception that occurred.</param> |
| | 189 | | /// |
| | 190 | | [Event(26, Level = EventLevel.Error, Message = "An exception occurred when claiming ownership of partition: `{0} |
| | 191 | | public virtual void ClaimOwnershipError(string partitionId, |
| | 192 | | string fullyQualifiedNamespace, |
| | 193 | | string eventHubName, |
| | 194 | | string consumerGroup, |
| | 195 | | string ownerIdentifier, |
| | 196 | | string errorMessage) |
| | 197 | | { |
| 20 | 198 | | if (IsEnabled()) |
| | 199 | | { |
| 0 | 200 | | WriteEvent(26, partitionId ?? string.Empty, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? str |
| | 201 | | } |
| 20 | 202 | | } |
| | 203 | |
|
| | 204 | | /// <summary> |
| | 205 | | /// Indicates that ownership was unable to be claimed. |
| | 206 | | /// </summary> |
| | 207 | | /// |
| | 208 | | /// <param name="partitionId">The identifier of the partition being claimed.</param> |
| | 209 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership is associated w |
| | 210 | | /// <param name="eventHubName">The name of the specific Event Hub the ownership is associated with, relative to |
| | 211 | | /// <param name="consumerGroup">The name of the consumer group the ownership is associated with.</param> |
| | 212 | | /// <param name="ownerIdentifier">The identifier of the processor that attempted to claim the ownership for.</pa |
| | 213 | | /// <param name="message">The message for the failure.</param> |
| | 214 | | /// |
| | 215 | | [Event(27, Level = EventLevel.Informational, Message = "Unable to claim ownership of partition: `{0}` of FullyQu |
| | 216 | | public virtual void OwnershipNotClaimable(string partitionId, |
| | 217 | | string fullyQualifiedNamespace, |
| | 218 | | string eventHubName, |
| | 219 | | string consumerGroup, |
| | 220 | | string ownerIdentifier, |
| | 221 | | string message) |
| | 222 | | { |
| 2 | 223 | | if (IsEnabled()) |
| | 224 | | { |
| 0 | 225 | | WriteEvent(27, partitionId ?? string.Empty, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? str |
| | 226 | | } |
| 2 | 227 | | } |
| | 228 | |
|
| | 229 | | /// <summary> |
| | 230 | | /// Indicates that ownership was successfully claimed. |
| | 231 | | /// </summary> |
| | 232 | | /// |
| | 233 | | /// <param name="partitionId">The identifier of the partition being claimed.</param> |
| | 234 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership is associated w |
| | 235 | | /// <param name="eventHubName">The name of the specific Event Hub the ownership is associated with, relative to |
| | 236 | | /// <param name="consumerGroup">The name of the consumer group the ownership is associated with.</param> |
| | 237 | | /// <param name="ownerIdentifier">The identifier of the processor that attempted to claim the ownership for.</pa |
| | 238 | | /// |
| | 239 | | [Event(28, Level = EventLevel.Informational, Message = "Successfully claimed ownership of partition: `{0}` of Fu |
| | 240 | | public virtual void OwnershipClaimed(string partitionId, |
| | 241 | | string fullyQualifiedNamespace, |
| | 242 | | string eventHubName, |
| | 243 | | string consumerGroup, |
| | 244 | | string ownerIdentifier) |
| | 245 | | { |
| 2 | 246 | | if (IsEnabled()) |
| | 247 | | { |
| 0 | 248 | | WriteEvent(28, partitionId ?? string.Empty, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? str |
| | 249 | | } |
| 2 | 250 | | } |
| | 251 | |
|
| | 252 | | /// <summary> |
| | 253 | | /// Indicates that an attempt to retrieve a list of checkpoints has started. |
| | 254 | | /// </summary> |
| | 255 | | /// |
| | 256 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the checkpoints are associate |
| | 257 | | /// <param name="eventHubName">The name of the specific Event Hub the checkpoints are associated with, relative |
| | 258 | | /// <param name="consumerGroup">The name of the consumer group the checkpoints are associated with.</param> |
| | 259 | | /// |
| | 260 | | [Event(29, Level = EventLevel.Informational, Message = "Starting to list checkpoints for FullyQualifiedNamespace |
| | 261 | | public virtual void ListCheckpointsStart(string fullyQualifiedNamespace, |
| | 262 | | string eventHubName, |
| | 263 | | string consumerGroup) |
| | 264 | | { |
| 16 | 265 | | if (IsEnabled()) |
| | 266 | | { |
| 0 | 267 | | WriteEvent(29, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? string.Empty, consumerGroup ?? s |
| | 268 | | } |
| 16 | 269 | | } |
| | 270 | |
|
| | 271 | | /// <summary> |
| | 272 | | /// Indicates that an attempt to retrieve a list of checkpoints has completed. |
| | 273 | | /// </summary> |
| | 274 | | /// |
| | 275 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the checkpoints are associate |
| | 276 | | /// <param name="eventHubName">The name of the specific Event Hub the checkpoints are associated with, relative |
| | 277 | | /// <param name="consumerGroup">The name of the consumer group the checkpoints are associated with.</param> |
| | 278 | | /// <param name="checkpointCount">The amount of checkpoints received from the storage service.</param> |
| | 279 | | /// |
| | 280 | | [Event(30, Level = EventLevel.Informational, Message = "Completed listing checkpoints for FullyQualifiedNamespac |
| | 281 | | public virtual void ListCheckpointsComplete(string fullyQualifiedNamespace, |
| | 282 | | string eventHubName, |
| | 283 | | string consumerGroup, |
| | 284 | | int checkpointCount) |
| | 285 | | { |
| 16 | 286 | | if (IsEnabled()) |
| | 287 | | { |
| 0 | 288 | | WriteEvent(30, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? string.Empty, consumerGroup ?? s |
| | 289 | | } |
| 16 | 290 | | } |
| | 291 | |
|
| | 292 | | /// <summary> |
| | 293 | | /// Indicates that an unhandled exception was encountered while retrieving a list of checkpoints. |
| | 294 | | /// </summary> |
| | 295 | | /// |
| | 296 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the checkpoints are associate |
| | 297 | | /// <param name="eventHubName">The name of the specific Event Hub the checkpoints are associated with, relative |
| | 298 | | /// <param name="consumerGroup">The name of the consumer group the ownership are associated with.</param> |
| | 299 | | /// <param name="errorMessage">The message for the exception that occurred.</param> |
| | 300 | | /// |
| | 301 | | [Event(31, Level = EventLevel.Error, Message = "An exception occurred when listing checkpoints for FullyQualifie |
| | 302 | | public virtual void ListCheckpointsError(string fullyQualifiedNamespace, |
| | 303 | | string eventHubName, |
| | 304 | | string consumerGroup, |
| | 305 | | string errorMessage) |
| | 306 | | { |
| 10 | 307 | | if (IsEnabled()) |
| | 308 | | { |
| 0 | 309 | | WriteEvent(31, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? string.Empty, consumerGroup ?? s |
| | 310 | | } |
| 10 | 311 | | } |
| | 312 | |
|
| | 313 | | /// <summary> |
| | 314 | | /// Indicates that an attempt to create/update a checkpoint has started. |
| | 315 | | /// </summary> |
| | 316 | | /// |
| | 317 | | /// <param name="partitionId">The identifier of the partition being checkpointed.</param> |
| | 318 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the checkpoint is associated |
| | 319 | | /// <param name="eventHubName">The name of the specific Event Hub the checkpoint is associated with, relative to |
| | 320 | | /// <param name="consumerGroup">The name of the consumer group the checkpoint is associated with.</param> |
| | 321 | | /// |
| | 322 | | [Event(32, Level = EventLevel.Informational, Message = "Starting to create/update a checkpoint for partition: `{ |
| | 323 | | public virtual void UpdateCheckpointStart(string partitionId, |
| | 324 | | string fullyQualifiedNamespace, |
| | 325 | | string eventHubName, |
| | 326 | | string consumerGroup) |
| | 327 | | { |
| 24 | 328 | | if (IsEnabled()) |
| | 329 | | { |
| 0 | 330 | | WriteEvent(32, partitionId ?? string.Empty, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? str |
| | 331 | | } |
| 24 | 332 | | } |
| | 333 | |
|
| | 334 | | /// <summary> |
| | 335 | | /// Indicates that an attempt to update a checkpoint has completed. |
| | 336 | | /// </summary> |
| | 337 | | /// |
| | 338 | | /// <param name="partitionId">The identifier of the partition being checkpointed.</param> |
| | 339 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the checkpoint is associated |
| | 340 | | /// <param name="eventHubName">The name of the specific Event Hub the checkpoint is associated with, relative to |
| | 341 | | /// <param name="consumerGroup">The name of the consumer group the checkpoint is associated with.</param> |
| | 342 | | /// |
| | 343 | | [Event(33, Level = EventLevel.Informational, Message = "Completed the attempt to create/update a checkpoint for |
| | 344 | | public virtual void UpdateCheckpointComplete(string partitionId, |
| | 345 | | string fullyQualifiedNamespace, |
| | 346 | | string eventHubName, |
| | 347 | | string consumerGroup) |
| | 348 | | { |
| 24 | 349 | | if (IsEnabled()) |
| | 350 | | { |
| 0 | 351 | | WriteEvent(33, partitionId ?? string.Empty, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? str |
| | 352 | | } |
| 24 | 353 | | } |
| | 354 | |
|
| | 355 | | /// <summary> |
| | 356 | | /// Indicates that an unhandled exception was encountered while updating a checkpoint. |
| | 357 | | /// </summary> |
| | 358 | | /// |
| | 359 | | /// <param name="partitionId">The identifier of the partition being checkpointed.</param> |
| | 360 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the checkpoint is associated |
| | 361 | | /// <param name="eventHubName">The name of the specific Event Hub the checkpoint is associated with, relative to |
| | 362 | | /// <param name="consumerGroup">The name of the consumer group the checkpoint is associated with.</param> |
| | 363 | | /// <param name="errorMessage">The message for the exception that occurred.</param> |
| | 364 | | /// |
| | 365 | | [Event(34, Level = EventLevel.Error, Message = "An exception occurred when creating/updating a checkpoint for p |
| | 366 | | public virtual void UpdateCheckpointError(string partitionId, |
| | 367 | | string fullyQualifiedNamespace, |
| | 368 | | string eventHubName, |
| | 369 | | string consumerGroup, |
| | 370 | | string errorMessage) |
| | 371 | | { |
| 20 | 372 | | if (IsEnabled()) |
| | 373 | | { |
| 0 | 374 | | WriteEvent(34, partitionId ?? string.Empty, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? str |
| | 375 | | } |
| 20 | 376 | | } |
| | 377 | |
|
| | 378 | | /// <summary> |
| | 379 | | /// Indicates that invalid checkpoint data was found during an attempt to retrieve a list of checkpoints. |
| | 380 | | /// </summary> |
| | 381 | | /// |
| | 382 | | /// <param name="partitionId">The identifier of the partition the data is associated with.</param> |
| | 383 | | /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the data is associated with. |
| | 384 | | /// <param name="eventHubName">The name of the specific Event Hub the data is associated with, relative to the E |
| | 385 | | /// <param name="consumerGroup">The name of the consumer group the data is associated with.</param> |
| | 386 | | /// |
| | 387 | | [Event(35, Level = EventLevel.Warning, Message = "An invalid checkpoint was found for partition: '{0}' of FullyQ |
| | 388 | | public virtual void InvalidCheckpointFound(string partitionId, |
| | 389 | | string fullyQualifiedNamespace, |
| | 390 | | string eventHubName, |
| | 391 | | string consumerGroup) |
| | 392 | | { |
| 0 | 393 | | if (IsEnabled()) |
| | 394 | | { |
| 0 | 395 | | WriteEvent(35, partitionId ?? string.Empty, fullyQualifiedNamespace ?? string.Empty, eventHubName ?? str |
| | 396 | | } |
| 0 | 397 | | } |
| | 398 | | } |
| | 399 | | } |