Skip to content

Commit b62d28f

Browse files
author
Daniel James
committed
(+semver: major) Initial implementation
0 parents  commit b62d28f

14 files changed

Lines changed: 484 additions & 0 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.vs
2+
obj
3+
bin

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language: csharp
2+
3+
os: linux
4+
dist: trusty
5+
sudo: required
6+
dotnet: 2.0.0
7+
8+
script:
9+
- dotnet restore ./src/Akka.Monitoring.Prometheus
10+
- dotnet build ./src/Akka.Monitoring.Prometheus
11+
- "if [[ $TRAVIS_PULL_REQUEST == 'false' && $TRAVIS_TAG ]]; then
12+
dotnet build ./src/Akka.Monitoring.Prometheus --configuration Release /p:Version=$TRAVIS_TAG;
13+
dotnet pack ./src/Akka.Monitoring.Prometheus --configuration Release /p:Version=$TRAVIS_TAG;
14+
nuget push ./src/Akka.Monitoring.Prometheus/bin/Release/*.nupkg -ApiKey $NUGET_API_KEY;
15+
fi"

Akka.Monitoring.Prometheus.sln

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio 15
3+
VisualStudioVersion = 15.0.27004.2006
4+
MinimumVisualStudioVersion = 15.0.26124.0
5+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{43141A2A-2C06-445D-A512-BEC49AAB9CFF}"
6+
EndProject
7+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.Monitoring.Prometheus", "src\Akka.Monitoring.Prometheus\Akka.Monitoring.Prometheus.csproj", "{BF0D52B2-BB31-4071-9E89-730FACEB5752}"
8+
EndProject
9+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.Monitoring.Prometheus.Demo", "src\Akka.Monitoring.Prometheus.Demo\Akka.Monitoring.Prometheus.Demo.csproj", "{F9A5B388-32E1-4F54-BF01-0358948F6102}"
10+
EndProject
11+
Global
12+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
13+
Debug|Any CPU = Debug|Any CPU
14+
Debug|x64 = Debug|x64
15+
Debug|x86 = Debug|x86
16+
Release|Any CPU = Release|Any CPU
17+
Release|x64 = Release|x64
18+
Release|x86 = Release|x86
19+
EndGlobalSection
20+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
21+
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22+
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Debug|Any CPU.Build.0 = Debug|Any CPU
23+
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Debug|x64.ActiveCfg = Debug|Any CPU
24+
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Debug|x64.Build.0 = Debug|Any CPU
25+
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Debug|x86.ActiveCfg = Debug|Any CPU
26+
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Debug|x86.Build.0 = Debug|Any CPU
27+
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Release|Any CPU.Build.0 = Release|Any CPU
29+
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Release|x64.ActiveCfg = Release|Any CPU
30+
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Release|x64.Build.0 = Release|Any CPU
31+
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Release|x86.ActiveCfg = Release|Any CPU
32+
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Release|x86.Build.0 = Release|Any CPU
33+
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34+
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Debug|Any CPU.Build.0 = Debug|Any CPU
35+
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Debug|x64.ActiveCfg = Debug|Any CPU
36+
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Debug|x64.Build.0 = Debug|Any CPU
37+
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Debug|x86.ActiveCfg = Debug|Any CPU
38+
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Debug|x86.Build.0 = Debug|Any CPU
39+
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Release|Any CPU.ActiveCfg = Release|Any CPU
40+
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Release|Any CPU.Build.0 = Release|Any CPU
41+
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Release|x64.ActiveCfg = Release|Any CPU
42+
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Release|x64.Build.0 = Release|Any CPU
43+
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Release|x86.ActiveCfg = Release|Any CPU
44+
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Release|x86.Build.0 = Release|Any CPU
45+
EndGlobalSection
46+
GlobalSection(SolutionProperties) = preSolution
47+
HideSolutionNode = FALSE
48+
EndGlobalSection
49+
GlobalSection(NestedProjects) = preSolution
50+
{BF0D52B2-BB31-4071-9E89-730FACEB5752} = {43141A2A-2C06-445D-A512-BEC49AAB9CFF}
51+
{F9A5B388-32E1-4F54-BF01-0358948F6102} = {43141A2A-2C06-445D-A512-BEC49AAB9CFF}
52+
EndGlobalSection
53+
GlobalSection(ExtensibilityGlobals) = postSolution
54+
SolutionGuid = {D35E7A11-B1AA-4562-AEC6-675C93991502}
55+
EndGlobalSection
56+
EndGlobal

CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at engineering@syncromatics.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Contributing
2+
3+
We are committed to fostering an open and welcoming environment. Please read our [code of conduct](CODE_OF_CONDUCT.md) before participating in or contributing to this project.
4+
5+
When contributing to this repository, we recommend discussing your feature, bug fix, or other contribution via an issue in this repository. If the change requires direct communication with the maintainers, send an email to engineering@syncromatics.com.
6+
7+
## Pull Request Process
8+
9+
1. Fork this repository
10+
2. Make the changes as you wish
11+
3. Submit a pull request back to this repository with a reference to the issue
12+
13+
### Process for Maintainers
14+
15+
1. Ensure that at least two maintainer reviewers have reviewed and approved the pull request
16+
2. Ensure that pull requests pass all applicable tests and successfully build the project
17+
3. Merge the pull request, and if applicable, clean up any merged branch

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Syncromatics Engineering
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Akka.Monitoring.Prometheus
2+
3+
[Monitoring system instrumentation](https://github.com/petabridge/akka-monitoring) in Prometheus for [Akka.NET](https://github.com/akkadotnet/akka.net) actor systems.
4+
5+
## Quickstart
6+
7+
### Add the `Akka.Monitoring.Prometheus` package to your project:
8+
9+
```bash
10+
dotnet add package Akka.Monitoring.Prometheus
11+
```
12+
13+
### Write code
14+
15+
1. Register the Prometheus monitor. From [Program](src/Akka.Monitoring.Prometheus.Demo/Program.cs):
16+
17+
```csharp
18+
var system = ActorSystem.Create("akka-performance-demo");
19+
20+
var didMonitorRegister = ActorMonitoringExtension.RegisterMonitor(system, new ActorPrometheusMonitor());
21+
```
22+
23+
2. Instrument your actor system as normal. From [PlutoActor](src/Akka.Monitoring.Prometheus.Demo/PlutoActor.cs):
24+
25+
```csharp
26+
Receive<string>(_ =>
27+
{
28+
Context.IncrementCounter("revolutions");
29+
Context.GetLogger().Debug("Whee!");
30+
Context.Gauge("revolutions.enjoyment", random.Next(1, 11));
31+
});
32+
```
33+
34+
For more information on instrumenting [Akka.NET](https://github.com/akkadotnet/akka.net) actor systems, please see [Akka.Monitoring](https://github.com/petabridge/akka-monitoring).
35+
36+
## Building
37+
38+
[![Travis](https://img.shields.io/travis/syncromatics/Akka.Monitoring.Prometheus.svg)](https://travis-ci.org/syncromatics/Akka.Monitoring.Prometheus)
39+
[![NuGet](https://img.shields.io/nuget/v/Akka.Monitoring.Prometheus.svg)](https://www.nuget.org/packages/Akka.Monitoring.Prometheus/)
40+
[![NuGet Pre Release](https://img.shields.io/nuget/vpre/Akka.Monitoring.Prometheus.svg)](https://www.nuget.org/packages/Akka.Monitoring.Prometheus/)
41+
42+
The package targets .NET Standard 2.0 and can be built via [.NET Core](https://www.microsoft.com/net/core):
43+
44+
```bash
45+
dotnet build
46+
```
47+
48+
## Code of Conduct
49+
50+
We are committed to fostering an open and welcoming environment. Please read our [code of conduct](CODE_OF_CONDUCT.md) before participating in or contributing to this project.
51+
52+
## Contributing
53+
54+
We welcome contributions and collaboration on this project. Please read our [contributor's guide](CONTRIBUTING.md) to understand how best to work with us.
55+
56+
## License and Authors
57+
58+
[![Syncromatics Engineering logo](https://en.gravatar.com/userimage/100017782/89bdc96d68ad4b23998e3cdabdeb6e13.png?size=16) Syncromatics Engineering](https://github.com/syncromatics)
59+
60+
[![license](https://img.shields.io/github/license/syncromatics/Akka.Monitoring.Prometheus.svg)](https://github.com/syncromatics/Akka.Monitoring.Prometheus/blob/master/LICENSE)
61+
[![GitHub contributors](https://img.shields.io/github/contributors/syncromatics/Akka.Monitoring.Prometheus.svg)](https://github.com/syncromatics/Akka.Monitoring.Prometheus/graphs/contributors)
62+
63+
This software is made available by Syncromatics Engineering under the MIT license.
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+
<TargetFrameworks>net462</TargetFrameworks>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\Akka.Monitoring.Prometheus\Akka.Monitoring.Prometheus.csproj" />
10+
</ItemGroup>
11+
12+
</Project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Akka.Actor;
2+
using Akka.Dispatch.SysMsg;
3+
using Akka.Event;
4+
5+
namespace Akka.Monitoring.Prometheus.Demo
6+
{
7+
public class CharonActor : ReceiveActor
8+
{
9+
public class ImYourMoon { }
10+
11+
public class WeGoRoundAndRound { }
12+
13+
public CharonActor()
14+
{
15+
Context.IncrementActorCreated();
16+
17+
Receive<IActorRef>(actor =>
18+
{
19+
Context.IncrementMessagesReceived();
20+
actor.Tell(new ImYourMoon());
21+
});
22+
23+
Receive<PlutoActor.YoureMyMoon>(_ =>
24+
{
25+
Context.IncrementMessagesReceived();
26+
Sender.Tell(new WeGoRoundAndRound());
27+
Context.GetLogger().Warning("From out here...");
28+
Self.Tell(PoisonPill.Instance);
29+
});
30+
31+
Receive<Stop>(_ =>
32+
{
33+
Context.IncrementActorStopped();
34+
});
35+
}
36+
}
37+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System;
2+
using System.Diagnostics;
3+
using Akka.Actor;
4+
using Akka.Dispatch.SysMsg;
5+
using Akka.Event;
6+
7+
namespace Akka.Monitoring.Prometheus.Demo
8+
{
9+
public class PlutoActor : ReceiveActor
10+
{
11+
private Stopwatch _stopwatch;
12+
13+
public class YoureMyMoon { }
14+
public PlutoActor()
15+
{
16+
Context.IncrementActorCreated();
17+
18+
var random = new Random();
19+
20+
Receive<CharonActor.ImYourMoon>(_ =>
21+
{
22+
Context.IncrementMessagesReceived();
23+
Sender.Tell(new YoureMyMoon());
24+
});
25+
26+
Receive<CharonActor.WeGoRoundAndRound>(_ =>
27+
{
28+
Context.IncrementMessagesReceived();
29+
_stopwatch = Stopwatch.StartNew();
30+
31+
Context.GetLogger().Info("Start \"revolving\"");
32+
var cancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(TimeSpan.Zero, TimeSpan.FromSeconds(1), Self, "revolve", Self);
33+
34+
Context.GetLogger().Info("Stop \"revolving\"");
35+
Context.System.Scheduler.ScheduleTellOnce(TimeSpan.FromSeconds(5), Self, cancelable, Self);
36+
});
37+
38+
Receive<string>(_ =>
39+
{
40+
Context.IncrementCounter("revolutions");
41+
Context.GetLogger().Debug("Whee!");
42+
Context.Gauge("revolutions.enjoyment", random.Next(1, 11));
43+
});
44+
45+
Receive<ICancelable>(cancelable =>
46+
{
47+
cancelable.Cancel();
48+
Context.Timing("revolutions.elapsed", _stopwatch.ElapsedMilliseconds);
49+
Context.GetLogger().Warning("... the rest of the world seems so small");
50+
Self.Tell(PoisonPill.Instance);
51+
});
52+
53+
Receive<Stop>(_ =>
54+
{
55+
Context.IncrementActorStopped();
56+
});
57+
}
58+
}
59+
}

0 commit comments

Comments
 (0)