Skip to content

Updating references to App.Metrics 3.0 #29

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 11 commits into
base: dev
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
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:
- [email protected]

language: csharp
dotnet: 1.0.4
dotnet: 2.0.0
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
31 changes: 22 additions & 9 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ var coverWith = HasArgument("CoverWith") ? Argument<string>("CoverWith") :
EnvironmentVariable("CoverWith") != null ? EnvironmentVariable("CoverWith") : "DotCover"; // None, DotCover, OpenCover
var skipReSharperCodeInspect = HasArgument("SkipCodeInspect") ? Argument<bool>("SkipCodeInspect", false) || !IsRunningOnWindows(): true;
var preReleaseSuffix = HasArgument("PreReleaseSuffix") ? Argument<string>("PreReleaseSuffix") :
(AppVeyor.IsRunningOnAppVeyor && EnvironmentVariable("PreReleaseSuffix") == null) || (AppVeyor.IsRunningOnAppVeyor && AppVeyor.Environment.Repository.Tag.IsTag) ? null :
EnvironmentVariable("PreReleaseSuffix") != null ? EnvironmentVariable("PreReleaseSuffix") : "ci";
(AppVeyor.IsRunningOnAppVeyor && EnvironmentVariable("PreReleaseSuffix") == null) || (AppVeyor.IsRunningOnAppVeyor && AppVeyor.Environment.Repository.Tag.IsTag && !packageRelease)
? 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 :
Expand Down Expand Up @@ -68,23 +68,36 @@ var coverExcludeFilter = "-:*.Facts";
var excludeFromCoverage = "*.ExcludeFromCodeCoverage*";
string versionSuffix = null;

if (!string.IsNullOrEmpty(preReleaseSuffix))
if (AppVeyor.IsRunningOnAppVeyor)
{
if (packageRelease)
if (AppVeyor.Environment.Repository.Tag.IsTag)
{
versionSuffix = preReleaseSuffix;
// Stable release package, pushed to nuget
}
else if (string.IsNullOrEmpty(preReleaseSuffix))
{
// Next stable release development package, not pushed to nuget
versionSuffix = buildNumber.ToString("D4");
}
else
{
versionSuffix = preReleaseSuffix + "-" + buildNumber.ToString("D4");
if (packageRelease)
{
// Pre-release package, set version suffix without build number, not tagged until stable release but pushed to nuget
versionSuffix = preReleaseSuffix;
}
else
{
// Pre-release development package, set version suffix with build number, not pushed to nuget
versionSuffix = preReleaseSuffix + "-" + buildNumber.ToString("D4");
}
}
}
else if (AppVeyor.IsRunningOnAppVeyor && !AppVeyor.Environment.Repository.Tag.IsTag && !packageRelease)
else
{
versionSuffix = buildNumber.ToString("D4");
versionSuffix = preReleaseSuffix + "-" + buildNumber.ToString("D4");
}


