Skip to content
This repository has been archived by the owner on Mar 26, 2019. It is now read-only.

Commit

Permalink
#12 app metrics 2.0 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
alhardy committed Jun 23, 2017
1 parent 4392838 commit 3f521c6
Show file tree
Hide file tree
Showing 52 changed files with 497 additions and 557 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ notifications:
- al_hardy@live.com.au

language: csharp
dotnet: 1.0.4
dotnet: 2.0.0-preview1-005977
os:
# - osx
- linux
Expand All @@ -16,6 +16,10 @@ script:
# .NET CLI require Ubuntu 14.04
sudo: required
dist: trusty
env:
global:
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
- DOTNET_CLI_TELEMETRY_OPTOUT: 1
addons:
apt:
packages:
Expand Down
4 changes: 3 additions & 1 deletion AppMetrics.Extensions.InfluxDB.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
VisualStudioVersion = 15.0.26606.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2D805782-756E-4C98-B22E-F502BEE95318}"
EndProject
Expand All @@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
AppMetrics.ruleset = AppMetrics.ruleset
appveyor.yml = appveyor.yml
stylecop.json = stylecop.json
version.props = version.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{DD2E4647-7125-4CE3-9BA5-B45A26113A31}"
Expand Down Expand Up @@ -55,6 +56,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{28CE67A4-2662-43AA-B42E-B3C8F33DF31B}"
ProjectSection(SolutionItems) = preProject
build\common.props = build\common.props
build\dependencies.props = build\dependencies.props
EndProjectSection
EndProject
Global
Expand Down
10 changes: 8 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
version: 1.0.{build}
image: Visual Studio 2017
image: Visual Studio 2017 Preview
environment:
COVERALLS_REPO_TOKEN:
secure: jE+uYnSDVrBExOFkaPPHpJeKfHxVuS+lYvS+8BlcKBTSioz25h+rBq3RxMGl9JBd
PreReleaseSuffix: alpha
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
CoverWith: OpenCover
PreReleaseSuffix: alpha
GitUser:
secure: zAdAOUUof3XGDsdOBRYg7J7wZS44iL4VjI/MVGw+JnU=
GitOwner:
Expand All @@ -28,4 +30,8 @@ deploy:
server: https://www.myget.org/F/alhardy/api/v2/package
api_key:
secure: gIAiACgNj+JzXyLLTe3rLxZyrAB9RpC8Lw81xEjdOLXqotprqEwGiFWRipEqkpps
skip_symbols: true
skip_symbols: true
symbol_server: https://www.myget.org/F/alhardy/symbol
skip_commits:
files:
- '**/*.md'
26 changes: 7 additions & 19 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ var configuration = HasArgument("BuildConfiguration") ? Argument<s
EnvironmentVariable("BuildConfiguration") != null ? EnvironmentVariable("BuildConfiguration") : "Release";
var coverWith = HasArgument("CoverWith") ? Argument<string>("CoverWith") :
EnvironmentVariable("CoverWith") != null ? EnvironmentVariable("CoverWith") : "OpenCover"; // None, DotCover, OpenCover
var skipReSharperCodeInspect = Argument("SkipCodeInspect", false) || !IsRunningOnWindows();
var skipReSharperCodeInspect = HasArgument("SkipCodeInspect") ? Argument<bool>("SkipCodeInspect", false) || !IsRunningOnWindows(): true;
var preReleaseSuffix = HasArgument("PreReleaseSuffix") ? Argument<string>("PreReleaseSuffix") :
(AppVeyor.IsRunningOnAppVeyor && EnvironmentVariable("PreReleaseSuffix") == null || AppVeyor.Environment.Repository.Tag.IsTag) ? null :
(AppVeyor.IsRunningOnAppVeyor && EnvironmentVariable("PreReleaseSuffix") == null) || (AppVeyor.IsRunningOnAppVeyor && AppVeyor.Environment.Repository.Tag.IsTag) ? null :
EnvironmentVariable("PreReleaseSuffix") != null ? EnvironmentVariable("PreReleaseSuffix") : "ci";
var buildNumber = HasArgument("BuildNumber") ? Argument<int>("BuildNumber") :
AppVeyor.IsRunningOnAppVeyor ? AppVeyor.Environment.Build.Number :
TravisCI.IsRunningOnTravisCI ? TravisCI.Environment.Build.BuildNumber :
EnvironmentVariable("BuildNumber") != null ? int.Parse(EnvironmentVariable("BuildNumber")) : 0;
var gitUser = HasArgument("GitUser") ? Argument<string>("GitUser") : EnvironmentVariable("GitUser");
var gitPassword = HasArgument("GitPassword") ? Argument<string>("GitPassword") : EnvironmentVariable("GitPassword");
var skipHtmlCoverageReport = Argument("SkipHtmlCoverageReport", true) || !IsRunningOnWindows();
var skipHtmlCoverageReport = HasArgument("SkipHtmlCoverageReport") ? Argument<bool>("SkipHtmlCoverageReport", true) || !IsRunningOnWindows() : true;

