Skip to content

Commit 000e374

Browse files
committed
create MetricServer
1 parent a987d95 commit 000e374

22 files changed

+769
-0
lines changed

.gitattributes

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.nupkg
2+
*.user
3+
*.suo
4+
*.exe
5+
6+
.vs
7+
bin
8+
obj
9+
packages

Prometheus.Client.MetricServer.sln

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26228.4
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8E29CEE6-355D-427A-8EDA-F2A1FE60BC3B}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prometheus.Client.MetricServer", "src\Prometheus.Client.MetricServer\Prometheus.Client.MetricServer.csproj", "{C77F577A-8639-4A63-966D-80C174B3D999}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{37C0D023-77CB-4164-9BF4-07D6AF18CA55}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiApplication", "examples\WebApiApplication\WebApiApplication.csproj", "{22C001AB-416F-4BA0-9F93-870ED8EFE294}"
13+
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreConsole", "Examples\CoreConsole\CoreConsole.csproj", "{697F4F23-C0B6-4A22-A55F-B94E99BF5999}"
15+
EndProject
16+
Global
17+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
18+
Debug|Any CPU = Debug|Any CPU
19+
Release|Any CPU = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
22+
{C77F577A-8639-4A63-966D-80C174B3D999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{C77F577A-8639-4A63-966D-80C174B3D999}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{C77F577A-8639-4A63-966D-80C174B3D999}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{C77F577A-8639-4A63-966D-80C174B3D999}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{22C001AB-416F-4BA0-9F93-870ED8EFE294}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{22C001AB-416F-4BA0-9F93-870ED8EFE294}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{22C001AB-416F-4BA0-9F93-870ED8EFE294}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{22C001AB-416F-4BA0-9F93-870ED8EFE294}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{697F4F23-C0B6-4A22-A55F-B94E99BF5999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{697F4F23-C0B6-4A22-A55F-B94E99BF5999}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{697F4F23-C0B6-4A22-A55F-B94E99BF5999}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{697F4F23-C0B6-4A22-A55F-B94E99BF5999}.Release|Any CPU.Build.0 = Release|Any CPU
34+
EndGlobalSection
35+
GlobalSection(SolutionProperties) = preSolution
36+
HideSolutionNode = FALSE
37+
EndGlobalSection
38+
GlobalSection(NestedProjects) = preSolution
39+
{C77F577A-8639-4A63-966D-80C174B3D999} = {8E29CEE6-355D-427A-8EDA-F2A1FE60BC3B}
40+
{22C001AB-416F-4BA0-9F93-870ED8EFE294} = {37C0D023-77CB-4164-9BF4-07D6AF18CA55}
41+
{697F4F23-C0B6-4A22-A55F-B94E99BF5999} = {37C0D023-77CB-4164-9BF4-07D6AF18CA55}
42+
EndGlobalSection
43+
EndGlobal

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Prometheus.Client.MetricServer
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp1.1</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\..\src\Prometheus.Client.MetricServer\Prometheus.Client.MetricServer.csproj" />
10+
</ItemGroup>
11+
12+
</Project>

examples/CoreConsole/Program.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using Prometheus.Client;
3+
using Prometheus.Client.MetricServer;
4+
5+
namespace CoreConsole
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
IMetricServer metricServer = new MetricServer("localhost", 9091);
12+
metricServer.Start();
13+
14+
var counter = Metrics.CreateCounter("test_count", "helptext");
15+
counter.Inc();
16+
17+
Console.WriteLine("Press any key..");
18+
Console.ReadKey();
19+
metricServer.Stop();
20+
}
21+
}
22+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Web.Http;
2+
3+
namespace WebApiApplication
4+
{
5+
public static class WebApiConfig
6+
{
7+
public static void Register(HttpConfiguration config)
8+
{
9+
// Web API configuration and services
10+
11+
// Web API routes
12+
config.MapHttpAttributeRoutes();
13+
14+
config.Routes.MapHttpRoute(
15+
name: "DefaultApi",
16+
routeTemplate: "{controller}",
17+
defaults: new { id = RouteParameter.Optional }
18+
);
19+
}
20+
}
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Web.Http;
2+
using Prometheus.Client;
3+
4+
namespace WebApiApplication.Controllers
5+
{
6+
public class CounterController : ApiController
7+
{
8+
readonly Counter _counter = Metrics.CreateCounter("myCounter", "some help about this");
9+
10+
[HttpGet]
11+
public IHttpActionResult Get()
12+
{
13+
_counter.Inc();
14+
return Ok();
15+
}
16+
}
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%@ Application Codebehind="Global.asax.cs" Inherits="WebApiApplication.WebApiApplication" Language="C#" %>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Web.Http;
2+
using Prometheus.Client.MetricServer;
3+
4+
namespace WebApiApplication
5+
{
6+
public class WebApiApplication : System.Web.HttpApplication
7+
{
8+
private IMetricServer _metricServer;
9+
10+
protected void Application_Start()
11+
{
12+
13+
GlobalConfiguration.Configure(WebApiConfig.Register);
14+
_metricServer = new MetricServer("localhost", 9091);
15+
_metricServer.Start();
16+
}
17+
18+
protected void Application_Stop()
19+
{
20+
_metricServer?.Stop();
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)