File tree Expand file tree Collapse file tree 4 files changed +10
-6
lines changed
ServiceControl.Audit.Persistence.PostgreSQL Expand file tree Collapse file tree 4 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 3434 <PackageVersion Include =" Mindscape.Raygun4Net.NetCore" Version =" 11.2.1" />
3535 <PackageVersion Include =" NLog.Extensions.Logging" Version =" 5.4.0" />
3636 <PackageVersion Include =" Npgsql" Version =" 9.0.3" />
37+ <PackageVersion Include =" Npgsql.OpenTelemetry" Version =" 9.0.3" />
3738 <PackageVersion Include =" NServiceBus" Version =" 9.2.7" />
3839 <PackageVersion Include =" NServiceBus.AcceptanceTesting" Version =" 9.2.7" />
3940 <PackageVersion Include =" NServiceBus.AmazonSQS" Version =" 8.0.0" />
Original file line number Diff line number Diff line change 11namespace ServiceControl . Audit . Persistence . PostgreSQL ;
22
33using Microsoft . Extensions . DependencyInjection ;
4+ using OpenTelemetry . Metrics ;
45using ServiceControl . Audit . Auditing . BodyStorage ;
56using ServiceControl . Audit . Persistence ;
67using ServiceControl . Audit . Persistence . PostgreSQL . BodyStorage ;
78using ServiceControl . Audit . Persistence . PostgreSQL . UnitOfWork ;
89using ServiceControl . Audit . Persistence . UnitOfWork ;
10+ using Npgsql ;
11+
912class PostgreSQLPersistence ( DatabaseConfiguration databaseConfiguration ) : IPersistence
1013{
1114 public void AddInstaller ( IServiceCollection services )
@@ -24,5 +27,6 @@ public void AddPersistence(IServiceCollection services)
2427 services . AddSingleton < IBodyStorage , PostgreSQLAttachmentsBodyStorage > ( ) ;
2528 services . AddSingleton < PostgreSQLConnectionFactory > ( ) ;
2629 services . AddHostedService < RetentionCleanupService > ( ) ;
30+ services . ConfigureOpenTelemetryMeterProvider ( b => b . AddNpgsqlInstrumentation ( ) ) ;
2731 }
2832}
Original file line number Diff line number Diff line change @@ -22,23 +22,21 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
2222 {
2323 await Task . Delay ( TimeSpan . FromSeconds ( config . ExpirationProcessTimerInSeconds ) , stoppingToken ) ;
2424
25- await CleanupOldMessagesAsync ( stoppingToken ) ;
25+ await CleanupOldMessages ( stoppingToken ) ;
2626 }
27- catch ( OperationCanceledException )
27+ catch ( OperationCanceledException ) when ( stoppingToken . IsCancellationRequested )
2828 {
29- // Expected when shutting down
29+ logger . LogInformation ( $ " { nameof ( RetentionCleanupService ) } stopped." ) ;
3030 break ;
3131 }
3232 catch ( Exception ex )
3333 {
3434 logger . LogError ( ex , "Error during cleanup task." ) ;
3535 }
3636 }
37-
38- logger . LogInformation ( $ "{ nameof ( RetentionCleanupService ) } stopped.") ;
3937 }
4038
41- async Task CleanupOldMessagesAsync ( CancellationToken cancellationToken )
39+ async Task CleanupOldMessages ( CancellationToken cancellationToken )
4240 {
4341 await using var conn = await connectionFactory . OpenConnection ( cancellationToken ) ;
4442
Original file line number Diff line number Diff line change 2525 <ItemGroup >
2626 <PackageReference Include =" Microsoft.IO.RecyclableMemoryStream" />
2727 <PackageReference Include =" Npgsql" />
28+ <PackageReference Include =" Npgsql.OpenTelemetry" />
2829 </ItemGroup >
2930
3031</Project >
You can’t perform that action at this time.
0 commit comments