-
Notifications
You must be signed in to change notification settings - Fork 1
Integration EventHubs Extension
Track Azure Event Hubs operations in your test diagrams using the TestTrackingDiagrams.Extensions.EventHubs NuGet package. This extension wraps EventHubProducerClient and EventHubConsumerClient to intercept send/receive operations.
Using a shared library or abstraction layer? If your code doesn't use the Event Hubs SDK directly — e.g. it goes through MassTransit, a shared messaging library, or a custom abstraction — see the MassTransit Extension or Tracking Custom Dependencies for alternative approaches including
MessageTrackerandTrackingProxy<T>.
dotnet add package TestTrackingDiagrams.Extensions.EventHubs
using Azure.Messaging.EventHubs.Producer;
using TestTrackingDiagrams.Extensions.EventHubs;
var options = new EventHubsTrackingOptions
{
ServiceName = "EventHubs",
CallingServiceName = "OrdersApi",
Verbosity = EventHubsTrackingVerbosity.Detailed,
CurrentTestInfoFetcher = () => (TestContext.CurrentTestName, TestContext.CurrentTestId)
};
var innerClient = new EventHubProducerClient(connectionString, eventHubName);
var producer = new TrackingEventHubProducerClient(innerClient, options);
await producer.SendAsync(new[] { new EventData("order-created") });Azure Event Hubs uses AMQP internally and does not expose an HTTP DelegatingHandler pipeline. Like the Service Bus and Pub/Sub extensions, this extension uses the wrapper/decorator pattern — standalone classes that wrap the SDK client and intercept method calls.
The EventHubsTracker (central logging helper) handles all request/response logging with RequestResponseMetaType.Event for async messaging notation in PlantUML diagrams.
| Operation | Enum Value | Source |
|---|---|---|
| Send | EventHubsOperation.Send |
Single event via SendAsync
|
| SendBatch | EventHubsOperation.SendBatch |
Multiple events via SendAsync
|
| CreateBatch | EventHubsOperation.CreateBatch |
CreateBatchAsync |
| ReadEvents | EventHubsOperation.ReadEvents |
ReadEventsAsync |
| ReadEventsFromPartition | EventHubsOperation.ReadEventsFromPartition |
ReadEventsFromPartitionAsync |
| GetPartitionIds | EventHubsOperation.GetPartitionIds |
GetPartitionIdsAsync |
| GetEventHubProperties | EventHubsOperation.GetEventHubProperties |
GetEventHubPropertiesAsync |
| GetPartitionProperties | EventHubsOperation.GetPartitionProperties |
GetPartitionPropertiesAsync |
| StartProcessing | EventHubsOperation.StartProcessing |
StartProcessingAsync |
| StopProcessing | EventHubsOperation.StopProcessing |
StopProcessingAsync |
| ProcessEvent | EventHubsOperation.ProcessEvent |
Event handler callback |
Wraps EventHubProducerClient:
-
SendAsync(IEnumerable<EventData>)— tracks single/batch sends -
SendAsync(IEnumerable<EventData>, SendEventOptions)— tracks with partition key -
SendAsync(EventDataBatch)— tracks batch sends -
CreateBatchAsync()— delegates without tracking -
CloseAsync()— delegates without tracking -
Innerproperty for direct access to the underlying client
Wraps EventHubConsumerClient:
-
ReadEventsAsync()— logs start, yields events, logs completion -
ReadEventsFromPartitionAsync()— logs with partition ID -
GetPartitionIdsAsync()— delegates directly -
CloseAsync()— delegates without tracking -
Innerproperty for direct access
-
Label: Operation name (e.g.
Send) - Content: Omitted
-
URI:
eventhubs:///hub-name
-
Label: Contextual (e.g.
Send → telemetry,Read ← telemetry[2]) - Content: Event body included
-
URI:
eventhubs:///hub-name/partition-idwhen applicable
-
Label: Full details (e.g.
Send hub=telemetry partition=1 count=3) - Content: Full event data
-
URI:
eventhubs:///hub-name/partition-id
new EventHubsTrackingOptions
{
ServiceName = "EventHubs",
CallingServiceName = "OrdersApi",
Verbosity = EventHubsTrackingVerbosity.Detailed,
CurrentTestInfoFetcher = () => (testName, testId),
}EventHubsTracker implements ITrackingComponent and auto-registers with TrackingComponentRegistry. This provides:
-
ComponentName:"EventHubsTracker ({ServiceName})" -
WasInvoked:trueafter first operation -
InvocationCount: Total operations tracked
eventhubs:///telemetry (hub-level operations)
eventhubs:///telemetry/2 (partition-specific operations)
Getting Started
Common Tasks
Integration Guides
- Integration xUnit3
- Integration xUnit2
- Integration NUnit
- Integration MSTest
- Integration TUnit
- Integration BDDfy xUnit3
- Integration LightBDD xUnit2
- Integration LightBDD xUnit3
- Integration LightBDD TUnit
- Integration ReqNRoll xUnit2
- Integration ReqNRoll xUnit3
- Integration ReqNRoll TUnit
Extensions
- Integration AtlasDataApi Extension
- Integration BigQuery Extension
- Integration Bigtable Extension
- Integration BlobStorage Extension
- Integration ClickHouse Extension
- Integration CloudStorage Extension
- Integration CosmosDB Extension
- Integration Dapper Extension
- Integration DynamoDB Extension
- Integration EF Core Relational Extension
- Integration Elasticsearch Extension
- Integration EventBridge Extension
- Integration EventHubs Extension
- Integration Grpc Extension
- Integration Kafka Extension
- Integration MassTransit Extension
- Integration MongoDB Extension
- Integration MySqlConnector Extension
- Integration Npgsql Extension
- Integration Oracle Extension
- Integration PubSub Extension
- Integration Redis Extension
- Integration S3 Extension
- Integration ServiceBus Extension
- Integration SNS Extension
- Integration Spanner Extension
- Integration SqlClient Extension
- Integration Sqlite Extension
- Integration SQS Extension
- Integration StorageQueues Extension
- Integration OpenTelemetry Extension
- Integration DispatchProxy Extension
- Integration MediatR Extension
- Integration PlantUML IKVM
Configuration
- Tracking Dependencies
- Tracking Custom Dependencies
- HTTP Tracking Setup
- Report Configuration
- Diagram Customisation
- Phase-Aware Tracking
- Content Formatting
- PlantUML Server Configuration
Features
- Generated Reports
- Search Syntax
- Component Diagrams
- PlantUML Browser Rendering
- Inline SVG Rendering
- Internal Flow Tracking
- Tags and Attributes
- Excluding Requests
- Excluded Headers
- Multi-Host Test Architectures
- Event-Driven Architecture Testing
- Service Bus Tracking Patterns
- Background Thread Correlation
- Parallel-Safe Background Correlation
- Event & Message Tracking
- Assertion Tracking
- Step Tracking
- Tabular Attributes
- Large Response and Diagram Handling
- Diagnostics and Debugging
- CI Summary Integration
- CI Artifact Upload
- Merging Parallel Reports
Reference