Enhancing telemetry in Seq and fixes namespaces

This commit is contained in:
Janus C. H. Knudsen 2025-02-20 00:23:13 +01:00
parent 5568007237
commit 9f4996bc8f
65 changed files with 1122 additions and 1139 deletions

View file

@ -1,21 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<None Remove="App.ts" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" />
<ProjectReference Include="..\Database\Database.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Components\" />
</ItemGroup>
</Project>

View file

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.Mvc.Razor;
namespace Application.Common namespace PlanTempus.Application.Common
{ {
public class ComponentsViewLocationExpander : IViewLocationExpander public class ComponentsViewLocationExpander : IViewLocationExpander
{ {

View file

@ -1,7 +1,7 @@
using Microsoft.ApplicationInsights; using Microsoft.ApplicationInsights;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace Application.Components.Navigation namespace PlanTempus.Application.Components.Navigation
{ {
public class NavigationViewComponent : ViewComponent public class NavigationViewComponent : ViewComponent
{ {

View file

@ -1,5 +1,5 @@
@page @page
@model IndexModel @model PlanTempus.Application.Pages.IndexModel
@{ @{
ViewData["Title"] = "Home page"; ViewData["Title"] = "Home page";
} }

View file

@ -3,7 +3,7 @@ using Microsoft.ApplicationInsights;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages;
namespace PlanTempus.Pages namespace PlanTempus.Application.Pages
{ {
public class IndexModel : PageModel public class IndexModel : PageModel
{ {

View file

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<None Remove="App.ts" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\PlanTempus.Core.csproj" />
<ProjectReference Include="..\Database\PlanTempus.Database.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Components\" />
</ItemGroup>
</Project>

View file

@ -1,5 +1,5 @@
using Application;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
using PlanTempus.Application;
var host = Host.CreateDefaultBuilder(args) var host = Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory()) .UseServiceProviderFactory(new AutofacServiceProviderFactory())

View file

@ -1,8 +1,9 @@
using Autofac; using Autofac;
using Core.Configurations.JsonConfigProvider; using PlanTempus.Core.Configurations.JsonConfigProvider;
using Core.Configurations; using PlanTempus.Core.Configurations;
using PlanTempus.Core.ModuleRegistry;
namespace Application namespace PlanTempus.Application
{ {
public class Startup public class Startup
{ {
@ -39,9 +40,9 @@ namespace Application
ConnectionString = ConfigurationRoot.GetConnectionString("ptdb") ConnectionString = ConfigurationRoot.GetConnectionString("ptdb")
}); });
builder.RegisterModule(new Core.ModuleRegistry.TelemetryModule builder.RegisterModule(new TelemetryModule
{ {
TelemetryConfig = ConfigurationRoot.GetSection(nameof(Core.ModuleRegistry.TelemetryConfig)).ToObject<Core.ModuleRegistry.TelemetryConfig>() TelemetryConfig = ConfigurationRoot.GetSection(nameof(TelemetryConfig)).ToObject<TelemetryConfig>()
}); });

View file

@ -4,11 +4,7 @@
"ptdb": "Host=localhost;Port=5433;Database=ptdb01;User Id=sathumper;Password=3911;" "ptdb": "Host=localhost;Port=5433;Database=ptdb01;User Id=sathumper;Password=3911;"
}, },
"TelemetryConfig": { "TelemetryConfig": {
"ConnectionString": "InstrumentationKey=07d2a2b9-5e8e-4924-836e-264f8438f6c5;IngestionEndpoint=https://northeurope-2.in.applicationinsights.azure.com/;LiveEndpoint=https://northeurope.livediagnostics.monitor.azure.com/;ApplicationId=56748c39-2fa3-4880-a1e2-24068e791548" "ConnectionString": "InstrumentationKey=07d2a2b9-5e8e-4924-836e-264f8438f6c5;IngestionEndpoint=https://northeurope-2.in.applicationinsights.azure.com/;LiveEndpoint=https://northeurope.livediagnostics.monitor.azure.com/;ApplicationId=56748c39-2fa3-4880-a1e2-24068e791548",
}, "UseSeqLoggingTelemetryChannel": true
"Feature": {
"Enabled": true,
"RolloutPercentage": 25,
"AllowedUserGroups": [ "beta" ]
} }
} }

View file

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Core.Configurations.Common namespace PlanTempus.Core.Configurations.Common
{ {
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;

View file

@ -1,5 +1,5 @@
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace Core.Configurations namespace PlanTempus.Core.Configurations
{ {
public interface IConfigurationBuilder public interface IConfigurationBuilder
{ {
@ -133,7 +133,7 @@ namespace Core.Configurations
public interface IConfigurationProvider public interface IConfigurationProvider
{ {
void Build(); void Build();
Newtonsoft.Json.Linq.JObject Configuration(); JObject Configuration();
} }
public class ConfigurationSection : IConfigurationSection public class ConfigurationSection : IConfigurationSection
@ -148,6 +148,6 @@ namespace Core.Configurations
{ {
string Path { get; } string Path { get; }
string Key { get; } string Key { get; }
Newtonsoft.Json.Linq.JToken Value { get; set; } JToken Value { get; set; }
} }
} }

View file

@ -1,4 +1,4 @@
namespace Core.Configurations namespace PlanTempus.Core.Configurations
{ {
/// <summary> /// <summary>
/// Marker interface for application configurations that should be automatically registered in the DI container. /// Marker interface for application configurations that should be automatically registered in the DI container.

View file

@ -1,4 +1,4 @@
namespace Core.Configurations namespace PlanTempus.Core.Configurations
{ {
public interface IConfigurationRoot : IConfiguration { } public interface IConfigurationRoot : IConfiguration { }

View file

@ -1,8 +1,9 @@
using Core.Exceptions; using PlanTempus.Core.Exceptions;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using PlanTempus.Core.Configurations;
namespace Core.Configurations.JsonConfigProvider namespace PlanTempus.Core.Configurations.JsonConfigProvider
{ {
public static class JsonConfigExtension public static class JsonConfigExtension
{ {

View file

@ -1,4 +1,4 @@
namespace Core.Configurations.SmartConfigProvider; namespace PlanTempus.Core.Configurations.SmartConfigProvider;
public class AppConfiguration public class AppConfiguration
{ {
public long Id { get; set; } public long Id { get; set; }

View file

@ -1,4 +1,4 @@
namespace Core.Configurations.SmartConfigProvider; namespace PlanTempus.Core.Configurations.SmartConfigProvider;
public interface IConfigurationRepository public interface IConfigurationRepository
{ {
string ConnectionString { get; set; } string ConnectionString { get; set; }

View file

@ -1,7 +1,7 @@
using System.Data; using System.Data;
using Insight.Database; using Insight.Database;
namespace Core.Configurations.SmartConfigProvider.Repositories; namespace PlanTempus.Core.Configurations.SmartConfigProvider.Repositories;
public class PostgresConfigurationRepository : IConfigurationRepository public class PostgresConfigurationRepository : IConfigurationRepository
{ {
private IDbConnection _connection; private IDbConnection _connection;

View file

@ -1,4 +1,6 @@
namespace Core.Configurations.SmartConfigProvider using PlanTempus.Core.Configurations;
namespace PlanTempus.Core.Configurations.SmartConfigProvider
{ {
/// <summary> /// <summary>
/// Extension methods for adding smart configuration providers to IConfigurationBuilder. /// Extension methods for adding smart configuration providers to IConfigurationBuilder.

View file

@ -1,4 +1,4 @@
namespace Core.Configurations.SmartConfigProvider namespace PlanTempus.Core.Configurations.SmartConfigProvider
{ {
/// <summary> /// <summary>
/// Configuration options for setting up smart configuration providers. /// Configuration options for setting up smart configuration providers.

View file

@ -1,9 +1,9 @@
using Core.Configurations.JsonConfigProvider;
using Core.Exceptions;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using PlanTempus.Core.Configurations.JsonConfigProvider;
using PlanTempus.Core.Exceptions;
namespace Core.Configurations.SmartConfigProvider namespace PlanTempus.Core.Configurations.SmartConfigProvider
{ {
/// <summary> /// <summary>
/// Configuration provider that loads configuration from a smart configuration source (e.g. database). /// Configuration provider that loads configuration from a smart configuration source (e.g. database).

View file

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Core.Entities.Users namespace PlanTempus.Core.Entities.Users
{ {
public class User public class User
{ {

View file

@ -1,4 +1,4 @@
namespace Core.Entities.Users namespace PlanTempus.Core.Entities.Users
{ {
public static class PasswordHasher public static class PasswordHasher
{ {

View file

@ -1,4 +1,4 @@
namespace Core.Exceptions namespace PlanTempus.Core.Exceptions
{ {
internal class ConfigurationException : Exception internal class ConfigurationException : Exception
{ {

View file

@ -1,20 +1,20 @@
using Core.Telemetry; using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts; using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using PlanTempus.Core.Telemetry;
namespace Core.Logging namespace PlanTempus.Core.Logging
{ {
public class SeqBackgroundService : BackgroundService public class SeqBackgroundService : BackgroundService
{ {
private readonly IMessageChannel<ITelemetry> _messageChannel; private readonly IMessageChannel<ITelemetry> _messageChannel;
private readonly TelemetryClient _telemetryClient; private readonly TelemetryClient _telemetryClient;
private readonly SeqLogger _seqLogger; private readonly SeqLogger<SeqBackgroundService> _seqLogger;
public SeqBackgroundService(TelemetryClient telemetryClient, public SeqBackgroundService(TelemetryClient telemetryClient,
IMessageChannel<ITelemetry> messageChannel, IMessageChannel<ITelemetry> messageChannel,
SeqLogger seqlogger) SeqLogger<SeqBackgroundService> seqlogger)
{ {
_telemetryClient = telemetryClient; _telemetryClient = telemetryClient;
_messageChannel = messageChannel; _messageChannel = messageChannel;

View file

@ -1,7 +1,7 @@
using Microsoft.ApplicationInsights.DataContracts; using Microsoft.ApplicationInsights.DataContracts;
using System.Text; using System.Text;
namespace Core.Logging namespace PlanTempus.Core.Logging
{ {
public record SeqConfiguration(string IngestionEndpoint, string ApiKey, string Environment); public record SeqConfiguration(string IngestionEndpoint, string ApiKey, string Environment);
} }

View file

@ -1,5 +1,4 @@
namespace PlanTempus.Core.Logging
namespace Core.Logging
{ {
public class SeqHttpClient public class SeqHttpClient
{ {

View file

@ -1,9 +1,9 @@
using Microsoft.ApplicationInsights.DataContracts; using Microsoft.ApplicationInsights.DataContracts;
using System.Text; using System.Text;
namespace Core.Logging namespace PlanTempus.Core.Logging
{ {
public class SeqLogger public class SeqLogger<T>
{ {
private readonly SeqHttpClient _httpClient; private readonly SeqHttpClient _httpClient;
private readonly string _environmentName; private readonly string _environmentName;
@ -13,8 +13,6 @@ namespace Core.Logging
public SeqLogger(SeqHttpClient httpClient, string environmentName, SeqConfiguration configuration) public SeqLogger(SeqHttpClient httpClient, string environmentName, SeqConfiguration configuration)
{ {
_httpClient = httpClient; _httpClient = httpClient;
_environmentName = configuration.Environment;
_machineName = Environment.MachineName;
} }
public async Task LogAsync(TraceTelemetry trace, CancellationToken cancellationToken = default) public async Task LogAsync(TraceTelemetry trace, CancellationToken cancellationToken = default)
@ -29,9 +27,10 @@ namespace Core.Logging
}; };
foreach (var prop in trace.Properties) foreach (var prop in trace.Properties)
{ seqEvent.Add($"prop_{prop.Key}", prop.Value);
seqEvent.Add(prop.Key, prop.Value);
} foreach (var prop in trace.Context.GlobalProperties)
seqEvent.Add($"global_{prop.Key}", prop.Value);
await SendToSeqAsync(seqEvent, cancellationToken); await SendToSeqAsync(seqEvent, cancellationToken);
} }
@ -48,14 +47,13 @@ namespace Core.Logging
}; };
foreach (var prop in evt.Properties) foreach (var prop in evt.Properties)
{ seqEvent.Add($"prop_{prop.Key}", prop.Value);
seqEvent.Add(prop.Key, prop.Value);
} foreach (var prop in evt.Context.GlobalProperties)
seqEvent.Add($"global_{prop.Key}", prop.Value);
foreach (var metric in evt.Metrics) foreach (var metric in evt.Metrics)
{
seqEvent.Add($"metric_{metric.Key}", metric.Value); seqEvent.Add($"metric_{metric.Key}", metric.Value);
}
await SendToSeqAsync(seqEvent, cancellationToken); await SendToSeqAsync(seqEvent, cancellationToken);
} }
@ -74,9 +72,10 @@ namespace Core.Logging
}; };
foreach (var prop in ex.Properties) foreach (var prop in ex.Properties)
{ seqEvent.Add($"prop_{prop.Key}", prop.Value);
seqEvent.Add(prop.Key, prop.Value);
} foreach (var prop in ex.Context.GlobalProperties)
seqEvent.Add($"global_{prop.Key}", prop.Value);
await SendToSeqAsync(seqEvent, cancellationToken); await SendToSeqAsync(seqEvent, cancellationToken);
} }
@ -96,73 +95,65 @@ namespace Core.Logging
}; };
foreach (var prop in dep.Properties) foreach (var prop in dep.Properties)
{ seqEvent.Add($"prop_{prop.Key}", prop.Value);
seqEvent.Add(prop.Key, prop.Value);
} foreach (var prop in dep.Context.GlobalProperties)
seqEvent.Add($"global_{prop.Key}", prop.Value);
await SendToSeqAsync(seqEvent, cancellationToken); await SendToSeqAsync(seqEvent, cancellationToken);
} }
public async Task LogAsync(RequestTelemetry req, CancellationToken cancellationToken = default) public async Task LogAsync(RequestTelemetry req, CancellationToken cancellationToken = default)
{ {
var seqEvent = new Dictionary<string, object> throw new NotImplementedException();
{
{ "@t", req.Timestamp.UtcDateTime.ToString("o") },
{ "@mt",$"{req.Properties["httpMethod"]} {req.Name}" },
{ "@l", req.Success??true ? "Information" : "Error" },
{ "Environment", _environmentName },
{ "MachineName", _machineName },
{ "Url", req.Url },
{ "ResponseCode", req.ResponseCode },
{ "Application", "sadasd" },
{ "RequestMethod", req.Properties["httpMethod"] },
{ "RequestId", req.Id },
{ "ItemTypeFlag", req.ItemTypeFlag.ToString() },
{ "@sp", "12"},
{ "@tr", "23344"},
{ "@sk","Server" },
{ "@st", req.Timestamp.UtcDateTime.Subtract(req.Duration).ToString("o") }
};
req.Properties.Remove("httpMethod");
//we should add a property with name { "Application", "<...>" } other the Seq Span is not looking ok
foreach (var prop in req.Properties)
{
seqEvent.Add(prop.Key, prop.Value);
}
await SendToSeqAsync(seqEvent, cancellationToken);
} }
public async Task LogAsync(Microsoft.ApplicationInsights.Extensibility.IOperationHolder<RequestTelemetry> operationHolder, CancellationToken cancellationToken = default) public async Task LogAsync(Microsoft.ApplicationInsights.Extensibility.IOperationHolder<RequestTelemetry> operationHolder, CancellationToken cancellationToken = default)
{ {
var req = operationHolder.Telemetry; var req = operationHolder.Telemetry;
//https://docs.datalust.co/v2025.1/docs/posting-raw-events
var seqEvent = new Dictionary<string, object> var seqEvent = new Dictionary<string, object>
{ {
{ "@t", req.Timestamp.UtcDateTime.ToString("o") }, { "@t", req.Timestamp.UtcDateTime.ToString("o") },
{ "@mt",$"{req.Properties["httpMethod"]} {req.Name}" }, { "@mt",req.Name },
{ "@l", req.Success??true ? "Information" : "Error" }, { "@l", req.Success??true ? "Information" : "Error" },
{ "Environment", _environmentName }, { "@sp", req.Id }, //Span id Unique identifier of a span Yes, if the event is a span
{ "MachineName", _machineName }, { "@tr", req.Context.Operation.Id}, //Trace id An identifier that groups all spans and logs that are in the same trace Yes, if the event is a span
{ "@sk","Server" }, //Span kind Describes the relationship of the span to others in the trace: Client, Server, Internal, Producer, or Consumer
{ "@st", req.Timestamp.UtcDateTime.Subtract(req.Duration).ToString("o") }, //Start The start ISO 8601 timestamp of this span Yes, if the event is a span
{ "SourceContext", typeof(T).FullName },
{ "Url", req.Url }, { "Url", req.Url },
{ "ResponseCode", req.ResponseCode },
{ "Application", "sadasd" },
{ "RequestMethod", req.Properties["httpMethod"] },
{ "RequestId", req.Id }, { "RequestId", req.Id },
{ "ItemTypeFlag", req.ItemTypeFlag.ToString() }, { "ItemTypeFlag", req.ItemTypeFlag.ToString() }
{ "@sp", "12"},
{ "@tr", "23344"},
{ "@sk","Server" },
{ "@st", req.Timestamp.UtcDateTime.Subtract(req.Duration).ToString("o") }
}; };
req.Properties.Remove("httpMethod");
//we should add a property with name { "Application", "<...>" } other the Seq Span is not looking ok
foreach (var prop in req.Properties) if (!string.IsNullOrEmpty(req.ResponseCode))
{ {
seqEvent.Add(prop.Key, prop.Value); if (int.TryParse(req.ResponseCode, out int statusCode))
{
if (Enum.IsDefined(typeof(System.Net.HttpStatusCode), statusCode))
seqEvent["StatusCode"] = $"{statusCode} {(System.Net.HttpStatusCode)statusCode}";
else
seqEvent["StatusCode"] = $"{statusCode} Unknown";
} }
}
if (!string.IsNullOrEmpty(req.Context.Operation.ParentId))
seqEvent["@ps"] = req.Context.Operation.ParentId;
if (req.Properties.TryGetValue("httpMethod", out string method))
{
seqEvent["RequestMethod"] = method;
seqEvent["@mt"] = $"{req.Properties["httpMethod"]} {req.Name}";
req.Properties.Remove("httpMethod");
}
foreach (var prop in req.Properties)
seqEvent.Add($"prop_{prop.Key}", prop.Value);
foreach (var prop in req.Context.GlobalProperties)
seqEvent.Add($"global_{prop.Key}", prop.Value);
await SendToSeqAsync(seqEvent, cancellationToken); await SendToSeqAsync(seqEvent, cancellationToken);
} }

View file

@ -1,8 +1,8 @@
using Autofac; using Autofac;
using Core.Logging; using PlanTempus.Core.Logging;
using Core.Telemetry; using PlanTempus.Core.Telemetry;
namespace Core.ModuleRegistry namespace PlanTempus.Core.ModuleRegistry
{ {
public class SeqLoggingModule : Module public class SeqLoggingModule : Module
{ {

View file

@ -1,71 +1,48 @@
using Autofac; using Autofac;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;
namespace Core.ModuleRegistry namespace PlanTempus.Core.ModuleRegistry
{ {
public class TelemetryModule : Module public class TelemetryModule : Module
{ {
public TelemetryConfig TelemetryConfig { get; set; } public TelemetryConfig TelemetryConfig { get; set; }
protected override void Load(ContainerBuilder builder) protected override void Load(ContainerBuilder builder)
{ {
if (TelemetryConfig == null) if (TelemetryConfig == null)
throw new Exceptions.ConfigurationException("TelemetryConfig is missing"); throw new Exceptions.ConfigurationException("TelemetryConfig is missing");
//builder.Register(c =>
//{
// var channel = new Telemetry.DualTelemetryChannel("C:\\logs\\telemetry.log");
// channel.DeveloperMode = true;
// var config = new TelemetryConfiguration
// {
// ConnectionString = TelemetryConfig.ConnectionString, var configuration = TelemetryConfiguration.CreateDefault();
// TelemetryChannel = channel configuration.ConnectionString = TelemetryConfig.ConnectionString;
// }; configuration.TelemetryChannel.DeveloperMode = true;
// return new TelemetryClient(config);
//}).InstancePerLifetimeScope();
var telemetryChannel = new InMemoryChannel if (TelemetryConfig.UseSeqLoggingTelemetryChannel)
{ configuration.TelemetryChannel = new Telemetry.SeqLoggingTelemetryChannel(); ;
DeveloperMode = true
};
//var configuration = new TelemetryConfiguration var r = new Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryProcessorChainBuilder(configuration);
//{ r.Use(next => new Telemetry.Enrichers.EnrichWithMetaTelemetry(next));
// ConnectionString = TelemetryConfig.ConnectionString, r.Build();
// TelemetryChannel = telemetryChannel
//};
//telemetryChannel.Initialize(configuration);
var tmc = Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.CreateDefault();
tmc.ConnectionString = TelemetryConfig.ConnectionString;
tmc.TelemetryChannel.DeveloperMode = true;
var channel = new Telemetry.SeqLoggingTelemetryChannel("C:\\logs\\telemetry.log");
tmc.TelemetryChannel = channel;
////var r = new Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryProcessorChainBuilder(tmc);
////r.Use(next => new Domain.EventTelemetryEnrichers.EnrichWithMetaTelemetry(next));
////r.Build();
//builder.RegisterInstance(configuration); //builder.RegisterInstance(configuration);
builder.Register(c => new TelemetryClient(tmc)).InstancePerLifetimeScope();
//builder.RegisterType<Microsoft.ApplicationInsights.TelemetryClient>() //builder.RegisterType<Microsoft.ApplicationInsights.TelemetryClient>()
// .InstancePerLifetimeScope(); // .InstancePerLifetimeScope();
//builder.RegisterType<Microsoft.ApplicationInsights.TelemetryClient>() var client = new Microsoft.ApplicationInsights.TelemetryClient(configuration);
// .As<Telemetry.ITelemetryClient>() client.Context.GlobalProperties["Application"] = GetType().Namespace.Split('.')[0];
// .InstancePerLifetimeScope(); client.Context.GlobalProperties["MachineName"] = Environment.MachineName;
client.Context.GlobalProperties["Version"] = Environment.Version.ToString();
client.Context.GlobalProperties["ProcessorCount"] = Environment.ProcessorCount.ToString();
builder.Register(c => client).InstancePerLifetimeScope();
} }
} }
public class TelemetryConfig public class TelemetryConfig
{ {
public string ConnectionString { get; set; } public string ConnectionString { get; set; }
public bool UseSeqLoggingTelemetryChannel { get; set; }
} }
} }

View file

@ -1,4 +1,4 @@
namespace Core.MultiKeyEncryption namespace PlanTempus.Core.MultiKeyEncryption
{ {
internal class MasterKey internal class MasterKey
{ {

View file

@ -5,7 +5,7 @@ using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Core.MultiKeyEncryption namespace PlanTempus.Core.MultiKeyEncryption
{ {
public class SecureConnectionString public class SecureConnectionString
{ {

View file

@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk"> 
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>

View file

@ -0,0 +1,22 @@
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;
namespace PlanTempus.Core.Telemetry.Enrichers
{
public class EnrichWithMetaTelemetry : ITelemetryProcessor
{
private readonly ITelemetryProcessor _next;
public EnrichWithMetaTelemetry(ITelemetryProcessor next)
{
_next = next;
}
public void Process(ITelemetry item)
{
//nothing going on here yet :)
_next.Process(item);
}
}
}

View file

@ -1,5 +1,5 @@
using System.Threading.Channels; using System.Threading.Channels;
namespace Core.Telemetry namespace PlanTempus.Core.Telemetry
{ {
public interface IMessageChannel<T> : IDisposable public interface IMessageChannel<T> : IDisposable
{ {

View file

@ -1,7 +1,7 @@
using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Channel;
using System.Threading.Channels; using System.Threading.Channels;
namespace Core.Telemetry namespace PlanTempus.Core.Telemetry
{ {
public class MessageChannel : IMessageChannel<ITelemetry> public class MessageChannel : IMessageChannel<ITelemetry>
{ {

View file

@ -1,11 +1,10 @@
using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Channel;
using System.Net.Http.Headers; using System.Net.Http.Headers;
namespace Core.Telemetry namespace PlanTempus.Core.Telemetry
{ {
public class SeqLoggingTelemetryChannel : InMemoryChannel, ITelemetryChannel public class SeqLoggingTelemetryChannel : InMemoryChannel, ITelemetryChannel
{ {
private readonly string _filePath;
public ITelemetryChannel _defaultChannel; public ITelemetryChannel _defaultChannel;
static HttpClient _client = new HttpClient(); static HttpClient _client = new HttpClient();
@ -22,9 +21,8 @@ namespace Core.Telemetry
} }
public SeqLoggingTelemetryChannel(string filePath) public SeqLoggingTelemetryChannel()
{ {
_filePath = filePath;
} }
public new void Send(ITelemetry telemetry) public new void Send(ITelemetry telemetry)
{ {

View file

@ -1,6 +1,6 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Database.Common namespace PlanTempus.Database.Common
{ {
internal class Validations internal class Validations
{ {

View file

@ -1,9 +1,10 @@
using Insight.Database; using Insight.Database;
using PlanTempus.Database.Core;
using System.Data; using System.Data;
namespace Database.ConfigurationManagementSystem; namespace PlanTempus.Database.ConfigurationManagementSystem;
public class SetupConfiguration : Core.IDbConfigure<SetupConfiguration.Command> public class SetupConfiguration : IDbConfigure<SetupConfiguration.Command>
{ {
public class Command public class Command
{ {

View file

@ -1,8 +1,9 @@
using System.Data; using System.Data;
using Database.Common;
using Insight.Database; using Insight.Database;
using PlanTempus.Database.Common;
using PlanTempus.Database.Core;
namespace Database.Core.DCL namespace PlanTempus.Database.Core.DCL
{ {
/// <summary> /// <summary>

View file

@ -1,8 +1,9 @@
using System.Data; using System.Data;
using Database.Common;
using Insight.Database; using Insight.Database;
using PlanTempus.Database.Common;
using PlanTempus.Database.Core;
namespace Database.Core.DCL namespace PlanTempus.Database.Core.DCL
{ {
/// <summary> /// <summary>

View file

@ -1,8 +1,9 @@
using System.Data; using System.Data;
using Database.Common;
using Insight.Database; using Insight.Database;
using PlanTempus.Database.Common;
using PlanTempus.Database.Core;
namespace Database.Core.DCL namespace PlanTempus.Database.Core.DCL
{ {
public class SetupOrganization : IDbConfigure<SetupOrganization.Command> public class SetupOrganization : IDbConfigure<SetupOrganization.Command>
{ {

View file

@ -1,7 +1,8 @@
using Insight.Database; using Insight.Database;
using PlanTempus.Database.Core;
using System.Data; using System.Data;
namespace Database.Core.DDL namespace PlanTempus.Database.Core.DDL
{ {
/// <summary> /// <summary>
/// This is by purpose not async await /// This is by purpose not async await

View file

@ -1,4 +1,4 @@
namespace Database.Core namespace PlanTempus.Database.Core
{ {
public interface IDbConfigure<T> public interface IDbConfigure<T>
{ {

View file

@ -1,8 +1,8 @@
using Core.Entities.Users; using Insight.Database;
using Insight.Database; using PlanTempus.Core.Entities.Users;
using System.Data; using System.Data;
namespace Database.Core namespace PlanTempus.Database.Core
{ {
public class UserService public class UserService
{ {

View file

@ -1,7 +1,7 @@
using Autofac; using Autofac;
using Npgsql; using Npgsql;
using System.Data; using System.Data;
namespace Database.ModuleRegistry namespace PlanTempus.Database.ModuleRegistry
{ {
public class DbPostgreSqlModule : Module public class DbPostgreSqlModule : Module
{ {

View file

@ -1,7 +1,7 @@
using Insight.Database; using Insight.Database;
using System.Data; using System.Data;
namespace Database.NavigationSystem namespace PlanTempus.Database.NavigationSystem
{ {
internal class Setup internal class Setup
{ {

View file

@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" /> <ProjectReference Include="..\Core\PlanTempus.Core.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -1,8 +1,7 @@
using System.Data; using System.Data;
using Database.Common;
using Insight.Database; using Insight.Database;
namespace Database.RolesPermissionSystem namespace PlanTempus.Database.RolesPermissionSystem
{ {
/// <summary> /// <summary>
/// This is by purpose not async await /// This is by purpose not async await

View file

@ -1,7 +1,7 @@
using Insight.Database; using Insight.Database;
using System.Data; using System.Data;
namespace Database.Tenants namespace PlanTempus.Database.Tenants
{ {
internal class InitializeOrganizationData internal class InitializeOrganizationData
{ {

View file

@ -2,15 +2,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.10.35013.160 VisualStudioVersion = 17.10.35013.160
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{7B554252-1CE4-44BD-B108-B0BDCCB24742}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlanTempus.Core", "Core\PlanTempus.Core.csproj", "{7B554252-1CE4-44BD-B108-B0BDCCB24742}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{85614050-CFB0-4E39-81D3-7D99946449D9}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlanTempus.Tests", "Tests\PlanTempus.Tests.csproj", "{85614050-CFB0-4E39-81D3-7D99946449D9}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Application", "Application\Application.csproj", "{111CE8AE-E637-4376-A5A3-88D33E77EA88}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlanTempus.Application", "Application\PlanTempus.Application.csproj", "{111CE8AE-E637-4376-A5A3-88D33E77EA88}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Database", "Database\Database.csproj", "{D5096A7F-E6D4-4C87-874E-2D9A6BEAD57F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlanTempus.Database", "Database\PlanTempus.Database.csproj", "{D5096A7F-E6D4-4C87-874E-2D9A6BEAD57F}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SetupInfrastructure", "SetupInfrastructure\SetupInfrastructure.csproj", "{48300227-BCBB-45A3-8359-9064DA85B1F9}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlanTempus.SetupInfrastructure", "SetupInfrastructure\PlanTempus.SetupInfrastructure.csproj", "{48300227-BCBB-45A3-8359-9064DA85B1F9}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View file

@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Database\Database.csproj" /> <ProjectReference Include="..\Database\PlanTempus.Database.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -1,9 +1,12 @@
using Autofac; using Autofac;
using Insight.Database; using Insight.Database;
using PlanTempus.Database.ConfigurationManagementSystem;
using PlanTempus.Database.Core.DCL;
using PlanTempus.Database.Core.DDL;
using System.Data; using System.Data;
using System.Diagnostics; using System.Diagnostics;
namespace SetupInfrastructure namespace PlanTempus.SetupInfrastructure
{ {
/// <summary> /// <summary>
/// SETUP APPLICATION USER NAMED sathumper /// SETUP APPLICATION USER NAMED sathumper
@ -51,8 +54,8 @@ namespace SetupInfrastructure
Console.Write("Database.Core.DCL.SetupDbAdmin..."); Console.Write("Database.Core.DCL.SetupDbAdmin...");
sw.Start(); sw.Start();
var setupDbAdmin = _container.Resolve<Database.Core.DCL.SetupDbAdmin>(); var setupDbAdmin = _container.Resolve<SetupDbAdmin>();
setupDbAdmin.With(new Database.Core.DCL.SetupDbAdmin.Command { Password = "3911", Schema = "system", User = "heimdall" }); setupDbAdmin.With(new SetupDbAdmin.Command { Password = "3911", Schema = "system", User = "heimdall" });
Console.WriteLine($"DONE, took: {sw.ElapsedMilliseconds} ms"); Console.WriteLine($"DONE, took: {sw.ElapsedMilliseconds} ms");
@ -64,16 +67,16 @@ namespace SetupInfrastructure
//create new container with application user, we use that role from now. //create new container with application user, we use that role from now.
_container = new Startup().ConfigureContainer(new Startup.ConnectionStringTemplateParameters("heimdall", "3911")); _container = new Startup().ConfigureContainer(new Startup.ConnectionStringTemplateParameters("heimdall", "3911"));
var setupIdentitySystem = _container.Resolve<Database.Core.DDL.SetupIdentitySystem>(); var setupIdentitySystem = _container.Resolve<SetupIdentitySystem>();
setupIdentitySystem.With(new Database.Core.DDL.SetupIdentitySystem.Command { Schema = "system"}); setupIdentitySystem.With(new SetupIdentitySystem.Command { Schema = "system" });
Console.WriteLine($"DONE, took: {sw.ElapsedMilliseconds} ms"); Console.WriteLine($"DONE, took: {sw.ElapsedMilliseconds} ms");
Console.WriteLine("::"); Console.WriteLine("::");
Console.WriteLine("::"); Console.WriteLine("::");
Console.Write("Database.ConfigurationManagementSystem.SetupConfiguration..."); Console.Write("Database.ConfigurationManagementSystem.SetupConfiguration...");
sw.Restart(); sw.Restart();
var setupConfigurationSystem = _container.Resolve<Database.ConfigurationManagementSystem.SetupConfiguration>(); var setupConfigurationSystem = _container.Resolve<SetupConfiguration>();
setupConfigurationSystem.With(new Database.ConfigurationManagementSystem.SetupConfiguration.Command()); setupConfigurationSystem.With(new SetupConfiguration.Command());
Console.Write($"DONE, took: {sw.ElapsedMilliseconds} ms"); Console.Write($"DONE, took: {sw.ElapsedMilliseconds} ms");
@ -81,8 +84,8 @@ namespace SetupInfrastructure
Console.WriteLine("::"); Console.WriteLine("::");
Console.Write("Database.Core.DCL.SetupApplicationUser..."); Console.Write("Database.Core.DCL.SetupApplicationUser...");
sw.Start(); sw.Start();
var setupApplicationUser = _container.Resolve<Database.Core.DCL.SetupApplicationUser>(); var setupApplicationUser = _container.Resolve<SetupApplicationUser>();
setupApplicationUser.With(new Database.Core.DCL.SetupApplicationUser.Command { Password = "3911", Schema = "system", User = "sathumper" }); setupApplicationUser.With(new SetupApplicationUser.Command { Password = "3911", Schema = "system", User = "sathumper" });
Console.WriteLine($"DONE, took: {sw.ElapsedMilliseconds} ms"); Console.WriteLine($"DONE, took: {sw.ElapsedMilliseconds} ms");

View file

@ -1,9 +1,10 @@
using Autofac; using Autofac;
using Core.Configurations; using PlanTempus.Core.Configurations;
using Core.Configurations.JsonConfigProvider; using PlanTempus.Core.Configurations.JsonConfigProvider;
using PlanTempus.Core.ModuleRegistry;
using PlanTempus.Database.Core;
namespace PlanTempus.SetupInfrastructure
namespace SetupInfrastructure
{ {
public class Startup public class Startup
{ {
@ -27,13 +28,13 @@ namespace SetupInfrastructure
ConnectionString = configuration.GetConnectionString("DefaultConnection").Replace("{usr}", ctp.user).Replace("{pwd}", ctp.pwd) ConnectionString = configuration.GetConnectionString("DefaultConnection").Replace("{usr}", ctp.user).Replace("{pwd}", ctp.pwd)
}); });
builder.RegisterModule(new Core.ModuleRegistry.TelemetryModule builder.RegisterModule(new TelemetryModule
{ {
TelemetryConfig = configuration.GetSection("ApplicationInsights").ToObject<Core.ModuleRegistry.TelemetryConfig>() TelemetryConfig = configuration.GetSection("ApplicationInsights").ToObject<TelemetryConfig>()
}); });
builder.RegisterAssemblyTypes(typeof(Database.Core.IDbConfigure<>).Assembly) builder.RegisterAssemblyTypes(typeof(IDbConfigure<>).Assembly)
.AsClosedTypesOf(typeof(Database.Core.IDbConfigure<>)) .AsClosedTypesOf(typeof(IDbConfigure<>))
.AsSelf(); .AsSelf();

View file

@ -1,10 +1,11 @@
using Core.Configurations;
using FluentAssertions; using FluentAssertions;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Core.Configurations.JsonConfigProvider; using PlanTempus.Tests;
using Core.Configurations.SmartConfigProvider; using PlanTempus.Core.Configurations;
using PlanTempus.Core.Configurations.JsonConfigProvider;
using PlanTempus.Core.Configurations.SmartConfigProvider;
namespace Tests.ConfigurationTests namespace PlanTempus.Tests.ConfigurationTests
{ {
[TestClass] [TestClass]
public class JsonConfigurationProviderTests : TestFixture public class JsonConfigurationProviderTests : TestFixture

View file

@ -1,7 +1,8 @@
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Core.Configurations.Common; using PlanTempus.Core.Configurations.Common;
using PlanTempus.Tests;
namespace Tests.ConfigurationTests; namespace PlanTempus.Tests.ConfigurationTests;
[TestClass] [TestClass]
public class ConfigurationTests : TestFixture public class ConfigurationTests : TestFixture

View file

@ -1,13 +1,14 @@
using Core.Configurations; using FluentAssertions;
using FluentAssertions;
using Core.Configurations.JsonConfigProvider;
using Autofac; using Autofac;
using System.Data; using System.Data;
using Insight.Database; using Insight.Database;
using Npgsql; using Npgsql;
using Core.Configurations.SmartConfigProvider; using PlanTempus.Tests;
using PlanTempus.Core.Configurations;
using PlanTempus.Core.Configurations.JsonConfigProvider;
using PlanTempus.Core.Configurations.SmartConfigProvider;
namespace Tests.ConfigurationTests namespace PlanTempus.Tests.ConfigurationTests
{ {
[TestClass] [TestClass]
public class SmartConfigProviderTests : TestFixture public class SmartConfigProviderTests : TestFixture

View file

@ -4,7 +4,8 @@
"DefaultConnection": "Host=192.168.1.57;Port=5432;Database=ptmain;User Id=sathumper;Password=3911;" "DefaultConnection": "Host=192.168.1.57;Port=5432;Database=ptmain;User Id=sathumper;Password=3911;"
}, },
"ApplicationInsights": { "ApplicationInsights": {
"ConnectionString": "InstrumentationKey=6d2e76ee-5343-4691-a5e3-81add43cb584;IngestionEndpoint=https://northeurope-0.in.applicationinsights.azure.com/" "ConnectionString": "InstrumentationKey=6d2e76ee-5343-4691-a5e3-81add43cb584;IngestionEndpoint=https://northeurope-0.in.applicationinsights.azure.com/",
"UseSeqLoggingTelemetryChannel": true
}, },
"Authentication": "SHA256", "Authentication": "SHA256",
"Feature": { "Feature": {

View file

@ -1,11 +1,11 @@
using Autofac; using Autofac;
using Core.Telemetry;
using Microsoft.ApplicationInsights; using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts; using Microsoft.ApplicationInsights.DataContracts;
using Core.Logging; using PlanTempus.Core.Logging;
using PlanTempus.Core.Telemetry;
namespace Tests.Logging namespace PlanTempus.Tests.Logging
{ {
[TestClass] [TestClass]
public class SeqBackgroundServiceTest : TestFixture public class SeqBackgroundServiceTest : TestFixture
@ -23,9 +23,7 @@ namespace Tests.Logging
var config = new SeqConfiguration("http://localhost:5341", null, "MSTEST"); var config = new SeqConfiguration("http://localhost:5341", null, "MSTEST");
var httpClient = new SeqHttpClient(config); var httpClient = new SeqHttpClient(config);
var logger = new SeqLogger(httpClient, Environment.MachineName, config); var logger = new SeqLogger<SeqBackgroundService>(httpClient, Environment.MachineName, config);
_service = new SeqBackgroundService(telemetryClient, _messageChannel, logger); _service = new SeqBackgroundService(telemetryClient, _messageChannel, logger);
_cts = new CancellationTokenSource(); _cts = new CancellationTokenSource();

View file

@ -1,14 +1,14 @@
using Autofac; using Autofac;
using Core.Logging;
using Microsoft.ApplicationInsights; using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts; using Microsoft.ApplicationInsights.DataContracts;
using PlanTempus.Core.Logging;
namespace Tests.Logging namespace PlanTempus.Tests.Logging
{ {
[TestClass] [TestClass]
public class SeqLoggerTests : TestFixture public class SeqLoggerTests : TestFixture
{ {
private SeqLogger _logger; private SeqLogger<SeqLoggerTests> _logger;
private SeqHttpClient _httpClient; private SeqHttpClient _httpClient;
private readonly string _testId; private readonly string _testId;
@ -17,7 +17,7 @@ namespace Tests.Logging
_testId = Guid.NewGuid().ToString(); _testId = Guid.NewGuid().ToString();
var config = new SeqConfiguration("http://localhost:5341", null, "MSTEST"); var config = new SeqConfiguration("http://localhost:5341", null, "MSTEST");
_httpClient = new SeqHttpClient(config); _httpClient = new SeqHttpClient(config);
_logger = new SeqLogger(_httpClient, Environment.MachineName, config); _logger = new SeqLogger<SeqLoggerTests>(_httpClient, Environment.MachineName, config);
} }
[TestMethod] [TestMethod]
@ -113,24 +113,22 @@ namespace Tests.Logging
} }
[TestMethod] [TestMethod]
public async Task LogRequestTelemetry_SendsCorrectData() public async Task LogRequestTelemetryInOperationHolderWithParentChild_SendsCorrectData()
{ {
var telemetryClient = Container.Resolve<TelemetryClient>(); var telemetryClient = Container.Resolve<TelemetryClient>();
var operationId = "op123"; using (Microsoft.ApplicationInsights.Extensibility.IOperationHolder<RequestTelemetry> parent = telemetryClient.StartOperation<RequestTelemetry>("Parent First"))
using (Microsoft.ApplicationInsights.Extensibility.IOperationHolder<RequestTelemetry> operation = telemetryClient.StartOperation<RequestTelemetry>("GET /api/parent"))
{ {
using (var child = telemetryClient.StartOperation<RequestTelemetry>("api/test")) parent.Telemetry.Duration = TimeSpan.FromMilliseconds(250);
// Arrange parent.Telemetry.Url = new Uri("http://parent.test.com/api/test");
{
//child.Telemetry.Name = "/api/test"; using (var child = telemetryClient.StartOperation<RequestTelemetry>("Child 1"))
{
child.Telemetry.Success = true; child.Telemetry.Success = true;
child.Telemetry.ResponseCode = "200"; child.Telemetry.ResponseCode = "200";
child.Telemetry.Duration = TimeSpan.FromMilliseconds(50); child.Telemetry.Duration = TimeSpan.FromMilliseconds(50);
child.Telemetry.Url = new Uri("http://test.com/api/test"); child.Telemetry.Url = new Uri("http://child.test.com/api/test");
child.Telemetry.Timestamp = DateTimeOffset.UtcNow; child.Telemetry.Timestamp = DateTimeOffset.UtcNow;
child.Telemetry.Properties.Add("httpMethod", HttpMethod.Get.ToString()); child.Telemetry.Properties.Add("httpMethod", HttpMethod.Get.ToString());
@ -139,8 +137,8 @@ namespace Tests.Logging
await _logger.LogAsync(child); await _logger.LogAsync(child);
}; };
await _logger.LogAsync(parent);
} }
// Act
} }
} }
} }

View file

@ -1,14 +1,8 @@
using Autofac;
using System.Data;
using Insight.Database;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Extensions.Logging;
using Core.Telemetry;
using Core.Entities.Users;
using System.Diagnostics; using System.Diagnostics;
using Sodium; using Sodium;
using PlanTempus.Core.Entities.Users;
namespace Tests namespace PlanTempus.Tests
{ {
[TestClass] [TestClass]
public class PasswordHasherTests : TestFixture public class PasswordHasherTests : TestFixture

View file

@ -18,8 +18,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Application\Application.csproj" /> <ProjectReference Include="..\Application\PlanTempus.Application.csproj" />
<ProjectReference Include="..\Database\Database.csproj" /> <ProjectReference Include="..\Database\PlanTempus.Database.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -1,11 +1,8 @@
using Autofac; using Autofac;
using System.Data; using System.Data;
using Insight.Database; using Insight.Database;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Extensions.Logging;
using Core.Telemetry;
namespace Tests namespace PlanTempus.Tests
{ {
[TestClass] [TestClass]
public class PostgresTests : TestFixture public class PostgresTests : TestFixture

View file

@ -1,11 +1,6 @@
using Autofac;
using System.Data;
using Insight.Database;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Extensions.Logging;
using Core.Telemetry;
namespace Tests
namespace PlanTempus.Tests
{ {
} }

View file

@ -1,12 +1,12 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using Autofac; using Autofac;
using Core.Configurations;
using Core.ModuleRegistry;
using Microsoft.ApplicationInsights; using Microsoft.ApplicationInsights;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Core.Configurations.JsonConfigProvider; using PlanTempus.Core.Configurations;
namespace Tests using PlanTempus.Core.Configurations.JsonConfigProvider;
using PlanTempus.Core.ModuleRegistry;
namespace PlanTempus.Tests
{ {
/// <summary> /// <summary>
/// Act as base class for tests. Avoids duplication of test setup code /// Act as base class for tests. Avoids duplication of test setup code
@ -72,9 +72,9 @@ namespace Tests
ConnectionString = configuration.GetConnectionString("DefaultConnection") ConnectionString = configuration.GetConnectionString("DefaultConnection")
}); });
builder.RegisterModule(new Core.ModuleRegistry.TelemetryModule builder.RegisterModule(new TelemetryModule
{ {
TelemetryConfig = configuration.GetSection("ApplicationInsights").ToObject<Core.ModuleRegistry.TelemetryConfig>() TelemetryConfig = configuration.GetSection("ApplicationInsights").ToObject<TelemetryConfig>()
}); });

View file

@ -3,6 +3,7 @@
"DefaultConnection": "Host=192.168.1.57;Port=5432;Database=ptmain;User Id=sathumper;Password=3911;" "DefaultConnection": "Host=192.168.1.57;Port=5432;Database=ptmain;User Id=sathumper;Password=3911;"
}, },
"ApplicationInsights": { "ApplicationInsights": {
"ConnectionString": "InstrumentationKey=6d2e76ee-5343-4691-a5e3-81add43cb584;IngestionEndpoint=https://northeurope-0.in.applicationinsights.azure.com/" "ConnectionString": "InstrumentationKey=6d2e76ee-5343-4691-a5e3-81add43cb584;IngestionEndpoint=https://northeurope-0.in.applicationinsights.azure.com/",
"UseSeqLoggingTelemetryChannel": true
} }
} }