You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ensure Application Insights is wired up as a sink in Serilog. It is expected that the client application will provide an Application Insights Connection String in their appsettings.
Ensure there are Telemetry Converters that set the appropriate Application Name (CloudRoleName) and CloudInstance (Machine name for on-prem, ResourceGroup+Instance name for a docker instance or Azure AppService.
For NServiceBus specifically, ensure a Timing Behavior is added so handlers are sending the appropriate metrics.
Add Serilog.Sinks.ApplicationInsights NuGet package to src/ClearHostedService/ClearMeasure.HostedService.csproj
Update src/ClearHostedService/Configuration/LoggingOptions.cs to replace ApplicationInsightsInstrumentationKey with ApplicationInsightsConnectionString property
Create src/ClearHostedService/Telemetry/TelemetryConverter.cs implementing custom ITelemetryConverter to set CloudRoleName (application name) and CloudRoleInstance (machine name for on-prem, ResourceGroup+Instance for Docker/Azure)
Update src/ClearHostedService/ClearHostedService.cs ConfigureLogging method to configure ApplicationInsights sink with custom TelemetryConverter when EnableApplicationInsights is true
Add NServiceBus.Metrics and Serilog.Sinks.ApplicationInsights NuGet packages to src/ClearHostedEndpoint/ClearMeasure.HostedEndpoint.csproj
Create src/ClearHostedEndpoint/Behaviors/TimingBehavior.cs implementing NServiceBus pipeline behavior to capture and log handler execution timing metrics
Update src/ClearHostedEndpoint/ClearHostedEndpoint.cs to register TimingBehavior in the NServiceBus pipeline during endpoint configuration
Create src/ClearHostedService.Tests/Infrastructure/Telemetry/TelemetryConverterTests.cs with unit tests for TelemetryConverter logic (CloudRoleName, CloudRoleInstance detection)
Update src/ClearHostedService.Tests/Infrastructure/Configuration/LoggingOptionsTests.cs to test new ApplicationInsightsConnectionString property
Create src/ClearHostedEndpoint.Tests/Behaviors/TimingBehaviorTests.cs with unit tests for TimingBehavior execution and metric logging
Dependencies:
Serilog.Sinks.ApplicationInsights (version 4.0.0 or later) - Provides ApplicationInsights sink for Serilog
NServiceBus.Metrics (version 5.0.0 or later) - Provides metrics infrastructure for NServiceBus handlers
This file contains hidden or 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
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.
Closes #11
User Experience Design
User Flow:
N/A
UI Components:
N/A
Error States:
N/A
Accessibility:
N/A
Technical Design
Affected Components:
src/ClearHostedService/ClearMeasure.HostedService.csprojsrc/ClearHostedService/Configuration/LoggingOptions.cssrc/ClearHostedService/Telemetry/TelemetryConverter.cssrc/ClearHostedService/ClearHostedService.cssrc/ClearHostedEndpoint/ClearMeasure.HostedEndpoint.csprojsrc/ClearHostedEndpoint/Behaviors/TimingBehavior.cssrc/ClearHostedEndpoint/ClearHostedEndpoint.cssrc/ClearHostedService.Tests/Infrastructure/Telemetry/TelemetryConverterTests.cssrc/ClearHostedService.Tests/Infrastructure/Configuration/LoggingOptionsTests.cssrc/ClearHostedEndpoint.Tests/Behaviors/TimingBehaviorTests.csImplementation Steps:
Serilog.Sinks.ApplicationInsightsNuGet package tosrc/ClearHostedService/ClearMeasure.HostedService.csprojsrc/ClearHostedService/Configuration/LoggingOptions.csto replaceApplicationInsightsInstrumentationKeywithApplicationInsightsConnectionStringpropertysrc/ClearHostedService/Telemetry/TelemetryConverter.csimplementing custom ITelemetryConverter to set CloudRoleName (application name) and CloudRoleInstance (machine name for on-prem, ResourceGroup+Instance for Docker/Azure)src/ClearHostedService/ClearHostedService.csConfigureLogging method to configure ApplicationInsights sink with custom TelemetryConverter whenEnableApplicationInsightsis trueNServiceBus.MetricsandSerilog.Sinks.ApplicationInsightsNuGet packages tosrc/ClearHostedEndpoint/ClearMeasure.HostedEndpoint.csprojsrc/ClearHostedEndpoint/Behaviors/TimingBehavior.csimplementing NServiceBus pipeline behavior to capture and log handler execution timing metricssrc/ClearHostedEndpoint/ClearHostedEndpoint.csto register TimingBehavior in the NServiceBus pipeline during endpoint configurationsrc/ClearHostedService.Tests/Infrastructure/Telemetry/TelemetryConverterTests.cswith unit tests for TelemetryConverter logic (CloudRoleName, CloudRoleInstance detection)src/ClearHostedService.Tests/Infrastructure/Configuration/LoggingOptionsTests.csto test new ApplicationInsightsConnectionString propertysrc/ClearHostedEndpoint.Tests/Behaviors/TimingBehaviorTests.cswith unit tests for TimingBehavior execution and metric loggingDependencies:
Serilog.Sinks.ApplicationInsights(version 4.0.0 or later) - Provides ApplicationInsights sink for SerilogNServiceBus.Metrics(version 5.0.0 or later) - Provides metrics infrastructure for NServiceBus handlersDatabase Migrations: None
Tests:
src/ClearHostedService.Tests/Infrastructure/Telemetry/TelemetryConverterTests.cssrc/ClearHostedService.Tests/Infrastructure/Configuration/LoggingOptionsTests.cssrc/ClearHostedEndpoint.Tests/Behaviors/TimingBehaviorTests.cssrc/ClearHostedEndpoint.Tests/EndpointIntegrationTests.csTest Design
Acceptance Tests: None required
Rationale: Backend-only change