Skip to content
Open
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ obj/
bin/
build/
deploy/
nuget/
TestResults/
*.bak
*.user
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* when creating a new package, make sure to:
* maintain the repo structure (see existing packages)
* add code analyzers
* create the package's README.md
* create the package's README.md
* initialize the package's CHANGELOG.md
* add tests
* consider presenting usage in Demo app (`/samples`)
* reference the package from README.md in repo's root

## Coding style

The coding style is guarded by the analyzers (such as stylecop) and .editorconfig.
Make sure to follow the defined standards.
The coding style is guarded by the analyzers (such as stylecop) and .editorconfig.
Make sure to follow the defined standards.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Allegro.Extensions
# Allegro.Extensions

This repo contains utility packages that can be shared between Allegro services, but are not required. Everyone can be an author of such package - the goal of this repository is to make it easier and quicker to share useful code snippets, helpers, extensions etc, with as little effort as possible.

Expand All @@ -8,7 +8,7 @@ This repo contains utility packages that can be shared between Allegro services,

Every PR is welcomed. You can extend existing packages and add new ones.

Please refer to [Contributing guideline](CONTRIBUTING.md) for details.
Please refer to [Contributing guideline](CONTRIBUTING.md) for details.

***

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoFixture.Xunit2" Version="4.18.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Update="Meziantou.Analyzer" Version="2.0.85">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; compile; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
<ProjectReference Include="..\Allegro.Extensions.ApplicationInsights.AspNetCore\Allegro.Extensions.ApplicationInsights.AspNetCore.csproj" />
</ItemGroup>