//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Expand Down
23 changes: 12 additions & 11 deletions build/dependencies.props
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<Project>
<PropertyGroup>
<AppMetricsCoreVersion>2.0.0-*</AppMetricsCoreVersion>
<AppMetricsAspNetCoreVersion>2.0.0-*</AppMetricsAspNetCoreVersion>
<AspNetCoreVersion>2.0.0-*</AspNetCoreVersion>
<AppMetricsAbstractionsVersion>3.0.0-*</AppMetricsAbstractionsVersion>
<AppMetricsCoreVersion>3.0.0-*</AppMetricsCoreVersion>
<AppMetricsAspNetCoreVersion>3.0.0-*</AppMetricsAspNetCoreVersion>
<AspNetCoreVersion>2.1.6</AspNetCoreVersion>
<AspNetCoreMvcVersion>2.2.0</AspNetCoreMvcVersion>
<MicrosoftExtensionsVersion>2.2.0</MicrosoftExtensionsVersion>
<BenchmarkDotNetVersion>0.10.8</BenchmarkDotNetVersion>
<CoreFxVersion>4.4.0-*</CoreFxVersion>
<DependencyModelVersion>2.0.0-*</DependencyModelVersion>
<MoqVersion>4.7.49</MoqVersion>
<NewtonsoftVersion>10.0.2</NewtonsoftVersion>
<NETStandardLibraryNETFrameworkVersion>2.0.0-*</NETStandardLibraryNETFrameworkVersion>
<RuntimeFrameworkVersion Condition="'$(TargetFramework)'=='netcoreapp2.0'">2.0.0-*</RuntimeFrameworkVersion>
<TestSdkVersion>15.3.0-*</TestSdkVersion>
<XunitVersion>2.3.0-beta2-*</XunitVersion>
<CoreFxVersion>4.4.0</CoreFxVersion>
<DependencyModelVersion>2.1.1</DependencyModelVersion>
<MoqVersion>4.10.0</MoqVersion>
<NewtonsoftVersion>11.0.2</NewtonsoftVersion>
<TestSdkVersion>15.9.0</TestSdkVersion>
<XunitVersion>2.4.1</XunitVersion>
<FluentAssertionsVersion>4.19.2</FluentAssertionsVersion>
<FluentAssertionsJsonVersion>4.19.0</FluentAssertionsJsonVersion>
<StyleCopAnalyzersVersion>1.0.0</StyleCopAnalyzersVersion>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projects": [ "src", "test", "benchmarks", "sandbox" ],
"sdk": {
"version": "2.0.0"
"version": "2.2.101"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.2;net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.2</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="App.Metrics" Version="$(AppMetricsCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftExtensionsVersion)" />
<PackageReference Include="Serilog.Sinks.Literate" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="3.3.3" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<Import Project="..\..\build\common.props" />

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.2;net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.2</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="App.Metrics.AspNetCore.Mvc" Version="$(AppMetricsAspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreMvcVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(MicrosoftExtensionsVersion)" />
<PackageReference Include="Serilog.Sinks.Literate" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="3.3.3" />
<PackageReference Include="Serilog.AspNetCore " Version="2.0.0" />
Expand All @@ -27,10 +27,6 @@
</Content>
</ItemGroup>

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

<ItemGroup>
<Folder Include="Controllers\" />
<Folder Include="JustForTesting\" />
Expand Down
2 changes: 1 addition & 1 deletion sandbox/MetricsElasticsearchSandboxMvc/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void ConfigureServices(IServiceCollection services)
{
services.AddTestStuff();

services.AddMvc(options => options.AddMetricsResourceFilter());
services.AddMvc().AddMetrics();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@

<PropertyGroup>
<Description>App Metrics Formatting, formatting metrics data to Elasticsearch formats.</Description>
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
<PackageTags>appmetrics;elasticsearch</PackageTags>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<PackageTags>appmetrics;elasticsearch</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="App.Metrics.Core" Version="$(AppMetricsCoreVersion)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="App.Metrics.Abstractions" Version="$(AppMetricsAbstractionsVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ public static class ElasticsearchFormatterConstants
{
public class ElasticsearchDefaults
{
public static readonly Dictionary<HistogramValueDataKeys, string> CustomHistogramDataKeys = new Dictionary<HistogramValueDataKeys, string>
public static readonly Dictionary<HistogramFields, string> CustomHistogramDataKeys = new Dictionary<HistogramFields, string>
{
{
HistogramValueDataKeys.Count,
HistogramFields.Count,
"countHist"
},
{
HistogramValueDataKeys.UserLastValue,
HistogramFields.UserLastValue,
"userLast"
},
{
HistogramValueDataKeys.UserMinValue,
HistogramFields.UserMinValue,
"userMin"
},
{
HistogramValueDataKeys.UserMaxValue,
HistogramFields.UserMaxValue,
"userMax"
}
};

public static readonly Dictionary<MeterValueDataKeys, string> CustomMeterDataKeys = new Dictionary<MeterValueDataKeys, string>
public static readonly Dictionary<MeterFields, string> CustomMeterDataKeys = new Dictionary<MeterFields, string>
{
{ MeterValueDataKeys.Count, "countMeter" },
{ MeterValueDataKeys.RateMean, "rateMean" }
{ MeterFields.Count, "countMeter" },
{ MeterFields.RateMean, "rateMean" }
};

public static readonly string[] SpecialChars = { @"\", @"/", " ", "-", "+", "=", "{", "}", "[", "]", ":", "&", "^", "~", "?", "!", "," };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public MetricSnapshotElasticsearchWriter(
TextWriter textWriter,
string elasticsearchIndex,
Func<string, string, string> metricNameFormatter = null,
Func<string, string> metricTagValueFormatter = null,
GeneratedMetricNameMapping dataKeys = null)
Func<string, string> metricTagValueFormatter = null)
{
if (string.IsNullOrWhiteSpace(elasticsearchIndex))
{
Expand All @@ -36,15 +35,8 @@ public MetricSnapshotElasticsearchWriter(
_bulkPayload = new BulkPayload(serializer, elasticsearchIndex);
_metricNameFormatter = metricNameFormatter ?? ElasticsearchFormatterConstants.ElasticsearchDefaults.MetricNameFormatter;
_metricTagValueFormatter = metricTagValueFormatter ?? ElasticsearchFormatterConstants.ElasticsearchDefaults.MetricTagValueFormatter;

MetricNameMapping = dataKeys ?? new GeneratedMetricNameMapping(
histogram: ElasticsearchFormatterConstants.ElasticsearchDefaults.CustomHistogramDataKeys,
meter: ElasticsearchFormatterConstants.ElasticsearchDefaults.CustomMeterDataKeys);
}

/// <inheritdoc />
public GeneratedMetricNameMapping MetricNameMapping { get; }

/// <inheritdoc />
public void Dispose()
{
Expand All @@ -53,7 +45,7 @@ public void Dispose()
}

/// <inheritdoc />
public void Write(string context, string name, object value, MetricTags tags, DateTime timestamp)
public void Write(string context, string name, string field, object value, MetricTags tags, DateTime timestamp)
{
var tagKeyValues = tags.ToDictionary(_metricTagValueFormatter);
var measurement = _metricNameFormatter(context, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ public class MetricsElasticsearchDocumentFormattingOptions
{
public MetricsElasticsearchDocumentFormattingOptions()
{
MetricNameMapping = new GeneratedMetricNameMapping(
histogram: ElasticsearchFormatterConstants.ElasticsearchDefaults.CustomHistogramDataKeys,
meter: ElasticsearchFormatterConstants.ElasticsearchDefaults.CustomMeterDataKeys);
MetricTagFormatter = ElasticsearchFormatterConstants.ElasticsearchDefaults.MetricTagValueFormatter;
MetricNameFormatter = ElasticsearchFormatterConstants.ElasticsearchDefaults.MetricNameFormatter;
}

public Func<string, string, string> MetricNameFormatter { get; set; }

public Func<string, string> MetricTagFormatter { get; set; }

public GeneratedMetricNameMapping MetricNameMapping { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public MetricsElasticsearchOutputFormatter(
/// <inheritdoc />
public MetricsMediaTypeValue MediaType => new MetricsMediaTypeValue("text", "vnd.appmetrics.metrics.elasticsearch", "v1", "plain");

/// <inheritdoc />
public MetricFields MetricFields { get; set; }

/// <inheritdoc />
public Task WriteAsync(
Stream output,
Expand All @@ -64,18 +67,13 @@ public Task WriteAsync(
streamWriter,
_elasticsearchIndex,
_options.MetricNameFormatter,
_options.MetricTagFormatter,
_options.MetricNameMapping))
_options.MetricTagFormatter))
{
serializer.Serialize(textWriter, metricsData);
serializer.Serialize(textWriter, metricsData, MetricFields);
}
}

#if !NETSTANDARD1_6
return AppMetricsTaskHelper.CompletedTask();
#else
return Task.CompletedTask;
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@

<PropertyGroup>
<Description>Provides Elasticsearch reporting capability to App Metrics.</Description>
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
<PackageTags>appmetrics;reporting;elasticsearch</PackageTags>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<PackageTags>appmetrics;reporting;elasticsearch</PackageTags>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\App.Metrics.Formatters.Elasticsearch\App.Metrics.Formatters.Elasticsearch.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="App.Metrics.Abstractions" Version="$(AppMetricsCoreVersion)" />
<PackageReference Include="App.Metrics.Core" Version="$(AppMetricsCoreVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<Import Project="..\..\build\common.props" />

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.2;net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.2</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -13,7 +13,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsVersion)" />
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
<PackageReference Include="Moq" Version="$(MoqVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
Expand Down
2 changes: 1 addition & 1 deletion version.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- This file may be overwritten by automation. -->
<Project>
<PropertyGroup>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionPrefix>3.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>