-
Notifications
You must be signed in to change notification settings - Fork 1
Integration AtlasDataApi Extension
The TestTrackingDiagrams.Extensions.AtlasDataApi package adds MongoDB Atlas Data API operation tracking to your test diagrams. It intercepts HTTP requests to the Atlas Data API and classifies them into typed operations like Find ← users with clean atlas:///myDb/users URIs.
Using the MongoDB driver directly? If your code uses the MongoDB .NET driver (MongoClient), use the Integration MongoDB Extension instead — it hooks into the driver's native event monitoring.
The Atlas Data API is a REST API that exposes MongoDB operations over HTTP. Requests are POST calls to action endpoints like:
POST https://data.mongodb-api.com/app/{appId}/endpoint/data/v1/action/findOne
The request body contains the dataSource, database, collection, and operation-specific parameters (filter, document, pipeline, etc.).
AtlasDataApiTrackingMessageHandler is a DelegatingHandler that:
- Reads the request body to extract metadata (dataSource, database, collection, filter)
- Parses the URL path to determine the action (findOne, insertMany, aggregate, etc.)
- Logs a classified request entry to
RequestResponseLogger - Forwards the request to the real Atlas Data API
- Logs the response
Because it logs to the same logger as all other extensions, Atlas Data API operations appear alongside HTTP API calls, MongoDB driver calls, and other tracked dependencies in the same sequence diagram.
dotnet add package TestTrackingDiagrams.Extensions.AtlasDataApi| Level | Label shown | URI shown | Request content | Response content |
|---|---|---|---|---|
| Raw | HTTP method (POST) |
Original Atlas URL | Full JSON body | Full JSON response |
| Detailed | Find ← users |
atlas:///myDb/users |
Full JSON body | Full JSON response |
| Summarised | Find |
atlas:///myDb/users |
None | None |
The default is Detailed.
| Category | Operations |
|---|---|
| Read |
FindOne, Find, Aggregate
|
| Write |
InsertOne, InsertMany, DeleteOne, DeleteMany
|
| Read-modify-write |
UpdateOne, UpdateMany, ReplaceOne
|
| Fallback |
Other (unrecognised actions) |
In Detailed verbosity, labels include directional arrows indicating data flow:
| Direction | Arrow | Examples |
|---|---|---|
| Read | ← |
Find ← users, Aggregate ← orders
|
| Write | → |
InsertOne → users, DeleteMany → temp
|
| Read-modify-write | ↔ |
UpdateOne ↔ orders, ReplaceOne ↔ users
|
var options = new AtlasDataApiTrackingMessageHandlerOptions
{
ServiceName = "Atlas Data API",
CallingServiceName = "My API",
Verbosity = AtlasDataApiTrackingVerbosity.Detailed,
CurrentTestInfoFetcher = XUnitTestTrackingMessageHandlerOptions.TestInfoFetcher
};
var handler = new AtlasDataApiTrackingMessageHandler(options, new HttpClientHandler());
var client = new HttpClient(handler)
{
BaseAddress = new Uri("https://data.mongodb-api.com/app/myapp/endpoint/data/v1/")
};builder.ConfigureTestServices(services =>
{
services.AddAtlasDataApiTestTracking(options =>
{
options.ServiceName = "Atlas Data API";
options.Verbosity = AtlasDataApiTrackingVerbosity.Detailed;
});
});builder.ConfigureTestServices(services =>
{
var trackingOptions = new AtlasDataApiTrackingMessageHandlerOptions
{
ServiceName = "Atlas Data API",
CurrentTestInfoFetcher = XUnitTestTrackingMessageHandlerOptions.TestInfoFetcher
};
services.AddHttpClient("AtlasDataApi")
.AddHttpMessageHandler(() => new AtlasDataApiTrackingMessageHandler(trackingOptions));
});| Property | Type | Default | Description |
|---|---|---|---|
ServiceName |
string |
"AtlasDataApi" |
The participant name shown in the diagram |
CallingServiceName |
string |
"Caller" |
The participant name for the calling service |
Verbosity |
AtlasDataApiTrackingVerbosity |
Detailed |
Controls detail level (Raw, Detailed, Summarised) |
CurrentTestInfoFetcher |
Func<(string Name, string Id)>? |
null |
Returns current test name and ID |
CurrentStepTypeFetcher |
Func<string?>? |
null |
Returns current BDD step type |
ExcludedHeaders |
HashSet<string> |
Authorization, User-Agent, api-key, apiKey
|
Headers to exclude from diagram notes |
ExcludedOperations |
HashSet<AtlasDataApiOperation> |
[] |
Operations to suppress from tracking |
SetupVerbosity |
AtlasDataApiTrackingVerbosity? |
null |
Verbosity override for Setup phase |
ActionVerbosity |
AtlasDataApiTrackingVerbosity? |
null |
Verbosity override for Action phase |
TrackDuringSetup |
bool |
true |
Whether to track during Setup phase |
TrackDuringAction |
bool |
true |
Whether to track during Action phase |
AtlasDataApiTrackingMessageHandler implements ITrackingComponent and auto-registers with TrackingComponentRegistry:
var handler = new AtlasDataApiTrackingMessageHandler(options);
// ... run test ...
Assert.True(handler.WasInvoked);
Assert.Equal(3, handler.InvocationCount);The handler reads the JSON request body to extract:
| Field | Used for |
|---|---|
dataSource |
Stored in AtlasDataApiOperationInfo.DataSource
|
database |
Used in clean URI: atlas:///database/collection
|
collection |
Used in label: Find ← collection
|
filter |
Stored in AtlasDataApiOperationInfo.FilterText
|
Malformed or missing JSON is handled gracefully — the operation is still classified from the URL, metadata is simply null.
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