//////////////////////////////////////////////////////////////////////
// DEFINE FILES & DIRECTORIES
Expand Down Expand Up @@ -58,7 +58,7 @@ var openCoverFilter = "+[App.Metrics*]* -[xunit.*]* -[*.Facts]*";
var openCoverExcludeFile = "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs";
var coverIncludeFilter = "+:App.Metrics*";
var coverExcludeFilter = "-:*.Facts";
var excludeFromCoverage = "*.AppMetricsExcludeFromCodeCoverage*";
var excludeFromCoverage = "*.ExcludeFromCodeCoverage*";
string versionSuffix = null;

if (!string.IsNullOrEmpty(preReleaseSuffix))
Expand Down Expand Up @@ -146,21 +146,15 @@ Task("Build")

foreach(var project in projects)
{
// Ignore Net452 on non-windows environments
if (project.Path.ToString().Contains("Net452"))
{
continue;
}

var parsedProject = ParseProject(new FilePath(project.Path.ToString()), configuration);

if (parsedProject.IsLibrary() && !project.Path.ToString().Contains(".Sandbox")&& !project.Path.ToString().Contains(".Facts") && !project.Path.ToString().Contains(".Benchmarks"))
{
settings.Framework = "netstandard1.6";
settings.Framework = "netstandard2.0";
}
else
{
settings.Framework = "netcoreapp1.1";
settings.Framework = "netcoreapp2.0";
}

Context.Information("Building as " + settings.Framework + ": " + project.Path.ToString());
Expand Down Expand Up @@ -227,15 +221,9 @@ Task("RunTests")
ArgumentCustomization = args => args.Append("--logger:trx")
};

// Ignore Net452 on non-windows environments
if (folderName.Contains("Net452") && !IsRunningOnWindows())
{
continue;
}

if (!IsRunningOnWindows())
{
settings.Framework = "netcoreapp1.1";
settings.Framework = "netcoreapp2.0";
}

DotNetCoreTest(project.FullPath, settings);
Expand Down
4 changes: 3 additions & 1 deletion build/common.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Project>
<Import Project="dependencies.props" />
<Import Project="..\version.props" />

<PropertyGroup>
<Copyright>Allan Hardy 2016</Copyright>
<Authors>Allan Hardy</Authors>
Expand All @@ -15,7 +18,6 @@
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<CodeAnalysisRuleSet>..\..\AppMetrics.ruleset</CodeAnalysisRuleSet>
<DebugType>full</DebugType>
</PropertyGroup>

