From 7b2a0c2fea17da5c34e3d02b076988b6ec6db5aa Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Sat, 27 Jan 2024 15:37:54 -0500 Subject: [PATCH] Add OpenTelemetry to Environment service --- Environment/Service/Program.cs | 4 ++++ Environment/Service/Service.csproj | 1 + Environment/Service/appsettings.json | 7 +++++-- Weather/SerialReader/appsettings.json | 6 ++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Environment/Service/Program.cs b/Environment/Service/Program.cs index 47788ad..5c7901b 100644 --- a/Environment/Service/Program.cs +++ b/Environment/Service/Program.cs @@ -1,4 +1,6 @@ +using ChrisKaczor.Common.OpenTelemetry; using ChrisKaczor.HomeMonitor.Environment.Service.Data; +using System.Reflection; namespace ChrisKaczor.HomeMonitor.Environment.Service; @@ -10,6 +12,8 @@ public static class Program builder.Configuration.AddEnvironmentVariables(); + builder.Services.AddCommonOpenTelemetry(Assembly.GetExecutingAssembly().GetName().Name, builder.Configuration["Telemetry:Endpoint"], nameof(MessageHandler)); + builder.Services.AddControllers(); builder.Services.AddTransient(); diff --git a/Environment/Service/Service.csproj b/Environment/Service/Service.csproj index 0729f44..61155af 100644 --- a/Environment/Service/Service.csproj +++ b/Environment/Service/Service.csproj @@ -20,6 +20,7 @@ + diff --git a/Environment/Service/appsettings.json b/Environment/Service/appsettings.json index 4826422..3bf5e22 100644 --- a/Environment/Service/appsettings.json +++ b/Environment/Service/appsettings.json @@ -1,8 +1,8 @@ { "Logging": { "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Default": "Warning", + "Microsoft": "Information" } }, "AllowedHosts": "*", @@ -22,5 +22,8 @@ "Hub": { "Url": "http://hub-server/environment" } + }, + "Telemetry": { + "Endpoint": "http://signoz-otel-collector.platform:4317/" } } diff --git a/Weather/SerialReader/appsettings.json b/Weather/SerialReader/appsettings.json index cbe2868..64c8f0d 100644 --- a/Weather/SerialReader/appsettings.json +++ b/Weather/SerialReader/appsettings.json @@ -1,4 +1,10 @@ { + "Logging": { + "LogLevel": { + "Default": "Warning", + "Microsoft": "Information" + } + }, "Weather": { "Port": { "Prefix": "/dev/ttyACM",