-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Archiver Observability #3353
Merged
Merged
Archiver Observability #3353
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8461845
feat: add an archive test without observablity, to ensure test passes…
iancooper 358d03b
chore: switch branch; commit to save wip
iancooper 07eb800
chore: Merge branch 'master' into arch_obser
iancooper 1f3dcca
chore: Merge branch 'master' into arch_obser
iancooper 9b4acbc
chore: switch to another device
iancooper 1fa1ee6
feat: we need a create span for the archive batch, if issued through …
iancooper c3e900b
fix: missing mark dispatched in clear otel checks
iancooper b327a98
feat: add tagobjects for archive batch
iancooper a72b352
feat: opentelemetry for the archive operation
iancooper 9ddedf7
feat: add async archive operation opentelemetry
iancooper 5a60cc8
feat: cleanup old archiver telemetry
iancooper 4de9e22
feat: add archive async telemetry
iancooper 5e5813b
Merge branch 'master' into arch_obser
iancooper 68d77b9
feat: move archive functionality to OutboxArchiver.cs
iancooper b20e357
feat: rename of ExternalBusService.cs to OutboxProducerMediator.cs
iancooper c824258
fix: name the mediator correctly
iancooper 513052d
fix: issue with PackageReference not PackageVersion
iancooper 4a481b3
chore: Merge branch 'master' into arch_obser
iancooper 8890035
fix: failing reflection based construction of OutBoxProducerMediator …
iancooper 8477f51
Merge branch 'master' into arch_obser
iancooper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# 20. Move Archive Methods from External Service Bus to Outbox Archiver to Reduce Complexity | ||
|
||
Date: 2024-10-28 | ||
|
||
## Status | ||
|
||
Adopted | ||
|
||
## Context | ||
|
||
The `ExternalServiceBus` class is a mediator between producer and outbox. It suffers from complexity, see ADR 0020. | ||
|
||
The `ExternalServiceBus` class has a number of methods that are related to archiving messages. These methods are: | ||
- Archive | ||
- ArchiveAsync | ||
|
||
The OutboxArchiver and the TimedOuboxArchiver are the only callers of these ExternalBus Archive methods. The TimedOutboxArchiver provides both a timer that fires the archiver at a given periodic interval, and uses the global distributed lock to ensure only one archiver runs. | ||
|
||
## Decision | ||
|
||
Whilst the `Archive` methods were not called out by CodeScene analysis, they do add to the overall set of responsibilities of `ExternalServiceBus`. As they have different reasons to change to `ExternalServiceBus` they should be moved to a separate class. | ||
|
||
We will move the implementation from `ExternalServiceBus` into `OutboxArchiver`. We will call `OutboxArchiver` from `TimedOutboxArchiver`. | ||
|
||
## Consequences | ||
|
||
One, we have moved these functions, it makes sense to rename the `ExternalServiceBus` class to 'OutboxProducerMediator' as this better describes its role within our codebase. | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,6 @@ THE SOFTWARE. */ | |
using Paramore.Brighter.FeatureSwitch; | ||
using Paramore.Brighter.Logging; | ||
using System.Text.Json; | ||
using System.Transactions; | ||
using Paramore.Brighter.DynamoDb; | ||
using Paramore.Brighter.Observability; | ||
using Polly.Registry; | ||
|
@@ -94,7 +93,7 @@ public static IBrighterBuilder BrighterHandlerBuilder(IServiceCollection service | |
var mapperRegistry = new ServiceCollectionMessageMapperRegistry(services, options.MapperLifetime); | ||
services.TryAddSingleton(mapperRegistry); | ||
|
||
services.TryAddSingleton<IAmARequestContextFactory>(options.RequestContextFactory); | ||
services.TryAddSingleton(options.RequestContextFactory); | ||
|
||
if (options.FeatureSwitchRegistry != null) | ||
services.TryAddSingleton(options.FeatureSwitchRegistry); | ||
|
@@ -136,9 +135,6 @@ public static IBrighterBuilder BrighterHandlerBuilder(IServiceCollection service | |
/// </summary> | ||
/// <param name="brighterBuilder">The Brighter builder to add this option to</param> | ||
/// <param name="configure">A callback that allows you to configure <see cref="ExternalBusConfiguration"/> options</param> | ||
/// <param name="transactionProvider">The transaction provider for the outbox, can be null for in-memory default | ||
/// of <see cref="CommittableTransactionProvider"/> which you must set the generic type to <see cref="CommittableTransaction"/> for | ||
/// </param> | ||
/// <param name="serviceLifetime">The lifetime of the transaction provider</param> | ||
/// <returns>The Brighter builder to allow chaining of requests</returns> | ||
public static IBrighterBuilder UseExternalBus( | ||
|
@@ -222,8 +218,8 @@ public static IBrighterBuilder UseExternalBus( | |
|
||
brighterBuilder.Services.TryAddSingleton<IAmExternalBusConfiguration>(busConfiguration); | ||
|
||
brighterBuilder.Services.TryAdd(new ServiceDescriptor(typeof(IAmAnExternalBusService), | ||
(serviceProvider) => BuildExternalBus( | ||
brighterBuilder.Services.TryAdd(new ServiceDescriptor(typeof(IAmAnOutboxProducerMediator), | ||
(serviceProvider) => BuildOutBoxProducerMediator( | ||
serviceProvider, transactionType, busConfiguration, brighterBuilder.PolicyRegistry, outbox | ||
), | ||
ServiceLifetime.Singleton)); | ||
|
@@ -237,7 +233,7 @@ private static INeedInstrumentation AddEventBus( | |
INeedMessaging messagingBuilder, | ||
IUseRpc useRequestResponse) | ||
{ | ||
var eventBus = provider.GetService<IAmAnExternalBusService>(); | ||
var eventBus = provider.GetService<IAmAnOutboxProducerMediator>(); | ||
var eventBusConfiguration = provider.GetService<IAmExternalBusConfiguration>(); | ||
var serviceActivatorOptions = provider.GetService<IServiceActivatorOptions>(); | ||
|
||
|
@@ -325,17 +321,17 @@ private static object BuildCommandProcessor(IServiceProvider provider) | |
return commandProcessor; | ||
} | ||
|
||
private static IAmAnExternalBusService BuildExternalBus(IServiceProvider serviceProvider, | ||
private static IAmAnOutboxProducerMediator BuildOutBoxProducerMediator(IServiceProvider serviceProvider, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ New issue: Excess Number of Function Arguments |
||
Type transactionType, | ||
ExternalBusConfiguration busConfiguration, | ||
IPolicyRegistry<string> policyRegistry, | ||
IAmAnOutbox outbox) | ||
{ | ||
//Because the bus has specialized types as members, we need to create the bus type dynamically | ||
//again to prevent someone configuring Brighter from having to pass generic types | ||
var busType = typeof(ExternalBusService<,>).MakeGenericType(typeof(Message), transactionType); | ||
var busType = typeof(OutboxProducerMediator<,>).MakeGenericType(typeof(Message), transactionType); | ||
|
||
return (IAmAnExternalBusService)Activator.CreateInstance( | ||
return (IAmAnOutboxProducerMediator)Activator.CreateInstance( | ||
busType, | ||
busConfiguration.ProducerRegistry, | ||
policyRegistry, | ||
|
@@ -344,13 +340,11 @@ private static IAmAnExternalBusService BuildExternalBus(IServiceProvider service | |
TransformFactoryAsync(serviceProvider), | ||
Tracer(serviceProvider), | ||
outbox, | ||
busConfiguration.ArchiveProvider, | ||
RequestContextFactory(serviceProvider), | ||
busConfiguration.OutboxTimeout, | ||
busConfiguration.MaxOutStandingMessages, | ||
busConfiguration.MaxOutStandingCheckInterval, | ||
busConfiguration.OutBoxBag, | ||
busConfiguration.ArchiveBatchSize, | ||
TimeProvider.System, | ||
busConfiguration.InstrumentationOptions); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ No longer an issue: Excess Number of Function Arguments
BuildExternalBus is no longer above the threshold for number of arguments