Skip to content

Commit 56af6df

Browse files
committed
Add some docs about Logging and Metrics
To leave as examples in case code gets deleted/forgotten.
1 parent 041c161 commit 56af6df

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Metrics and logging
2+
3+
Some processes were setup for the `notifications` code to observe logs, events and metrics
4+
5+
## Application Insights
6+
7+
The ApplicationInsightsLogging service class sets up logs to feed into Application Insights, which can then be called like so:
8+
9+
```
10+
class CommandHandler:
11+
@contextmanager
12+
@staticmethod
13+
def handle(command_name):
14+
try:
15+
yield
16+
ApplicationInsightsLogging().custom_event_info(
17+
event_name=f"{command_name}Completed",
18+
message=f"{command_name} completed successfully",
19+
)
20+
except Exception as e:
21+
ApplicationInsightsLogging().exception(f"{command_name}Error: {e}")
22+
raise CommandError(e)
23+
```
24+
25+
26+
The Application Insights resource is setup in by the `app_insights_audit` module in terraform:
27+
28+
```
29+
module "app_insights_audit" {
30+
source = "../dtos-devops-templates/infrastructure/modules/app-insights"
31+
32+
name = module.shared_config.names.app-insights
33+
location = var.region
34+
resource_group_name = azurerm_resource_group.main.name
35+
appinsights_type = "web"
36+
37+
log_analytics_workspace_id = module.log_analytics_workspace_audit.id
38+
39+
# alerts
40+
action_group_id = var.action_group_id
41+
enable_alerting = var.enable_alerting
42+
}
43+
```
44+
45+
## Metrics
46+
47+
This PR introduced a Metrics service class and command to collect information about queue sizes
48+
https://github.com/NHSDigital/dtos-manage-breast-screening/pull/617
49+
50+
The metrics would feed through to the Application Insights resource and could be viewed in the Portal.

0 commit comments

Comments
 (0)