From fbb30d21a80182d91c0b48c281d5883a0f5ab06b Mon Sep 17 00:00:00 2001
From: brycecoon <112597142+brycecoon@users.noreply.github.com>
Date: Wed, 20 Mar 2024 12:36:06 -0600
Subject: [PATCH] did the telemetry thing
---
BlazorTickets/Components/Layout/NavMenu.razor | 10 +
BlazorTickets/Components/Pages/Counter.razor | 5 +
.../Components/Pages/WebTickets.razor | 1 -
BlazorTickets/Program.cs | 2 -
BlazorTickets/Services/WebEventService.cs | 33 ++-
BlazorTickets/Services/WebTicketService.cs | 44 +++-
.../dashboards/logging-dashboard.json | 235 ++++++++++++++++++
TicketLibrary/Pages/Tickets.razor | 4 +
TicketLibrary/Pages/WebEvent.razor | 3 +
TicketLibrary/Services/IEventService.cs | 4 +
TicketLibrary/Services/ITicketService.cs | 3 +-
11 files changed, 332 insertions(+), 12 deletions(-)
create mode 100644 BryceDocker/grafana/provisioning/dashboards/logging-dashboard.json
diff --git a/BlazorTickets/Components/Layout/NavMenu.razor b/BlazorTickets/Components/Layout/NavMenu.razor
index f5fa114..0d03849 100644
--- a/BlazorTickets/Components/Layout/NavMenu.razor
+++ b/BlazorTickets/Components/Layout/NavMenu.razor
@@ -24,6 +24,16 @@
Events
+
+
+ Weather
+
+
+
+
+ Counter
+
+
diff --git a/BlazorTickets/Components/Pages/Counter.razor b/BlazorTickets/Components/Pages/Counter.razor
index 1a4f8e7..3df9bbb 100644
--- a/BlazorTickets/Components/Pages/Counter.razor
+++ b/BlazorTickets/Components/Pages/Counter.razor
@@ -1,5 +1,6 @@
@page "/counter"
@rendermode InteractiveServer
+@inject ILogger logger;
Counter
@@ -12,6 +13,10 @@
@code {
private int currentCount = 0;
+ protected override void OnInitialized()
+ {
+ }
+
private void IncrementCount()
{
currentCount++;
diff --git a/BlazorTickets/Components/Pages/WebTickets.razor b/BlazorTickets/Components/Pages/WebTickets.razor
index 8249774..457457d 100644
--- a/BlazorTickets/Components/Pages/WebTickets.razor
+++ b/BlazorTickets/Components/Pages/WebTickets.razor
@@ -3,4 +3,3 @@
WebTickets
-
diff --git a/BlazorTickets/Program.cs b/BlazorTickets/Program.cs
index 2274b57..697dedb 100644
--- a/BlazorTickets/Program.cs
+++ b/BlazorTickets/Program.cs
@@ -20,11 +20,9 @@
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
-//int aaronsBadWarn = 7;
builder.Services.AddScoped();
builder.Services.AddScoped();
-//builder.Services.AddScoped();
builder.Services.AddControllers();
builder.Services.AddScoped();
builder.Services.AddDbContext(options => options.UseNpgsql(builder.Configuration["Postgres"]));
diff --git a/BlazorTickets/Services/WebEventService.cs b/BlazorTickets/Services/WebEventService.cs
index 17ca6b6..fb85dbd 100644
--- a/BlazorTickets/Services/WebEventService.cs
+++ b/BlazorTickets/Services/WebEventService.cs
@@ -1,18 +1,47 @@
using BlazorTickets.Data;
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Logging;
using TicketLibrary.Data;
using TicketLibrary.Services;
namespace BlazorTickets.Services;
-public class WebEventService : IEventService
+
+
+public partial class WebEventService : IEventService
{
+ private readonly ILogger _logger;
+
+
+ [LoggerMessage(Level = LogLevel.Information, Message = "Getting All Events.")]
+ static partial void GetAllEvents(ILogger logger, string description);
+
+ [LoggerMessage(Level = LogLevel.Error, Message = "Testing the events.")]
+ static partial void TestEvents1(ILogger logger, string description);
+
+ [LoggerMessage(Level = LogLevel.Warning, Message = "Something about events.")]
+ static partial void TestEvents2(ILogger logger, string description);
+
+
PostgresContext _context;
- public WebEventService(PostgresContext context)
+ public WebEventService(PostgresContext context, ILogger logger)
{
_context = context;
+ _logger = logger;
}
public async Task> GetAllEventsAsync()
{
+ GetAllEvents(_logger, $"Inside getAllEvents now. Number of events is {_context.Events.Count()}");
return await _context.Events.ToListAsync();
}
+
+ public void InvokeEventsLogger1(int num1)
+ {
+ TestEvents1(_logger, $"Inside invokeEvents now. {num1}");
+ }
+
+ public void InvokeEventsLogger2(int num2)
+ {
+ TestEvents2(_logger, $"invoking events again. {num2}");
+
+ }
}
diff --git a/BlazorTickets/Services/WebTicketService.cs b/BlazorTickets/Services/WebTicketService.cs
index 1f1c129..49c047e 100644
--- a/BlazorTickets/Services/WebTicketService.cs
+++ b/BlazorTickets/Services/WebTicketService.cs
@@ -4,12 +4,26 @@
using TicketLibrary.Services;
namespace BlazorTickets.Services;
-public class WebTicketService : ITicketService
+public partial class WebTicketService : ITicketService
{
+ private readonly ILogger _logger;
+
+
+ [LoggerMessage(Level = LogLevel.Information, Message = "Getting All Tickets.")]
+ static partial void GetAllTickets(ILogger logger, string description);
+
+ [LoggerMessage(Level = LogLevel.Error, Message = "Testing the tickets.")]
+ static partial void TestTickets1(ILogger logger, string description);
+
+ [LoggerMessage(Level = LogLevel.Warning, Message = "Something about tickets.")]
+ static partial void TestTickets2(ILogger logger, string description);
+
+
PostgresContext _context;
- public WebTicketService(PostgresContext context)
+ public WebTicketService(PostgresContext context, ILogger logger)
{
_context = context;
+ _logger = logger;
}
public Task AddATicket(Ticket t)
@@ -24,21 +38,39 @@ public Task AddATicket(Ticket t)
return Task.CompletedTask;
}
- public void ChangeBaseAddress(string newBaseAddress)
+ public void InvokeTicketsLogger1(int number1)
{
- throw new NotImplementedException();
+ TestTickets1(_logger, $"Inside invokeTickets now. {number1}");
}
- public void ChangeConnectivity(bool _IsConnected)
+ public void InvokeTicketsLogger2(int number2)
{
- throw new NotImplementedException();
+ TestTickets1(_logger, $"Invoke number 2 for tickets {number2}");
}
public async Task> GetAllTicketsAsync()
{
+ GetAllTickets(_logger, $"Inside of getAllTickets. Number of tickets is {_context.Tickets.Count()}");
return await _context.Tickets.ToListAsync();
}
+
+
+
+
+
+
+ public void ChangeBaseAddress(string newBaseAddress)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void ChangeConnectivity(bool _IsConnected)
+ {
+ throw new NotImplementedException();
+ }
+
+
public Task ResetLocalTicketsDB()
{
throw new NotImplementedException();
diff --git a/BryceDocker/grafana/provisioning/dashboards/logging-dashboard.json b/BryceDocker/grafana/provisioning/dashboards/logging-dashboard.json
new file mode 100644
index 0000000..ca490d6
--- /dev/null
+++ b/BryceDocker/grafana/provisioning/dashboards/logging-dashboard.json
@@ -0,0 +1,235 @@
+{
+ "annotations": {
+ "list": [
+ {
+ "builtIn": 1,
+ "datasource": {
+ "type": "grafana",
+ "uid": "-- Grafana --"
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "target": {
+ "limit": 100,
+ "matchAny": false,
+ "tags": [],
+ "type": "dashboard"
+ },
+ "type": "dashboard"
+ }
+ ]
+ },
+ "editable": true,
+ "fiscalYearStartMonth": 0,
+ "graphTooltip": 0,
+ "id": 3,
+ "links": [],
+ "liveNow": false,
+ "panels": [
+ {
+ "datasource": {
+ "type": "loki",
+ "uid": "loki"
+ },
+ "gridPos": {
+ "h": 8,
+ "w": 12,
+ "x": 0,
+ "y": 0
+ },
+ "id": 6,
+ "options": {
+ "dedupStrategy": "none",
+ "enableLogDetails": true,
+ "prettifyLogMessage": false,
+ "showCommonLabels": false,
+ "showLabels": false,
+ "showTime": false,
+ "sortOrder": "Descending",
+ "wrapLogMessage": false
+ },
+ "targets": [
+ {
+ "datasource": {
+ "type": "loki",
+ "uid": "loki"
+ },
+ "editorMode": "code",
+ "expr": "{exporter=\"OTLP\"} | json | line_format \"{{.body}}\" |~ \".*Getting All Event.*\"",
+ "queryType": "range",
+ "refId": "A"
+ }
+ ],
+ "title": "Events information",
+ "type": "logs"
+ },
+ {
+ "datasource": {
+ "type": "loki",
+ "uid": "loki"
+ },
+ "gridPos": {
+ "h": 8,
+ "w": 12,
+ "x": 12,
+ "y": 0
+ },
+ "id": 8,
+ "options": {
+ "dedupStrategy": "none",
+ "enableLogDetails": true,
+ "prettifyLogMessage": false,
+ "showCommonLabels": false,
+ "showLabels": false,
+ "showTime": false,
+ "sortOrder": "Descending",
+ "wrapLogMessage": false
+ },
+ "targets": [
+ {
+ "datasource": {
+ "type": "loki",
+ "uid": "loki"
+ },
+ "editorMode": "code",
+ "expr": "{exporter=\"OTLP\"} | json | line_format \"{{.body}}\" |~ \".*Getting All Ticket.*\"",
+ "queryType": "range",
+ "refId": "A"
+ }
+ ],
+ "title": "Tickets Information",
+ "type": "logs"
+ },
+ {
+ "datasource": {
+ "type": "loki",
+ "uid": "loki"
+ },
+ "gridPos": {
+ "h": 8,
+ "w": 12,
+ "x": 0,
+ "y": 8
+ },
+ "id": 4,
+ "options": {
+ "dedupStrategy": "none",
+ "enableLogDetails": true,
+ "prettifyLogMessage": false,
+ "showCommonLabels": false,
+ "showLabels": false,
+ "showTime": false,
+ "sortOrder": "Descending",
+ "wrapLogMessage": false
+ },
+ "targets": [
+ {
+ "datasource": {
+ "type": "loki",
+ "uid": "loki"
+ },
+ "editorMode": "code",
+ "expr": "{exporter=\"OTLP\"} | json | line_format \"{{.body}}\" |~ \".*Testing the eve.*\"",
+ "queryType": "range",
+ "refId": "A"
+ }
+ ],
+ "title": "Events Error",
+ "type": "logs"
+ },
+ {
+ "datasource": {
+ "type": "loki",
+ "uid": "loki"
+ },
+ "gridPos": {
+ "h": 8,
+ "w": 12,
+ "x": 12,
+ "y": 8
+ },
+ "id": 10,
+ "options": {
+ "dedupStrategy": "none",
+ "enableLogDetails": true,
+ "prettifyLogMessage": false,
+ "showCommonLabels": false,
+ "showLabels": false,
+ "showTime": false,
+ "sortOrder": "Descending",
+ "wrapLogMessage": false
+ },
+ "targets": [
+ {
+ "datasource": {
+ "type": "loki",
+ "uid": "loki"
+ },
+ "editorMode": "code",
+ "expr": "{exporter=\"OTLP\"} | json | line_format \"{{.body}}\" |~ \".*Testing the ticket.*\"",
+ "queryType": "range",
+ "refId": "A"
+ }
+ ],
+ "title": "Tickets Error",
+ "type": "logs"
+ },
+ {
+ "datasource": {
+ "type": "loki",
+ "uid": "loki"
+ },
+ "gridPos": {
+ "h": 9,
+ "w": 12,
+ "x": 0,
+ "y": 16
+ },
+ "id": 2,
+ "options": {
+ "dedupStrategy": "none",
+ "enableLogDetails": true,
+ "prettifyLogMessage": false,
+ "showCommonLabels": false,
+ "showLabels": false,
+ "showTime": false,
+ "sortOrder": "Descending",
+ "wrapLogMessage": false
+ },
+ "targets": [
+ {
+ "datasource": {
+ "type": "loki",
+ "uid": "loki"
+ },
+ "editorMode": "code",
+ "expr": "{exporter=\"OTLP\"} | json | line_format \"{{.body}}\" |~ \".*Something about events.*\"",
+ "queryType": "range",
+ "refId": "A"
+ }
+ ],
+ "title": "Events Warn",
+ "type": "logs"
+ }
+ ],
+ "refresh": "",
+ "revision": 1,
+ "schemaVersion": 38,
+ "style": "dark",
+ "tags": [],
+ "templating": {
+ "list": []
+ },
+ "time": {
+ "from": "now-6h",
+ "to": "now"
+ },
+ "timepicker": {},
+ "timezone": "",
+ "title": "Events warn",
+ "uid": "4HO7dJJIk",
+ "version": 6,
+ "weekStart": ""
+}
\ No newline at end of file
diff --git a/TicketLibrary/Pages/Tickets.razor b/TicketLibrary/Pages/Tickets.razor
index a9e5409..656b82d 100644
--- a/TicketLibrary/Pages/Tickets.razor
+++ b/TicketLibrary/Pages/Tickets.razor
@@ -36,7 +36,11 @@
public List events = new();
protected override async Task OnInitializedAsync(){
+
tickets = await ticketService.GetAllTicketsAsync();
+ ticketService.InvokeTicketsLogger1(1);
+ ticketService.InvokeTicketsLogger2(2);
+
events = await eventService.GetAllEventsAsync();
}
}
\ No newline at end of file
diff --git a/TicketLibrary/Pages/WebEvent.razor b/TicketLibrary/Pages/WebEvent.razor
index 7561fbd..7ee05dd 100644
--- a/TicketLibrary/Pages/WebEvent.razor
+++ b/TicketLibrary/Pages/WebEvent.razor
@@ -33,6 +33,9 @@
protected override async Task OnInitializedAsync()
{
events = await eventService.GetAllEventsAsync();
+ eventService.InvokeEventsLogger1(1);
+ eventService.InvokeEventsLogger2(2);
+
}
//send the email with qr code
diff --git a/TicketLibrary/Services/IEventService.cs b/TicketLibrary/Services/IEventService.cs
index 7da6f49..edf1aa8 100644
--- a/TicketLibrary/Services/IEventService.cs
+++ b/TicketLibrary/Services/IEventService.cs
@@ -10,5 +10,9 @@ namespace TicketLibrary.Services;
public interface IEventService
{
public Task> GetAllEventsAsync();
+ public void InvokeEventsLogger1(int number);
+ public void InvokeEventsLogger2(int number);
+
+
}
diff --git a/TicketLibrary/Services/ITicketService.cs b/TicketLibrary/Services/ITicketService.cs
index bd18ed3..5f4852d 100644
--- a/TicketLibrary/Services/ITicketService.cs
+++ b/TicketLibrary/Services/ITicketService.cs
@@ -20,6 +20,7 @@ public interface ITicketService
public Task ChangeBaseAddress(string newBaseAddress);
public Task ResetLocalTicketsDB();
public Task SyncDatabases();
-
+ public void InvokeTicketsLogger1(int number);
+ public void InvokeTicketsLogger2(int number);
}