</Project>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Allegro.Extensions.ApplicationInsights.AspNetCore\Allegro.Extensions.ApplicationInsights.AspNetCore.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoFixture.Xunit2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ public class SamplingFilterTests : FilterTests<DependencyForFilter, RequestForFi
[InlineData(null, null, null, null, 150, true, null, "ResultCode eq '4'", true)]
[InlineData(null, null, null, null, 150, true, null, "startswith(ResultCode, '4')", true)]
public void Dependencies_Rules(
string cloudRoleName,
string type,
string target,
string name,
string? cloudRoleName,
string? type,
string? target,
string? name,
int duration,
bool success,
string resultCode,
string filter,
string? resultCode,
string? filter,
bool shouldSample)
{
var dependency = new DependencyTelemetry(type, target, name, null);
Expand All @@ -116,7 +116,7 @@ public void Dependencies_Rules(

DependencyForFilter DependencyMap(DependencyTelemetry d) => new(d);

ApplyDependencyRules(dependency, filter, DependencyMap);
ApplyDependencyRules(dependency, filter!, DependencyMap);

((ISupportSampling)dependency).SamplingPercentage.Should().Be(shouldSample ? null : 100);
}
Expand Down Expand Up @@ -208,13 +208,13 @@ public void Dependencies_Rules(
[InlineData(null, null, null, 150, true, null, "CloudRoleName eq 'SomeService'", true)]
[InlineData(null, null, null, 150, true, null, "startswith(CloudRoleName, 'SomeService')", true)]
public void Requests_Rules(
string cloudRoleName,
string name,
string? cloudRoleName,
string? name,
string? url,
int duration,
bool success,
string responseCode,
string filter,
string? responseCode,
string? filter,
bool shouldSample)
{
var requestTelemetry = new RequestTelemetry(
Expand All @@ -231,7 +231,7 @@ public void Requests_Rules(

RequestForFilter RequestMap(RequestTelemetry d) => new(d);

ApplyRequestRules(requestTelemetry, filter, RequestMap);
ApplyRequestRules(requestTelemetry, filter!, RequestMap);

((ISupportSampling)requestTelemetry).SamplingPercentage.Should().Be(shouldSample ? null : 100);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
</PropertyGroup>
<Import Project="..\..\Package.Build.props" />
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.4" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
<PackageReference Include="StringToExpression" Version="1.1.1" />
<PackageReference Update="Meziantou.Analyzer" Version="2.0.85">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; compile; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
<Import Project="..\..\Package.Build.props" />
<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.ApplicationInsights" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
<PackageReference Include="StringToExpression" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Allegro.Extensions.ApplicationInsights.AspNetCore.UnitTests" />
<InternalsVisibleTo Include="Allegro.Extensions.ApplicationInsights.Demo.UnitTests" />
</ItemGroup>
</Project>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ public static ApplicationInsightsExtensionsBuilder AddApplicationInsightsTelemet

private static string GetConnectionString(string? connectionString, IConfiguration configuration, IHostEnvironment env)
{
var sendConfig = configuration.GetSection(MainSection).Get<SendConfig>();
var sendConfig = configuration.GetSection(MainSection).Get<SendConfig>()
?? throw new InvalidOperationException("Missing SendConfig configuration section in ApplicationInsights configuration!");
return env.IsDevelopment() && sendConfig.DisableLocally ? "InstrumentationKey=FakeKey" :
connectionString ?? configuration.GetSection(MainSection)["ConnectionString"];
connectionString ?? (configuration.GetSection(MainSection)["ConnectionString"]
?? throw new InvalidOperationException("Missing ConnectionString configuration in ApplicationInsights configuration!"));
}

/// <summary>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,37 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.18.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Update="Meziantou.Analyzer" Version="2.0.85">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; compile; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
<ProjectReference Include="..\Allegro.Extensions.ApplicationInsights.AspNetCore.UnitTests\Allegro.Extensions.ApplicationInsights.AspNetCore.UnitTests.csproj" />
<ProjectReference Include="..\Allegro.Extensions.ApplicationInsights.Demo\Allegro.Extensions.ApplicationInsights.Demo.csproj" />
</ItemGroup>

</Project>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Allegro.Extensions.ApplicationInsights.AspNetCore.UnitTests\Allegro.Extensions.ApplicationInsights.AspNetCore.UnitTests.csproj" />
<ProjectReference Include="..\Allegro.Extensions.ApplicationInsights.Demo\Allegro.Extensions.ApplicationInsights.Demo.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoFixture" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Allegro.Extensions.ApplicationInsights.Demo.UnitTests;

internal class
internal sealed class
CustomExcludeFromSamplingTelemetryInitializer : ExcludeFromSamplingTelemetryInitializer<CustomDependencyForFilter,
RequestForFilter>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.cs]
# CS1591: Missing XML comment for publicly visible type or member
dotnet_diagnostic.CS1591.severity = none
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="prometheus-net.AspNetCore" Version="6.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Update="Meziantou.Analyzer" Version="2.0.85">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; compile; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Allegro.Extensions.ApplicationInsights.Prometheus\Allegro.Extensions.ApplicationInsights.Prometheus.csproj" />
<ProjectReference Include="..\Allegro.Extensions.ApplicationInsights.AspNetCore\Allegro.Extensions.ApplicationInsights.AspNetCore.csproj" />
</ItemGroup>
</Project>
<ItemGroup>
<ProjectReference Include="..\Allegro.Extensions.ApplicationInsights.Prometheus\Allegro.Extensions.ApplicationInsights.Prometheus.csproj" />
<ProjectReference Include="..\Allegro.Extensions.ApplicationInsights.AspNetCore\Allegro.Extensions.ApplicationInsights.AspNetCore.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" />
<PackageReference Include="prometheus-net.AspNetCore" />
<PackageReference Include="Swashbuckle.AspNetCore" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Allegro.Extensions.ApplicationInsights.Demo.UnitTests" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace Allegro.Extensions.ApplicationInsights.Demo.Controllers;

public record WeatherForecast(DateTime Date, int TemperatureC, string Summary);
Expand All @@ -13,10 +11,7 @@ public record WeatherForecast(DateTime Date, int TemperatureC, string Summary);
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private static readonly string[] Summaries = ["Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"];

private readonly ILogger<WeatherForecastController> _logger;
private readonly IHttpClientFactory _httpClientFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Allegro.Extensions.ApplicationInsights.AspNetCore;
using Microsoft.ApplicationInsights.DataContracts;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace Allegro.Extensions.ApplicationInsights.Demo;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[*.{cs,fs}]
dotnet_diagnostic.CS1591.severity = none
[*.cs]
# CA1861: Avoid constant arrays as arguments
dotnet_diagnostic.CA1861.severity = silent
Loading