<ItemGroup>
Expand Down
21 changes: 21 additions & 0 deletions build/dependencies.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project>
<PropertyGroup>
<AppMetricsCoreVersion>2.0.0-*</AppMetricsCoreVersion>
<AppMetricsMiddlewareVersion>2.0.0-*</AppMetricsMiddlewareVersion>
<AppMetricsReportingVersion>2.0.0-*</AppMetricsReportingVersion>
<AspNetCoreVersion>2.0.0-*</AspNetCoreVersion>
<CoreFxVersion>4.4.0-*</CoreFxVersion>
<DependencyModelVersion>2.0.0-*</DependencyModelVersion>
<BenchmarkDotNetVersion>0.10.8</BenchmarkDotNetVersion>
<MoqVersion>4.7.1</MoqVersion>
<NETStandardLibraryNETFrameworkVersion>2.0.0-*</NETStandardLibraryNETFrameworkVersion>
<RoslynVersion>2.0.0</RoslynVersion>
<RuntimeFrameworkVersion Condition="'$(TargetFramework)'=='netcoreapp2.0'">2.0.0-*</RuntimeFrameworkVersion>
<DotNetCliVersion>2.0.0-preview1-005977</DotNetCliVersion>
<TestSdkVersion>15.3.0-*</TestSdkVersion>
<XunitVersion>2.3.0-beta3-*</XunitVersion>
<FluentAssertionsVersion>4.19.2</FluentAssertionsVersion>
<FluentAssertionsJsonVersion>4.19.0</FluentAssertionsJsonVersion>
<StyleCopAnalyzersVersion>1.0.0</StyleCopAnalyzersVersion>
</PropertyGroup>
</Project>
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"projects": [ "src", "test", "sandbox" ],
"sdk": {
"version": "2.0.0-preview1-005977"
}
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<Import Project="..\..\build\common.props" />

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<DockerComposeProjectPath>..\..\docker-compose.dcproj</DockerComposeProjectPath>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="App.Metrics" Version="1.2.0" />
<PackageReference Include="App.Metrics.Concurrency" Version="1.2.0" />
<PackageReference Include="App.Metrics.Extensions.Middleware" Version="1.2.0" />
<PackageReference Include="App.Metrics.Extensions.Mvc" Version="1.2.0" />
<PackageReference Include="App.Metrics.Formatters.Ascii" Version="1.0.0" />
<PackageReference Include="App.Metrics.Formatters.Json" Version="1.2.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
<PackageReference Include="App.Metrics" Version="$(AppMetricsCoreVersion)" />
<PackageReference Include="App.Metrics.Core" Version="$(AppMetricsCoreVersion)" />
<PackageReference Include="App.Metrics.Middleware" Version="$(AppMetricsMiddlewareVersion)" />
<PackageReference Include="App.Metrics.Mvc" Version="$(AppMetricsMiddlewareVersion)" />
<PackageReference Include="App.Metrics.Middleware.Formatters.Ascii" Version="$(AppMetricsMiddlewareVersion)" />
<PackageReference Include="App.Metrics.Middleware.Formatters.Json" Version="$(AppMetricsMiddlewareVersion)" />
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\App.Metrics.Extensions.Reporting.InfluxDB\App.Metrics.Extensions.Reporting.InfluxDB.csproj" />
<ProjectReference Include="..\..\src\App.Metrics.Formatters.InfluxDB\App.Metrics.Formatters.InfluxDB.csproj" />
</ItemGroup>

<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="$(AspNetCoreVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
// <copyright file="ExceptionThrowingController.cs" company="Allan Hardy">
// Copyright (c) Allan Hardy. All rights reserved.
// </copyright>

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
// <copyright file="FileController.cs" company="Allan Hardy">
// Copyright (c) Allan Hardy. All rights reserved.
// </copyright>

using System;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// <copyright file="FrustratingController.cs" company="Allan Hardy">
// Copyright (c) Allan Hardy. All rights reserved.
// </copyright>

using System;
using System.Threading.Tasks;
using App.Metrics.InfluxDB.Sandbox.JustForTesting;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
// <copyright file="RandomStatusCodeController.cs" company="Allan Hardy">
// Copyright (c) Allan Hardy. All rights reserved.
// </copyright>

using System;
using App.Metrics.InfluxDB.Sandbox.JustForTesting;
using Microsoft.AspNetCore.Mvc;

