Skip to content

Commit

Permalink
#3 remove Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
phnx47 committed Mar 23, 2018
1 parent d0fbe98 commit 3d5e69e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
4 changes: 2 additions & 2 deletions examples/WebApiApplication/WebApiApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="Prometheus.Client">
<HintPath>C:\Users\fenix\.nuget\packages\prometheus.client\1.0.0\lib\netstandard1.3\Prometheus.Client.dll</HintPath>
<Reference Include="Prometheus.Client, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\packages\prometheus.client\1.4.0\lib\net45\Prometheus.Client.dll</HintPath>
</Reference>
<Reference Include="protobuf-net, Version=2.1.0.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
<HintPath>..\..\packages\protobuf-net.2.1.0\lib\net451\protobuf-net.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion src/Prometheus.Client.Owin/Prometheus.Client.Owin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Description>An Owin handler for the Prometheus.Client</Description>
<Copyright>2017 © Sergey Kuznetsov</Copyright>
<AssemblyTitle>Prometheus.Client.Owin</AssemblyTitle>
<VersionPrefix>1.4.0</VersionPrefix>
<VersionPrefix>1.4.1</VersionPrefix>
<Authors>Sergey Kuznetsov</Authors>
<TargetFrameworks>net45;netstandard1.3;netstandard2.0</TargetFrameworks>
<AssemblyName>Prometheus.Client.Owin</AssemblyName>
Expand Down
32 changes: 11 additions & 21 deletions src/Prometheus.Client.Owin/PrometheusExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.AspNetCore.Builder;
#else
using Owin;

#endif

namespace Prometheus.Client.Owin
Expand All @@ -30,21 +29,17 @@ public static IApplicationBuilder UsePrometheusServer(this IApplicationBuilder a
public static IApplicationBuilder UsePrometheusServer(this IApplicationBuilder app, PrometheusOptions options)
{
if (app == null)
{
throw new ArgumentNullException(nameof(app));
}

if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
if (options.MapPath.StartsWith("/"))
{
throw new ArgumentException($"Path '{options.MapPath}' cannot start with '/'");
}

if (!options.MapPath.StartsWith("/"))
options.MapPath = "/" + options.MapPath;

RegisterCollectors(options);

app.Map(string.Format("/{0}", options.MapPath), coreapp =>
app.Map(options.MapPath, coreapp =>
{
coreapp.Run(async context =>
{
Expand Down Expand Up @@ -85,21 +80,17 @@ public static IAppBuilder UsePrometheusServer(this IAppBuilder app)
public static IAppBuilder UsePrometheusServer(this IAppBuilder app, PrometheusOptions options)
{
if (app == null)
{
throw new ArgumentNullException(nameof(app));
}

if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
if (options.MapPath.StartsWith("/"))
{
throw new ArgumentException($"Path '{options.MapPath}' cannot start with '/'");
}


if (!options.MapPath.StartsWith("/"))
options.MapPath = "/" + options.MapPath;

RegisterCollectors(options);

app.Map($"/{options.MapPath}", coreapp =>
app.Map(options.MapPath, coreapp =>
{
coreapp.Run(async context =>
{
Expand Down Expand Up @@ -139,7 +130,6 @@ private static void RegisterCollectors(PrometheusOptions options)
options.Collectors.AddRange(DefaultCollectors.Get(metricFactory));
}


options.CollectorRegistryInstance.RegisterOnDemandCollectors(options.Collectors);
}
}
Expand Down

0 comments on commit 3d5e69e

Please sign in to comment.