Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CU-8687yhbz5 sentry logging changes #122

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/Resgrid.Config/ExternalErrorConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static class ExternalErrorConfig
public static string ExternalErrorServiceUrlForInternalApi = "";
public static string ExternalErrorServiceUrlForInternalWorker = "";
public static double SentryPerfSampleRate = 0.4;
public static double SentryProfilingSampleRate = 0;
#endregion Sentry Settings

#region Application Insights Settings
Expand Down
14 changes: 13 additions & 1 deletion Core/Resgrid.Framework/Logging.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Resgrid.Config;
using Microsoft.Extensions.Options;
using Resgrid.Config;
using Sentry;
using Sentry.Profiling;
using Serilog;
using Serilog.Core;
using Serilog.Events;
Expand All @@ -10,6 +12,7 @@
using System.Net.Mail;
using System.Reflection;
using System.Runtime.CompilerServices;
using static NodaTime.TimeZones.ZoneEqualityComparer;

namespace Resgrid.Framework
{
Expand Down Expand Up @@ -39,9 +42,18 @@ public static void Initialize(string key)
o.Dsn = dsn;
o.AttachStacktrace = true;
o.SendDefaultPii = true;
o.AutoSessionTracking = true;
o.TracesSampleRate = ExternalErrorConfig.SentryPerfSampleRate;
o.Environment = ExternalErrorConfig.Environment;
o.Release = Assembly.GetEntryAssembly().GetName().Version.ToString();
o.ProfilesSampleRate = ExternalErrorConfig.SentryProfilingSampleRate;

// Requires NuGet package: Sentry.Profiling
// Note: By default, the profiler is initialized asynchronously. This can be tuned by passing a desired initialization timeout to the constructor.
o.AddIntegration(new ProfilingIntegration(
// During startup, wait up to 500ms to profile the app startup code. This could make launching the app a bit slower so comment it out if your prefer profiling to start asynchronously
//TimeSpan.FromMilliseconds(500)
));
}).CreateLogger();
}
else if (SystemBehaviorConfig.ErrorLoggerType == ErrorLoggerTypes.Elk)
Expand Down
6 changes: 4 additions & 2 deletions Core/Resgrid.Framework/Resgrid.Framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
<PackageReference Include="HtmlAgilityPack" Version="1.11.59" />
<PackageReference Include="NodaTime" Version="3.1.11" />
<PackageReference Include="protobuf-net" Version="3.2.30" />
<PackageReference Include="Sentry" Version="4.2.1" />
<PackageReference Include="Sentry.Serilog" Version="4.2.1" />
<PackageReference Include="Sentry" Version="4.6.2" />
<PackageReference Include="Sentry.AspNetCore" Version="4.6.2" />
<PackageReference Include="Sentry.Profiling" Version="4.6.2" />
<PackageReference Include="Sentry.Serilog" Version="4.6.2" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
<PackageReference Include="TimeZoneConverter" Version="6.1.0" />
Expand Down
2 changes: 2 additions & 0 deletions Providers/Resgrid.Providers.Claims/ClaimsPrincipalFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Resgrid.Model.Identity;
using Resgrid.Model.Repositories;
using Resgrid.Model.Services;
using IdentityRole = Resgrid.Model.Identity.IdentityRole;
using IdentityUser = Resgrid.Model.Identity.IdentityUser;

namespace Resgrid.Providers.Claims
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using IdentityRole = Resgrid.Model.Identity.IdentityRole;
using IdentityUser = Resgrid.Model.Identity.IdentityUser;

namespace Resgrid.Repositories.DataRepository
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using IdentityRole = Resgrid.Model.Identity.IdentityRole;
using IdentityUser = Resgrid.Model.Identity.IdentityUser;

namespace Resgrid.Repositories.DataRepository.Stores
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using IdentityRole = Resgrid.Model.Identity.IdentityRole;
using IdentityUser = Resgrid.Model.Identity.IdentityUser;

namespace Resgrid.Repositories.DataRepository.Stores
{
Expand Down
1 change: 1 addition & 0 deletions Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="Sentry.AspNetCore" Version="4.6.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\Resgrid.Config\Resgrid.Config.csproj" />
Expand Down
10 changes: 10 additions & 0 deletions Web/Resgrid.Web.ServicesCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Resgrid.Config;
using Sentry.Profiling;

namespace Resgrid.Web.ServicesCore
{
Expand Down Expand Up @@ -40,9 +41,18 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
options.Dsn = Config.ExternalErrorConfig.ExternalErrorServiceUrlForApi;
options.AttachStacktrace = true;
options.SendDefaultPii = true;
options.AutoSessionTracking = true;
options.TracesSampleRate = ExternalErrorConfig.SentryPerfSampleRate;
options.Environment = ExternalErrorConfig.Environment;
options.Release = Assembly.GetEntryAssembly().GetName().Version.ToString();
options.ProfilesSampleRate = ExternalErrorConfig.SentryProfilingSampleRate;

// Requires NuGet package: Sentry.Profiling
// Note: By default, the profiler is initialized asynchronously. This can be tuned by passing a desired initialization timeout to the constructor.
options.AddIntegration(new ProfilingIntegration(
// During startup, wait up to 500ms to profile the app startup code. This could make launching the app a bit slower so comment it out if your prefer profiling to start asynchronously
//TimeSpan.FromMilliseconds(500)
));

options.TracesSampler = samplingContext =>
{
Expand Down
4 changes: 2 additions & 2 deletions Web/Resgrid.Web.ServicesCore/Resgrid.Web.ServicesCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="protobuf-net" Version="3.2.30" />
<PackageReference Include="Sentry" Version="4.2.1" />
<PackageReference Include="Sentry.AspNetCore" Version="4.2.1" />
<PackageReference Include="Sentry" Version="4.6.2" />
<PackageReference Include="Sentry.AspNetCore" Version="4.6.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
Expand Down
10 changes: 10 additions & 0 deletions Web/Resgrid.WebCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Resgrid.Config;
using Sentry.Profiling;

namespace Resgrid.Web
{
Expand Down Expand Up @@ -41,7 +42,16 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
options.SendDefaultPii = true;
options.TracesSampleRate = ExternalErrorConfig.SentryPerfSampleRate;
options.Environment = ExternalErrorConfig.Environment;
options.AutoSessionTracking = true;
options.Release = Assembly.GetEntryAssembly().GetName().Version.ToString();
options.ProfilesSampleRate = ExternalErrorConfig.SentryProfilingSampleRate;

// Requires NuGet package: Sentry.Profiling
// Note: By default, the profiler is initialized asynchronously. This can be tuned by passing a desired initialization timeout to the constructor.
options.AddIntegration(new ProfilingIntegration(
// During startup, wait up to 500ms to profile the app startup code. This could make launching the app a bit slower so comment it out if your prefer profiling to start asynchronously
//TimeSpan.FromMilliseconds(500)
));

options.TracesSampler = samplingContext =>
{
Expand Down
4 changes: 2 additions & 2 deletions Web/Resgrid.WebCore/Resgrid.WebCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="protobuf-net" Version="3.2.30" />
<PackageReference Include="Sentry" Version="4.2.1" />
<PackageReference Include="Sentry.AspNetCore" Version="4.2.1" />
<PackageReference Include="Sentry" Version="4.6.2" />
<PackageReference Include="Sentry.AspNetCore" Version="4.6.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
Expand Down
Loading