Skip to content

Commit 40c717b

Browse files
committed
Merge branch 'main' into chore/provide-new-az-msg-handler-interface
2 parents cf86a82 + 83c4dc3 commit 40c717b

22 files changed

+479
-378
lines changed

docs/preview/02-getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ Host.CreateDefaultBuilder()
8080

8181
The way *'message handlers'* are registered determines when the received message will be routed to them.
8282

83-
> 🔗 See the [Azure Service Bus messaging feature documentation](./03-Features/01-Azure/01-service-bus.md) for more information on providing additional routing filters to your message handlers.
83+
> 🔗 See the [Azure Service Bus messaging feature documentation](./03-Features/01-Azure/01-service-bus.mdx) for more information on providing additional routing filters to your message handlers.

docs/preview/03-Features/01-Azure/01-service-bus.md renamed to docs/preview/03-Features/01-Azure/01-service-bus.mdx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
sidebar_label: Service Bus
33
---
44

5+
import Tabs from '@theme/Tabs';
6+
import TabItem from '@theme/TabItem';
7+
58
# Azure Service Bus messaging
69
The `Arcus.Messaging.Pumps.ServiceBus` library provides a way to process Azure Service Bus messages on queues/topic subscriptions via custom routed *message handlers*, instead of interacting with the [`ServiceBusReceiver`](https://learn.microsoft.com/en-us/dotnet/api/azure.messaging.servicebus.servicebusreceiver) yourself.
710

@@ -134,6 +137,10 @@ services.AddServiceBus[Topic/Queue]MessagePump(..., options =>
134137
// this job instance in a multi-instance deployment (default: generated GUID).
135138
options.JobId = Guid.NewGuid().ToString();
136139

140+
// The name for the request operation which will be used in the chosen message correlation system.
141+
// (default: Azure Service Bus message processing)
142+
options.Telemetry.OperationName = "ReceiveOrder";
143+
137144
// Indicate whether or not messages should be automatically marked as completed when the handler succeeded (no exceptions thrown) (default: true)
138145
// ⚠️ Setting this property to false means you are responsible for completing the message yourself.
139146
options.Routing.AutoComplete = false;
@@ -163,6 +170,30 @@ services.AddServiceBus[Topic/Queue]MessagePump(..., options =>
163170
});
164171
```
165172

173+
#### Service Bus request tracking
174+
Arcus Messaging makes it possible to make it visible in a logging system like Azure Application Insights, what happens when a message is received from a Service Bus topic or queue.
175+
Below, you will find the different options that are supported to enable Service Bus request tracking. When this is enabled, Arcus.Messaging will log a request operation for every message that is received from Service Bus and all traces and interactions to dependent systems that happen during the processing of that message, will be logged as children of this request operation.
176+
177+
<Tabs groupId="correlation-systems">
178+
<TabItem value="serilog" label="Serilog">
179+
180+
```powershell
181+
PS> Install-Package -Name Arcus.Messaging.ServiceBus.Telemetry.Serilog
182+
```
183+
184+
Make sure to include the following line to your message pump registration:
185+
```diff
186+
services.AddServiceBusTopicMessagePump(...)
187+
+ .UseServiceBusSerilogRequestTracking()
188+
.WithServiceBusMessageHandler<...>()
189+
.WithServiceBusMessageHandler<...>();
190+
```
191+
192+
Now Arcus will use the Serilog approach to track Azure Service Bus messages. Make sure that Microsoft's `TelemetryClient` is registered in the application services. (See [Microsoft documentation](https://learn.microsoft.com/en-us/azure/azure-monitor/app/dot-net?tabs=net%2Cnet-1%2Cserver%2Cportal%2Ccsharp%2Cenqueue) for more information.)
193+
194+
</TabItem>
195+
</Tabs>
196+
166197
### Message handler routing customization
167198
The following routing options are available when registering an Azure Service Bus message handler on a message pump.
168199

docs/preview/03-Guides/migration-guide-v3.0.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,11 @@ To still benefit from the original W3C message correlation tracking with **Arcus
158158
* 🔨 Register Serilog as the message correlation system by adding this line:
159159
```diff
160160
services.AddServiceBusTopicMessagePump(...)
161-
+ .WithServiceBusSerilogRequestTracking()
161+
+ .UseServiceBusSerilogRequestTracking()
162162
.WithServiceBusMessageHandler<...>()
163163
.WithServiceBusMessageHandler<...>();
164164
```
165+
* 👀 Check that the `TelemetryClient` is registered in the application services (registering Azure Application Insights services is not done automatically anymore).
165166
* 🎉 The original (< v3.0) message correlation is now restored.
166167

167168
We expect other kinds of message correlation registrations in the future. Switching between them would be a matter of choosing the correct `.WithServiceBus...RequestTracking()`.

src/Arcus.Messaging.Abstractions.ServiceBus/MessageHandling/AzureServiceBusMessageRouter.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
using System.Threading;
55
using System.Threading.Tasks;
66
using Arcus.Messaging.Abstractions.MessageHandling;
7-
using Arcus.Messaging.Abstractions.Telemetry;
87
using Azure.Messaging.ServiceBus;
98
using Microsoft.Extensions.DependencyInjection;
109
using Microsoft.Extensions.Logging;
11-
using Serilog.Context;
1210
using static Arcus.Messaging.Abstractions.MessageHandling.MessageProcessingError;
1311

1412
#pragma warning disable S1133
@@ -103,10 +101,6 @@ protected async Task<MessageProcessingResult> RouteMessageWithPotentialFallbackA
103101
}
104102

105103
using IServiceScope serviceScope = ServiceProvider.CreateScope();
106-
#pragma warning disable CS0618 // Type or member is obsolete: will be refactored when moving towards v3.0.
107-
using IDisposable _ = LogContext.Push(new MessageCorrelationInfoEnricher(correlationInfo, Options.CorrelationEnricher));
108-
#pragma warning restore CS0618 // Type or member is obsolete
109-
110104
return await TryRouteMessageWithPotentialFallbackAsync(serviceScope.ServiceProvider, messageReceiver, message, messageContext, correlationInfo, cancellationToken);
111105
}
112106

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Arcus.Messaging.Abstractions.MessageHandling;
2+
using Arcus.Messaging.Abstractions.Telemetry;
3+
4+
namespace Arcus.Messaging.Abstractions.ServiceBus.Telemetry
5+
{
6+
/// <summary>
7+
/// Represents the way how incoming Azure Service bus request messages
8+
/// within a service-to-service correlation operation are tracked in a custom telemetry system,.
9+
/// </summary>
10+
public interface IServiceBusMessageCorrelationScope
11+
{
12+
/// <summary>
13+
/// Starts a new Azure Service bus request operation on the telemetry system.
14+
/// </summary>
15+
/// <param name="messageContext">The message context for the currently received Azure Service bus message.</param>
16+
/// <param name="options">The user-configurable options to manipulate the telemetry.</param>
17+
MessageOperationResult StartOperation(ServiceBusMessageContext messageContext, MessageTelemetryOptions options);
18+
}
19+
}

src/Arcus.Messaging.Abstractions/Arcus.Messaging.Abstractions.csproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,8 @@
2626
<None Include="..\..\docs\static\img\icon.png" Pack="true" PackagePath="\" />
2727
</ItemGroup>
2828

29-
3029
<ItemGroup>
3130
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="[8.*,10.0.0)" />
3231
</ItemGroup>
3332

34-
<ItemGroup>
35-
<!-- TODO: will be removed in v3.0 -->
36-
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
37-
<PackageReference Include="Serilog" Version="4.3.0" />
38-
<!-- TODO: will be removed in v3.0 -->
39-
</ItemGroup>
40-
4133
</Project>

src/Arcus.Messaging.Abstractions/MessageCorrelationInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class MessageCorrelationInfo
1414
/// <param name="transactionId">The unique identifier that spans one or more operations and are considered a transaction/session.</param>
1515
/// <exception cref="ArgumentException">Thrown when the <paramref name="operationId"/> or <paramref name="transactionId"/> is blank.</exception>
1616
public MessageCorrelationInfo(string operationId, string transactionId)
17-
: this(operationId, transactionId, null)
17+
: this(operationId, transactionId, operationParentId: null)
1818
{
1919
}
2020

src/Arcus.Messaging.Abstractions/MessageCorrelationResult.cs

Lines changed: 0 additions & 91 deletions
This file was deleted.

src/Arcus.Messaging.Abstractions/MessageHandling/MessageCorrelationFormat.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using Arcus.Messaging.Abstractions.Telemetry;
3-
4-
namespace Arcus.Messaging.Abstractions.MessageHandling
1+
namespace Arcus.Messaging.Abstractions.MessageHandling
52
{
63
/// <summary>
74
/// Represents the consumer-configurable options to change the behavior of the <see cref="MessageRouter"/>.
@@ -12,17 +9,5 @@ public class MessageRouterOptions
129
/// Gets the consumer-configurable options to change the deserialization behavior of the message router.
1310
/// </summary>
1411
public MessageDeserializationOptions Deserialization { get; } = new();
15-
16-
/// <summary>
17-
/// Gets the consumer configurable options model to change the behavior of the tracked telemetry.
18-
/// </summary>
19-
[Obsolete("Will be removed in v3.0 as the correlation is handled outside the core message routing")]
20-
public MessageTelemetryOptions Telemetry { get; } = new();
21-
22-
/// <summary>
23-
/// Gets the options to control the Serilog <see cref="MessageCorrelationInfoEnricher"/> when the incoming message is routed via the message router.
24-
/// </summary>
25-
[Obsolete("Will be removed in v3.0 as the correlation is handled outside the core message routing")]
26-
public MessageCorrelationEnricherOptions CorrelationEnricher { get; } = new();
2712
}
2813
}

0 commit comments

Comments
 (0)