Enhancing telemetry in Seq and fixes namespaces
This commit is contained in:
parent
5568007237
commit
9f4996bc8f
65 changed files with 1122 additions and 1139 deletions
|
|
@ -1,141 +1,142 @@
|
|||
using Core.Configurations;
|
||||
using FluentAssertions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Core.Configurations.JsonConfigProvider;
|
||||
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]
|
||||
public class JsonConfigurationProviderTests : TestFixture
|
||||
{
|
||||
const string _testFolder = "ConfigurationTests/";
|
||||
[TestClass]
|
||||
public class JsonConfigurationProviderTests : TestFixture
|
||||
{
|
||||
const string _testFolder = "ConfigurationTests/";
|
||||
|
||||
public JsonConfigurationProviderTests() : base(_testFolder) { }
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void GetSection_ShouldReturnCorrectFeatureSection()
|
||||
{
|
||||
// Arrange
|
||||
var expectedJObject = JObject.Parse(@"{
|
||||
[TestMethod]
|
||||
public void GetSection_ShouldReturnCorrectFeatureSection()
|
||||
{
|
||||
// Arrange
|
||||
var expectedJObject = JObject.Parse(@"{
|
||||
'Enabled': true,
|
||||
'RolloutPercentage': 25,
|
||||
'AllowedUserGroups': ['beta']
|
||||
}") as JToken;
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||
.Build();
|
||||
|
||||
// Act
|
||||
var section = builder.GetSection("Feature");
|
||||
|
||||
// Assert
|
||||
section.Should().NotBeNull();
|
||||
section.Value.Should().BeEquivalentTo(expectedJObject);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectFeatureObject()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = new Feature
|
||||
{
|
||||
Enabled = true,
|
||||
RolloutPercentage = 25,
|
||||
AllowedUserGroups = new() { "beta" }
|
||||
};
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||
.Build();
|
||||
|
||||
// Act
|
||||
var actualFeature = builder.GetSection("Feature").ToObject<Feature>();
|
||||
// Act
|
||||
var section = builder.GetSection("Feature");
|
||||
|
||||
// Assert
|
||||
section.Should().NotBeNull();
|
||||
section.Value.Should().BeEquivalentTo(expectedJObject);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectFeatureObject()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = new Feature
|
||||
{
|
||||
Enabled = true,
|
||||
RolloutPercentage = 25,
|
||||
AllowedUserGroups = new() { "beta" }
|
||||
};
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||
.Build();
|
||||
|
||||
// Act
|
||||
var actualFeature = builder.GetSection("Feature").ToObject<Feature>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var actualFeatureObsoleted = builder.GetSection("Feature").Get<Feature>();
|
||||
var actualFeatureObsoleted = builder.GetSection("Feature").Get<Feature>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
// Assert
|
||||
actualFeature.Should().BeEquivalentTo(expectedFeature);
|
||||
actualFeatureObsoleted.Should().BeEquivalentTo(expectedFeature);
|
||||
// Assert
|
||||
actualFeature.Should().BeEquivalentTo(expectedFeature);
|
||||
actualFeatureObsoleted.Should().BeEquivalentTo(expectedFeature);
|
||||
|
||||
}
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueAsString()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = "123";
|
||||
}
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueAsString()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = "123";
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||
.Build();
|
||||
|
||||
// Act
|
||||
var actualFeature = builder.GetSection("AnotherSetting").Get<string>("Thresholds:High");
|
||||
// Act
|
||||
var actualFeature = builder.GetSection("AnotherSetting").Get<string>("Thresholds:High");
|
||||
|
||||
// Assert
|
||||
actualFeature.Should().BeEquivalentTo(expectedFeature);
|
||||
}
|
||||
/// <summary>
|
||||
/// Testing a stupid indexer for compability with Microsoft ConfigurationBuilder
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void Indexer_ShouldReturnValueAsString()
|
||||
{
|
||||
// Arrange
|
||||
var expected = "SHA256";
|
||||
// Assert
|
||||
actualFeature.Should().BeEquivalentTo(expectedFeature);
|
||||
}
|
||||
/// <summary>
|
||||
/// Testing a stupid indexer for compability with Microsoft ConfigurationBuilder
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void Indexer_ShouldReturnValueAsString()
|
||||
{
|
||||
// Arrange
|
||||
var expected = "SHA256";
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||
.Build();
|
||||
|
||||
// Act
|
||||
var actual = builder["Authentication"];
|
||||
// Act
|
||||
var actual = builder["Authentication"];
|
||||
|
||||
// Assert
|
||||
actual.Should().BeEquivalentTo(expected);
|
||||
}
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueAsInt()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = 22;
|
||||
// Assert
|
||||
actual.Should().BeEquivalentTo(expected);
|
||||
}
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueAsInt()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = 22;
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||
.Build();
|
||||
|
||||
// Act
|
||||
var actualFeature = builder.GetSection("AnotherSetting:Temperature").Get<int>("Indoor:Max:Limit");
|
||||
// Act
|
||||
var actualFeature = builder.GetSection("AnotherSetting:Temperature").Get<int>("Indoor:Max:Limit");
|
||||
|
||||
// Assert
|
||||
actualFeature.Should().Be(expectedFeature);
|
||||
}
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueAsBool()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = true;
|
||||
// Assert
|
||||
actualFeature.Should().Be(expectedFeature);
|
||||
}
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueAsBool()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = true;
|
||||
|
||||
var configRoot = new ConfigurationBuilder()
|
||||
var configRoot = new ConfigurationBuilder()
|
||||
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||
.AddSmartConfig()
|
||||
.Build();
|
||||
.Build();
|
||||
|
||||
// Act
|
||||
var actualFeature = configRoot.Get<bool>("Database:UseSSL");
|
||||
// Act
|
||||
var actualFeature = configRoot.Get<bool>("Database:UseSSL");
|
||||
|
||||
// Assert
|
||||
actualFeature.Should().Be(expectedFeature);
|
||||
}
|
||||
}
|
||||
// Assert
|
||||
actualFeature.Should().Be(expectedFeature);
|
||||
}
|
||||
}
|
||||
|
||||
public class Feature
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
public int RolloutPercentage { get; set; }
|
||||
public List<string> AllowedUserGroups { get; set; }
|
||||
}
|
||||
public class Feature
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
public int RolloutPercentage { get; set; }
|
||||
public List<string> AllowedUserGroups { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using Core.Configurations.Common;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PlanTempus.Core.Configurations.Common;
|
||||
using PlanTempus.Tests;
|
||||
|
||||
namespace Tests.ConfigurationTests;
|
||||
namespace PlanTempus.Tests.ConfigurationTests;
|
||||
|
||||
[TestClass]
|
||||
public class ConfigurationTests : TestFixture
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
using Core.Configurations;
|
||||
using FluentAssertions;
|
||||
using Core.Configurations.JsonConfigProvider;
|
||||
using FluentAssertions;
|
||||
using Autofac;
|
||||
using System.Data;
|
||||
using Insight.Database;
|
||||
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]
|
||||
public class SmartConfigProviderTests : TestFixture
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
"DefaultConnection": "Host=192.168.1.57;Port=5432;Database=ptmain;User Id=sathumper;Password=3911;"
|
||||
},
|
||||
"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",
|
||||
"Feature": {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
using Autofac;
|
||||
using Core.Telemetry;
|
||||
using Microsoft.ApplicationInsights;
|
||||
using Microsoft.ApplicationInsights.Channel;
|
||||
using Microsoft.ApplicationInsights.DataContracts;
|
||||
using Core.Logging;
|
||||
using PlanTempus.Core.Logging;
|
||||
using PlanTempus.Core.Telemetry;
|
||||
|
||||
namespace Tests.Logging
|
||||
namespace PlanTempus.Tests.Logging
|
||||
{
|
||||
[TestClass]
|
||||
public class SeqBackgroundServiceTest : TestFixture
|
||||
|
|
@ -23,9 +23,7 @@ namespace Tests.Logging
|
|||
var config = new SeqConfiguration("http://localhost:5341", null, "MSTEST");
|
||||
|
||||
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);
|
||||
_cts = new CancellationTokenSource();
|
||||
|
|
@ -40,15 +38,15 @@ namespace Tests.Logging
|
|||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
var eventTelemetry = new EventTelemetry
|
||||
{
|
||||
Name = "Test Event",
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
eventTelemetry.Properties.Add("TestId", Guid.NewGuid().ToString());
|
||||
eventTelemetry.Metrics.Add("TestMetric", 42.0);
|
||||
var eventTelemetry = new EventTelemetry
|
||||
{
|
||||
Name = "Test Event",
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
eventTelemetry.Properties.Add("TestId", Guid.NewGuid().ToString());
|
||||
eventTelemetry.Metrics.Add("TestMetric", 42.0);
|
||||
|
||||
await _messageChannel.Writer.WriteAsync(eventTelemetry);
|
||||
await _messageChannel.Writer.WriteAsync(eventTelemetry);
|
||||
}
|
||||
|
||||
// wait for processing
|
||||
|
|
|
|||
|
|
@ -1,146 +1,144 @@
|
|||
using Autofac;
|
||||
using Core.Logging;
|
||||
using Microsoft.ApplicationInsights;
|
||||
using Microsoft.ApplicationInsights.DataContracts;
|
||||
using PlanTempus.Core.Logging;
|
||||
|
||||
namespace Tests.Logging
|
||||
namespace PlanTempus.Tests.Logging
|
||||
{
|
||||
[TestClass]
|
||||
public class SeqLoggerTests : TestFixture
|
||||
{
|
||||
private SeqLogger _logger;
|
||||
private SeqHttpClient _httpClient;
|
||||
private readonly string _testId;
|
||||
[TestClass]
|
||||
public class SeqLoggerTests : TestFixture
|
||||
{
|
||||
private SeqLogger<SeqLoggerTests> _logger;
|
||||
private SeqHttpClient _httpClient;
|
||||
private readonly string _testId;
|
||||
|
||||
public SeqLoggerTests()
|
||||
{
|
||||
_testId = Guid.NewGuid().ToString();
|
||||
var config = new SeqConfiguration("http://localhost:5341", null, "MSTEST");
|
||||
_httpClient = new SeqHttpClient(config);
|
||||
_logger = new SeqLogger(_httpClient, Environment.MachineName, config);
|
||||
}
|
||||
public SeqLoggerTests()
|
||||
{
|
||||
_testId = Guid.NewGuid().ToString();
|
||||
var config = new SeqConfiguration("http://localhost:5341", null, "MSTEST");
|
||||
_httpClient = new SeqHttpClient(config);
|
||||
_logger = new SeqLogger<SeqLoggerTests>(_httpClient, Environment.MachineName, config);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task LogTraceTelemetry_SendsCorrectDataWithErrorLevel()
|
||||
{
|
||||
// Arrange
|
||||
var traceTelemetry = new TraceTelemetry
|
||||
{
|
||||
Message = "Test trace error message",
|
||||
SeverityLevel = SeverityLevel.Error,
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
traceTelemetry.Properties.Add("TestId", _testId);
|
||||
[TestMethod]
|
||||
public async Task LogTraceTelemetry_SendsCorrectDataWithErrorLevel()
|
||||
{
|
||||
// Arrange
|
||||
var traceTelemetry = new TraceTelemetry
|
||||
{
|
||||
Message = "Test trace error message",
|
||||
SeverityLevel = SeverityLevel.Error,
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
traceTelemetry.Properties.Add("TestId", _testId);
|
||||
|
||||
// Act
|
||||
await _logger.LogAsync(traceTelemetry);
|
||||
// Act
|
||||
await _logger.LogAsync(traceTelemetry);
|
||||
|
||||
|
||||
}
|
||||
[TestMethod]
|
||||
public async Task LogTraceTelemetry_SendsCorrectDataWithWarningLevel()
|
||||
{
|
||||
// Arrange
|
||||
var traceTelemetry = new TraceTelemetry
|
||||
{
|
||||
Message = "Test trace warning message",
|
||||
SeverityLevel = SeverityLevel.Warning,
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
traceTelemetry.Properties.Add("TestId", _testId);
|
||||
}
|
||||
[TestMethod]
|
||||
public async Task LogTraceTelemetry_SendsCorrectDataWithWarningLevel()
|
||||
{
|
||||
// Arrange
|
||||
var traceTelemetry = new TraceTelemetry
|
||||
{
|
||||
Message = "Test trace warning message",
|
||||
SeverityLevel = SeverityLevel.Warning,
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
traceTelemetry.Properties.Add("TestId", _testId);
|
||||
|
||||
// Act
|
||||
await _logger.LogAsync(traceTelemetry);
|
||||
// Act
|
||||
await _logger.LogAsync(traceTelemetry);
|
||||
|
||||
}
|
||||
[TestMethod]
|
||||
public async Task LogEventTelemetry_SendsCorrectData()
|
||||
{
|
||||
// Arrange
|
||||
var eventTelemetry = new EventTelemetry
|
||||
{
|
||||
Name = "Test Event",
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
eventTelemetry.Properties.Add("TestId", _testId);
|
||||
eventTelemetry.Metrics.Add("TestMetric", 42.0);
|
||||
}
|
||||
[TestMethod]
|
||||
public async Task LogEventTelemetry_SendsCorrectData()
|
||||
{
|
||||
// Arrange
|
||||
var eventTelemetry = new EventTelemetry
|
||||
{
|
||||
Name = "Test Event",
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
eventTelemetry.Properties.Add("TestId", _testId);
|
||||
eventTelemetry.Metrics.Add("TestMetric", 42.0);
|
||||
|
||||
// Act
|
||||
await _logger.LogAsync(eventTelemetry);
|
||||
}
|
||||
// Act
|
||||
await _logger.LogAsync(eventTelemetry);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task LogExceptionTelemetry_SendsCorrectData()
|
||||
{
|
||||
try
|
||||
{
|
||||
int t = 0;
|
||||
var result = 10 / t;
|
||||
[TestMethod]
|
||||
public async Task LogExceptionTelemetry_SendsCorrectData()
|
||||
{
|
||||
try
|
||||
{
|
||||
int t = 0;
|
||||
var result = 10 / t;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
// Arrange
|
||||
var exceptionTelemetry = new ExceptionTelemetry(e)
|
||||
{
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
exceptionTelemetry.Properties.Add("TestId", _testId);
|
||||
// Arrange
|
||||
var exceptionTelemetry = new ExceptionTelemetry(e)
|
||||
{
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
exceptionTelemetry.Properties.Add("TestId", _testId);
|
||||
|
||||
// Act
|
||||
await _logger.LogAsync(exceptionTelemetry);
|
||||
}
|
||||
}
|
||||
// Act
|
||||
await _logger.LogAsync(exceptionTelemetry);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task LogDependencyTelemetry_SendsCorrectData()
|
||||
{
|
||||
// Arrange
|
||||
var dependencyTelemetry = new DependencyTelemetry
|
||||
{
|
||||
Name = "SQL Query",
|
||||
Type = "SQL",
|
||||
Target = "TestDB",
|
||||
Success = true,
|
||||
Duration = TimeSpan.FromMilliseconds(100),
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
dependencyTelemetry.Properties.Add("TestId", _testId);
|
||||
[TestMethod]
|
||||
public async Task LogDependencyTelemetry_SendsCorrectData()
|
||||
{
|
||||
// Arrange
|
||||
var dependencyTelemetry = new DependencyTelemetry
|
||||
{
|
||||
Name = "SQL Query",
|
||||
Type = "SQL",
|
||||
Target = "TestDB",
|
||||
Success = true,
|
||||
Duration = TimeSpan.FromMilliseconds(100),
|
||||
Timestamp = DateTimeOffset.UtcNow
|
||||
};
|
||||
dependencyTelemetry.Properties.Add("TestId", _testId);
|
||||
|
||||
// Act
|
||||
await _logger.LogAsync(dependencyTelemetry);
|
||||
}
|
||||
// Act
|
||||
await _logger.LogAsync(dependencyTelemetry);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task LogRequestTelemetry_SendsCorrectData()
|
||||
{
|
||||
var telemetryClient = Container.Resolve<TelemetryClient>();
|
||||
[TestMethod]
|
||||
public async Task LogRequestTelemetryInOperationHolderWithParentChild_SendsCorrectData()
|
||||
{
|
||||
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"))
|
||||
{
|
||||
parent.Telemetry.Duration = TimeSpan.FromMilliseconds(250);
|
||||
parent.Telemetry.Url = new Uri("http://parent.test.com/api/test");
|
||||
|
||||
using (var child = telemetryClient.StartOperation<RequestTelemetry>("api/test"))
|
||||
// Arrange
|
||||
{
|
||||
using (var child = telemetryClient.StartOperation<RequestTelemetry>("Child 1"))
|
||||
{
|
||||
child.Telemetry.Success = true;
|
||||
child.Telemetry.ResponseCode = "200";
|
||||
child.Telemetry.Duration = TimeSpan.FromMilliseconds(50);
|
||||
child.Telemetry.Url = new Uri("http://child.test.com/api/test");
|
||||
child.Telemetry.Timestamp = DateTimeOffset.UtcNow;
|
||||
|
||||
//child.Telemetry.Name = "/api/test";
|
||||
child.Telemetry.Success = true;
|
||||
child.Telemetry.ResponseCode = "200";
|
||||
child.Telemetry.Duration = TimeSpan.FromMilliseconds(50);
|
||||
child.Telemetry.Url = new Uri("http://test.com/api/test");
|
||||
child.Telemetry.Timestamp = DateTimeOffset.UtcNow;
|
||||
child.Telemetry.Properties.Add("httpMethod", HttpMethod.Get.ToString());
|
||||
child.Telemetry.Properties.Add("TestId", _testId);
|
||||
|
||||
child.Telemetry.Properties.Add("httpMethod", HttpMethod.Get.ToString());
|
||||
child.Telemetry.Properties.Add("TestId", _testId);
|
||||
await _logger.LogAsync(child);
|
||||
};
|
||||
|
||||
await _logger.LogAsync(child);
|
||||
};
|
||||
|
||||
}
|
||||
// Act
|
||||
}
|
||||
}
|
||||
await _logger.LogAsync(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 Sodium;
|
||||
using PlanTempus.Core.Entities.Users;
|
||||
|
||||
namespace Tests
|
||||
namespace PlanTempus.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class PasswordHasherTests : TestFixture
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Application\Application.csproj" />
|
||||
<ProjectReference Include="..\Database\Database.csproj" />
|
||||
<ProjectReference Include="..\Application\PlanTempus.Application.csproj" />
|
||||
<ProjectReference Include="..\Database\PlanTempus.Database.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -1,11 +1,8 @@
|
|||
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
|
||||
{
|
||||
[TestClass]
|
||||
public class PostgresTests : TestFixture
|
||||
|
|
@ -39,11 +36,11 @@ namespace Tests
|
|||
// );
|
||||
// }
|
||||
// var logger = Container.Resolve<Microsoft.ApplicationInsights.TelemetryClient>();
|
||||
|
||||
|
||||
|
||||
|
||||
// for (int i = 0; i < 5; i++)
|
||||
// {
|
||||
|
||||
|
||||
// logger.TrackTrace("Hello 23", Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Information);
|
||||
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Autofac;
|
||||
using Core.Configurations;
|
||||
using Core.ModuleRegistry;
|
||||
using Microsoft.ApplicationInsights;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Core.Configurations.JsonConfigProvider;
|
||||
namespace Tests
|
||||
using PlanTempus.Core.Configurations;
|
||||
using PlanTempus.Core.Configurations.JsonConfigProvider;
|
||||
using PlanTempus.Core.ModuleRegistry;
|
||||
namespace PlanTempus.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Act as base class for tests. Avoids duplication of test setup code
|
||||
|
|
@ -72,9 +72,9 @@ namespace Tests
|
|||
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>()
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
"DefaultConnection": "Host=192.168.1.57;Port=5432;Database=ptmain;User Id=sathumper;Password=3911;"
|
||||
},
|
||||
"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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue