Skip to content

.NET Standard 2.0 support #91

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
33 changes: 20 additions & 13 deletions Metrics.sln
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metrics.StupidBenchmarks",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NancyFx.Sample", "Samples\NancyFx.Sample\NancyFx.Sample.csproj", "{B7C6EF21-0797-4B53-A917-1CFF8267CD67}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Owin.Sample", "Samples\Owin.Sample\Owin.Sample.csproj", "{828188F9-26C2-4C93-A156-D9EA13D7E2FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Owin.Metrics", "Src\Adapters\Owin.Metrics\Owin.Metrics.csproj", "{025CD6D0-1A1E-4B14-A7DB-AF5DFF887210}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{2E004760-A644-4312-8489-6057B8B7554A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metrics.TestConsole", "Src\Metrics.TestConsole\Metrics.TestConsole.csproj", "{1E8F49B4-B8D9-4932-909D-821AEFB869B0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metrics.AspSample", "Samples\Metrics.AspSample\Metrics.AspSample.csproj", "{83F38EB9-504D-4B85-A181-7309EA08FAC2}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCore.Metrics", "Src\Adapters\AspNetCore.Metrics\AspNetCore.Metrics.csproj", "{8AD2C970-EC7F-405B-B267-9F0C1AAD7CC4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Owin.Sample", "Samples\Owin.Sample\Owin.Sample.csproj", "{C400B4D6-98FD-46AD-B3E4-2FC3D3DC6C6C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCore.Sample", "Samples\AspNetCore.Sample\AspNetCore.Sample.csproj", "{52C0EDCD-3573-4B8B-ACB1-DDC9B7518DB3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -113,10 +115,6 @@ Global
{B7C6EF21-0797-4B53-A917-1CFF8267CD67}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7C6EF21-0797-4B53-A917-1CFF8267CD67}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7C6EF21-0797-4B53-A917-1CFF8267CD67}.Release|Any CPU.Build.0 = Release|Any CPU
{828188F9-26C2-4C93-A156-D9EA13D7E2FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{828188F9-26C2-4C93-A156-D9EA13D7E2FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{828188F9-26C2-4C93-A156-D9EA13D7E2FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{828188F9-26C2-4C93-A156-D9EA13D7E2FA}.Release|Any CPU.Build.0 = Release|Any CPU
{025CD6D0-1A1E-4B14-A7DB-AF5DFF887210}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{025CD6D0-1A1E-4B14-A7DB-AF5DFF887210}.Debug|Any CPU.Build.0 = Debug|Any CPU
{025CD6D0-1A1E-4B14-A7DB-AF5DFF887210}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -125,10 +123,18 @@ Global
{1E8F49B4-B8D9-4932-909D-821AEFB869B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E8F49B4-B8D9-4932-909D-821AEFB869B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E8F49B4-B8D9-4932-909D-821AEFB869B0}.Release|Any CPU.Build.0 = Release|Any CPU
{83F38EB9-504D-4B85-A181-7309EA08FAC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83F38EB9-504D-4B85-A181-7309EA08FAC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83F38EB9-504D-4B85-A181-7309EA08FAC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{83F38EB9-504D-4B85-A181-7309EA08FAC2}.Release|Any CPU.Build.0 = Release|Any CPU
{8AD2C970-EC7F-405B-B267-9F0C1AAD7CC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8AD2C970-EC7F-405B-B267-9F0C1AAD7CC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8AD2C970-EC7F-405B-B267-9F0C1AAD7CC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8AD2C970-EC7F-405B-B267-9F0C1AAD7CC4}.Release|Any CPU.Build.0 = Release|Any CPU
{C400B4D6-98FD-46AD-B3E4-2FC3D3DC6C6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C400B4D6-98FD-46AD-B3E4-2FC3D3DC6C6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C400B4D6-98FD-46AD-B3E4-2FC3D3DC6C6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C400B4D6-98FD-46AD-B3E4-2FC3D3DC6C6C}.Release|Any CPU.Build.0 = Release|Any CPU
{52C0EDCD-3573-4B8B-ACB1-DDC9B7518DB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52C0EDCD-3573-4B8B-ACB1-DDC9B7518DB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52C0EDCD-3573-4B8B-ACB1-DDC9B7518DB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52C0EDCD-3573-4B8B-ACB1-DDC9B7518DB3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -143,9 +149,10 @@ Global
{DAF70394-CE63-4D2F-B52B-839941827B4E} = {DEC3A50A-7243-45C0-9995-F829BFF99453}
{A9074D3E-3421-483D-AF98-4AAEEED11ECA} = {DEC3A50A-7243-45C0-9995-F829BFF99453}
{B7C6EF21-0797-4B53-A917-1CFF8267CD67} = {DEC3A50A-7243-45C0-9995-F829BFF99453}
{828188F9-26C2-4C93-A156-D9EA13D7E2FA} = {DEC3A50A-7243-45C0-9995-F829BFF99453}
{025CD6D0-1A1E-4B14-A7DB-AF5DFF887210} = {443860DA-6378-47D0-A4AE-4E79975C5E1C}
{1E8F49B4-B8D9-4932-909D-821AEFB869B0} = {2E004760-A644-4312-8489-6057B8B7554A}
{83F38EB9-504D-4B85-A181-7309EA08FAC2} = {DEC3A50A-7243-45C0-9995-F829BFF99453}
{8AD2C970-EC7F-405B-B267-9F0C1AAD7CC4} = {443860DA-6378-47D0-A4AE-4E79975C5E1C}
{C400B4D6-98FD-46AD-B3E4-2FC3D3DC6C6C} = {DEC3A50A-7243-45C0-9995-F829BFF99453}
{52C0EDCD-3573-4B8B-ACB1-DDC9B7518DB3} = {DEC3A50A-7243-45C0-9995-F829BFF99453}
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions Metrics.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Interfaces/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
6 changes: 6 additions & 0 deletions Samples/AspNetCore.Sample/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Metrics.GlobalContextName" value="OWINSamples" />
</appSettings>
</configuration>
28 changes: 28 additions & 0 deletions Samples/AspNetCore.Sample/AspNetCore.Sample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Src\Adapters\AspNetCore.Metrics\AspNetCore.Metrics.csproj">
<Project>{8AD2C970-EC7F-405B-B267-9F0C1AAD7CC4}</Project>
<Name>AspNetCore.Metrics</Name>
</ProjectReference>
<ProjectReference Include="..\..\Src\Metrics\Metrics.csproj">
<Project>{95E29D40-DBEC-49E2-9CC5-26B88966DADE}</Project>
<Name>Metrics</Name>
</ProjectReference>
<ProjectReference Include="..\Metrics.Samples\Metrics.Samples.csproj">
<Project>{D08A63D0-F440-477C-9565-1264AE0879D0}</Project>
<Name>Metrics.Samples</Name>
</ProjectReference>
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions Samples/AspNetCore.Sample/Controllers/SampleController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;

namespace AspNetCore.Sample.Controllers
{
[Route("sample")]
public class SampleController : Controller
{
[HttpGet]
public IEnumerable<string> Get()
{
return new[] { "value1", "value2" };
}

[HttpGet("withparams/{x}/{y}")]
public IEnumerable<string> Get(int x, string y)
{
return new[] { "value1", "value2" };
}
}
}
14 changes: 14 additions & 0 deletions Samples/AspNetCore.Sample/Controllers/SampleIgnoreController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.AspNetCore.Mvc;

namespace AspNetCore.Sample.Controllers
{
[Route("sampleignore")]
public class SampleIgnoreController : Controller
{
[HttpGet]
public string Get()
{
return "get";
}
}
}
45 changes: 45 additions & 0 deletions Samples/AspNetCore.Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using Metrics.Samples;
using Metrics.Utils;
using Microsoft.AspNetCore.Hosting;

namespace AspNetCore.Sample
{
public class Program
{
static void Main(string[] args)
{
const string url = "http://localhost:32132/";

using (var scheduler = new ActionScheduler())
{
using (var webHost = new WebHostBuilder()
.UseKestrel()
.UseStartup<Startup>()
.UseUrls(url)
.Build())
{
Console.WriteLine("AspNetCore Running at {0}", url);
Console.WriteLine("Press any key to exit");
//Process.Start(string.Format("{0}metrics/", url));

SampleMetrics.RunSomeRequests();

scheduler.Start(TimeSpan.FromMilliseconds(500), () =>
{
SetCounterSample.RunSomeRequests();
SetMeterSample.RunSomeRequests();
UserValueHistogramSample.RunSomeRequests();
UserValueTimerSample.RunSomeRequests();
SampleMetrics.RunSomeRequests();
});

HealthChecksSample.RegisterHealthChecks();

webHost.Run();

}
}
}
}
}
37 changes: 37 additions & 0 deletions Samples/AspNetCore.Sample/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

//TODO: Migrate to csproj
//// General Information about an assembly is controlled through the following
//// set of attributes. Change these attribute values to modify the information
//// associated with an assembly.
//[assembly: AssemblyTitle("WebApi.Sample")]
//[assembly: AssemblyDescription("")]
//[assembly: AssemblyConfiguration("")]
//[assembly: AssemblyCompany("")]
//[assembly: AssemblyProduct("WebApi.Sample")]
//[assembly: AssemblyCopyright("Copyright © 2014")]
//[assembly: AssemblyTrademark("")]
//[assembly: AssemblyCulture("")]
//
//// Setting ComVisible to false makes the types in this assembly not visible
//// to COM components. If you need to access a type in this assembly from
//// COM, set the ComVisible attribute to true on that type.
//[assembly: ComVisible(false)]
//
//// The following GUID is for the ID of the typelib if this project is exposed to COM
//[assembly: Guid("4118530f-7ae9-4639-b9ce-6e64c404ea8f")]
//
//// Version information for an assembly consists of the following four values:
////
//// Major Version
//// Minor Version
//// Build Number
//// Revision
////
//// You can specify all the values or you can default the Build and Revision Numbers
//// by using the '*' as shown below:
//// [assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
51 changes: 51 additions & 0 deletions Samples/AspNetCore.Sample/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.Text.RegularExpressions;
using AspNetCore.Metrics;
using Metrics;
using Metrics.Endpoints;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Formatting = Newtonsoft.Json.Formatting;

namespace AspNetCore.Sample
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}


public void Configure(IApplicationBuilder app)
{
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
Formatting = Formatting.Indented,
ContractResolver = new CamelCasePropertyNamesContractResolver()
};

app.UseCors(c => c.AllowAnyOrigin());

Metric.Config
//.WithReporting(r => r.WithConsoleReport(TimeSpan.FromSeconds(30)))
.WithAspNetCore(
middleware => app.Use(middleware),
config => config
.WithRequestMetricsConfig(c => c.WithAllAspNetCoreMetrics(), new[]
{
new Regex("(?i)^sampleignore"),
new Regex("(?i)^metrics"),
new Regex("(?i)^health"),
new Regex("(?i)^json")
})
.WithMetricsEndpoint(conf => conf
.WithEndpointReport("/test", (d, h, r) => new MetricsEndpointResponse("test", "text/plain")))
);

app.UseMvc();
}

}
}
6 changes: 6 additions & 0 deletions Samples/ConsoleApplication/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
41 changes: 41 additions & 0 deletions Samples/ConsoleApplication/AssemblyInfo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace ConsoleApplication.AssemblyInfo

open System.Reflection
open System.Runtime.CompilerServices
open System.Runtime.InteropServices

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[<assembly: AssemblyTitle("ConsoleApplication")>]
[<assembly: AssemblyDescription("")>]
[<assembly: AssemblyConfiguration("")>]
[<assembly: AssemblyCompany("")>]
[<assembly: AssemblyProduct("ConsoleApplication")>]
[<assembly: AssemblyCopyright("Copyright © 2017")>]
[<assembly: AssemblyTrademark("")>]
[<assembly: AssemblyCulture("")>]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[<assembly: ComVisible(false)>]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[<assembly: Guid("513A11F7-D772-4F00-978B-6F8D192005A1")>]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [<assembly: AssemblyVersion("1.0.*")>]
[<assembly: AssemblyVersion("1.0.0.0")>]
[<assembly: AssemblyFileVersion("1.0.0.0")>]

do
()
58 changes: 58 additions & 0 deletions Samples/ConsoleApplication/ConsoleApplication.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{513A11F7-D772-4F00-978B-6F8D192005A1}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ConsoleApplication</RootNamespace>
<AssemblyName>ConsoleApplication</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<DocumentationFile>bin\$(Configuration)\$(AssemblyName).xml</DocumentationFile>
<Name>ConsoleApplication</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\$(Configuration)\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<OtherFlags>--warnon:1182</OtherFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\$(Configuration)\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<OtherFlags>--warnon:1182</OtherFlags>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="FSharp.Core">
<HintPath>..\..\packages\FSharp.Core.4.1.18\lib\net45\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple">
<HintPath>..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Program.fs" />
<Content Include="packages.config" />
<None Include="App.config" />
</ItemGroup>
<PropertyGroup>
<FSharpTargetsPath>..\..\packages\FSharp.Compiler.Tools.4.1.23\tools\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')"/>
</Project>
Loading