Expand All @@ -18,7 +22,7 @@ public RandomStatusCodeController(IMetrics metrics, RandomStatusCodeForTesting r

[HttpGet]
public IActionResult Get()
{
{
return StatusCode(_randomStatusCodeForTesting.NextStatusCode);
}
}
Expand Down
29 changes: 29 additions & 0 deletions sandbox/App.Metrics.InfluxDB.Sandbox/Controllers/Registry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// <copyright file="Registry.cs" company="Allan Hardy">
// Copyright (c) Allan Hardy. All rights reserved.
// </copyright>

namespace App.Metrics.InfluxDB.Sandbox.Controllers
{
// public static class Registry
// {
// public static HistogramOptions One = new HistogramOptions
// // ReSharper restore UnusedMember.Global
// {
// Name = "test1",
// MeasurementUnit = Unit.Bytes,
// Context = "test"
// };
// public static HistogramOptions Two = new HistogramOptions
// {
// Name = "test2",
// MeasurementUnit = Unit.Bytes,
// Context = "test"
// };
// public static HistogramOptions Three = new HistogramOptions
// {
// Name = "test3",
// MeasurementUnit = Unit.Bytes,
// Context = "test"
// };
// }
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,22 @@
using System;
// <copyright file="SatisfyingController.cs" company="Allan Hardy">
// Copyright (c) Allan Hardy. All rights reserved.
// </copyright>

using System.Threading.Tasks;
using App.Metrics.Core.Options;
using App.Metrics.InfluxDB.Sandbox.JustForTesting;
using Microsoft.AspNetCore.Mvc;

namespace App.Metrics.InfluxDB.Sandbox.Controllers
{
public static class Registry
{
public static HistogramOptions One = new HistogramOptions
{
Name = "test1",
MeasurementUnit = Unit.Bytes,
Context = "test"
};

public static HistogramOptions Two = new HistogramOptions
{
Name = "test2",
MeasurementUnit = Unit.Bytes,
Context = "test"
};

public static HistogramOptions Three = new HistogramOptions
{
Name = "test3",
MeasurementUnit = Unit.Bytes,
Context = "test"
};
}

[Route("api/[controller]")]
public class SatisfyingController : Controller
{
private readonly RequestDurationForApdexTesting _durationForApdexTesting;
private static readonly Random Rnd = new Random();
private readonly IMetrics _metrics;
// private static readonly Random Rnd = new Random();
// private readonly IMetrics _metrics;

public SatisfyingController(IMetrics metrics, RequestDurationForApdexTesting durationForApdexTesting)
{
_metrics = metrics ?? throw new ArgumentNullException(nameof(metrics));
_durationForApdexTesting = durationForApdexTesting;
}

Expand All @@ -48,14 +25,13 @@ public async Task<int> Get()
{
var duration = _durationForApdexTesting.NextSatisfiedDuration;

//foreach (var i in Enumerable.Range(1, 500))
//{
// var tags = new MetricTags($"key{i}", $"value{i}");

// _metrics.Measure.Histogram.Update(Registry.One, tags, Rnd.Next(1, 500));
// _metrics.Measure.Histogram.Update(Registry.Two, tags, Rnd.Next(1, 500));
// _metrics.Measure.Histogram.Update(Registry.Three, tags, Rnd.Next(1, 500));
//}
// foreach (var i in Enumerable.Range(1, 500))
// {
// var tags = new MetricTags($"key{i}", $"value{i}");
// _metrics.Measure.Histogram.Update(Registry.One, tags, Rnd.Next(1, 500));
// _metrics.Measure.Histogram.Update(Registry.Two, tags, Rnd.Next(1, 500));
// _metrics.Measure.Histogram.Update(Registry.Three, tags, Rnd.Next(1, 500));
// }

await Task.Delay(duration, HttpContext.RequestAborted);

Expand Down
Loading

0 comments on commit 3f521c6

Please sign in to comment.