-
Notifications
You must be signed in to change notification settings - Fork 1
Integration SQS Extension
Track Amazon SQS operations in your test diagrams using the Kronikol.Extensions.SQS NuGet package. This extension intercepts SQS HTTP traffic via the AWS SDK's HttpClientFactory pipeline and logs operations for diagram generation.
Using a shared library or abstraction layer? If your code doesn't use the SQS 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 Kronikol.Extensions.SQS
using Amazon.SQS;
using Kronikol.Extensions.SQS;
var config = new AmazonSQSConfig
{
RegionEndpoint = Amazon.RegionEndpoint.EUWest1
}
.WithTestTracking(new SqsTrackingMessageHandlerOptions
{
ServiceName = "SQS",
CallerName = "OrdersApi",
Verbosity = SqsTrackingVerbosity.Detailed,
CurrentTestInfoFetcher = () => (TestContext.CurrentTestName, TestContext.CurrentTestId)
});
var client = new AmazonSQSClient(config);The extension uses the same DelegatingHandler pattern as the S3 and DynamoDB extensions. WithTestTracking() injects a SqsTrackingMessageHandler via AmazonSQSConfig.HttpClientFactory, intercepting all HTTP requests made by the SQS SDK.
The handler:
- Reads and classifies each request using
SqsOperationClassifier - Reconstructs the request body so downstream processing is unaffected
- Logs request/response pairs via
RequestResponseLogger
SQS supports two protocols:
| Protocol | Detection | Example |
|---|---|---|
| JSON (modern) |
X-Amz-Target: AmazonSQS.{Operation} header |
AmazonSQS.SendMessage |
| Query (legacy) |
Action={Operation} parameter in query string or form body |
Action=ReceiveMessage |
Both protocols are fully supported by the classifier.
| Operation | Enum Value |
|---|---|
| SendMessage | SqsOperation.SendMessage |
| SendMessageBatch | SqsOperation.SendMessageBatch |
| ReceiveMessage | SqsOperation.ReceiveMessage |
| DeleteMessage | SqsOperation.DeleteMessage |
| DeleteMessageBatch | SqsOperation.DeleteMessageBatch |
| ChangeMessageVisibility | SqsOperation.ChangeMessageVisibility |
| ChangeMessageVisibilityBatch | SqsOperation.ChangeMessageVisibilityBatch |
| CreateQueue | SqsOperation.CreateQueue |
| DeleteQueue | SqsOperation.DeleteQueue |
| GetQueueUrl | SqsOperation.GetQueueUrl |
| GetQueueAttributes | SqsOperation.GetQueueAttributes |
| SetQueueAttributes | SqsOperation.SetQueueAttributes |
| PurgeQueue | SqsOperation.PurgeQueue |
| ListQueues | SqsOperation.ListQueues |
Unrecognised operations are classified as SqsOperation.Other.
The classifier extracts queue names from (in priority order):
-
URL path:
/account-id/queue-name(e.g.https://sqs.us-east-1.amazonaws.com/123456789012/my-queue) -
Body
QueueUrlfield: JSON body containing"QueueUrl": "https://.../{accountId}/{queueName}" -
Body
QueueNamefield: JSON body containing"QueueName": "my-queue"(used byCreateQueue)
FIFO queue names (e.g. orders.fifo) are preserved with the .fifo suffix.
Minimal output for clean diagrams:
-
Method label: Operation name (e.g.
SendMessage) -
URI:
sqs:///orders-queue - Content: Omitted (both request and response)
- Headers: Omitted
- Other operations: Skipped entirely
Balanced output for debugging:
-
Method label: Operation name (e.g.
SendMessage) -
URI:
sqs:///orders-queue - Content: Included (request body and response body)
- Headers: Included (with default exclusions)
Full HTTP-level output:
-
Method:
POST(actual HTTP method) - URI: Original AWS endpoint URL
- Content: Full request/response bodies
- Headers: All headers (with default exclusions)
- Other operations: Included
new SqsTrackingMessageHandlerOptions
{
// Display name for this SQS instance in diagrams
ServiceName = "SQS",
// Name of the calling service in diagrams
CallerName = "OrdersApi",
// Verbosity level (default: Detailed)
Verbosity = SqsTrackingVerbosity.Detailed,
// Required: provides test context for log correlation
CurrentTestInfoFetcher = () => (testName, testId),
// Headers excluded from logging (defaults below)
ExcludedHeaders = new HashSet<string>
{
"Authorization", "x-amz-date", "x-amz-security-token",
"x-amz-content-sha256", "User-Agent", "amz-sdk-invocation-id",
"amz-sdk-request"
}
}| Property | Type | Default | Description |
|---|---|---|---|
ServiceName |
string |
"SQS" |
Display name in diagrams for the SQS service |
CallerName |
string |
"Caller" |
Calling service name in diagrams |
Verbosity |
SqsTrackingVerbosity |
Detailed |
Verbosity level (Raw, Detailed, Summarised) |
CurrentTestInfoFetcher |
Func<(string Name, string Id)>? |
null |
Required: provides test context for log correlation |
CurrentStepTypeFetcher |
Func<string?>? |
null |
Optional — returns the current BDD step type (Given/When/Then) |
HttpContextAccessor |
IHttpContextAccessor? |
null |
Optional — enables dual-resolution of test identity from HTTP headers. Auto-resolved by DI extensions (v2.26.3+). See HTTP Tracking Setup#Dual-Resolution Test Identity (v2.23.0+) |
ExcludedHeaders |
HashSet<string> |
See above | Headers excluded from logging |
SetupVerbosity |
SqsTrackingVerbosity? |
null |
Verbosity override for the Setup phase. See Phase-Aware Tracking |
ActionVerbosity |
SqsTrackingVerbosity? |
null |
Verbosity override for the Action phase. See Phase-Aware Tracking |
TrackDuringSetup |
bool |
true |
When false, tracking is suppressed during Setup. See Phase-Aware Tracking
|
TrackDuringAction |
bool |
true |
When false, tracking is suppressed during Action. See Phase-Aware Tracking
|
v2.23.0+ Dual-Resolution:
SqsTrackingMessageHandleraccepts an optionalIHttpContextAccessor? httpContextAccessorconstructor parameter for resolving test identity from HTTP request headers when running inside the SUT's request pipeline. v2.26.3+: SetHttpContextAccessoronSqsTrackingMessageHandlerOptionsinstead — the tracker reads it automatically. See HTTP Tracking Setup#Dual-Resolution Test Identity (v2.23.0+) for details.
SqsTrackingMessageHandler implements ITrackingComponent and auto-registers with TrackingComponentRegistry on construction. This provides:
-
ComponentName:"SqsTrackingMessageHandler ({ServiceName})" -
WasInvoked:trueafter first request -
InvocationCount: Total requests processed
Classified requests use the sqs:/// URI scheme with the queue name in the path:
sqs:///orders-queue
sqs:///orders.fifo
sqs:/// (when queue name unavailable, e.g. ListQueues)
The path-based format (three slashes) preserves queue name casing, unlike host-based URIs which lowercase per RFC 3986.
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