Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel James committed Nov 3, 2017
0 parents commit 43966cf
Show file tree
Hide file tree
Showing 14 changed files with 433 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vs
obj
bin
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: csharp

os: linux
dist: trusty
sudo: required
dotnet: 2.0.0

script:
- dotnet restore ./src/Akka.Monitoring.NewRelic
- dotnet build --configuration Release ./src/Akka.Monitoring.NewRelic
- "if [[ $TRAVIS_PULL_REQUEST == 'false' && $TRAVIS_TAG ]]; then
dotnet pack ./src/Akka.Monitoring.NewRelic --configuration Release /p:Version=$TRAVIS_TAG;
nuget push ./src/Akka.Monitoring.NewRelic/bin/Release/*.nupkg -ApiKey $NUGET_API_KEY;
fi"
56 changes: 56 additions & 0 deletions Akka.Monitoring.NewRelic.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2006
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{43141A2A-2C06-445D-A512-BEC49AAB9CFF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.Monitoring.NewRelic", "src\Akka.Monitoring.NewRelic\Akka.Monitoring.NewRelic.csproj", "{BF0D52B2-BB31-4071-9E89-730FACEB5752}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.Monitoring.NewRelic.Demo", "src\Akka.Monitoring.NewRelic.Demo\Akka.Monitoring.NewRelic.Demo.csproj", "{F9A5B388-32E1-4F54-BF01-0358948F6102}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Debug|x64.ActiveCfg = Debug|Any CPU
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Debug|x64.Build.0 = Debug|Any CPU
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Debug|x86.ActiveCfg = Debug|Any CPU
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Debug|x86.Build.0 = Debug|Any CPU
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Release|Any CPU.Build.0 = Release|Any CPU
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Release|x64.ActiveCfg = Release|Any CPU
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Release|x64.Build.0 = Release|Any CPU
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Release|x86.ActiveCfg = Release|Any CPU
{BF0D52B2-BB31-4071-9E89-730FACEB5752}.Release|x86.Build.0 = Release|Any CPU
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Debug|x64.ActiveCfg = Debug|Any CPU
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Debug|x64.Build.0 = Debug|Any CPU
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Debug|x86.ActiveCfg = Debug|Any CPU
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Debug|x86.Build.0 = Debug|Any CPU
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Release|Any CPU.Build.0 = Release|Any CPU
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Release|x64.ActiveCfg = Release|Any CPU
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Release|x64.Build.0 = Release|Any CPU
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Release|x86.ActiveCfg = Release|Any CPU
{F9A5B388-32E1-4F54-BF01-0358948F6102}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BF0D52B2-BB31-4071-9E89-730FACEB5752} = {43141A2A-2C06-445D-A512-BEC49AAB9CFF}
{F9A5B388-32E1-4F54-BF01-0358948F6102} = {43141A2A-2C06-445D-A512-BEC49AAB9CFF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D35E7A11-B1AA-4562-AEC6-675C93991502}
EndGlobalSection
EndGlobal
46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

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.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

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.

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.

## Scope

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.

## Enforcement

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.

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.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Contributing

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.

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.

## Pull Request Process

1. Fork this repository
2. Make the changes as you wish
3. Submit a pull request back to this repository with a reference to the issue

### Process for Maintainers

1. Ensure that at least two maintainer reviewers have reviewed and approved the pull request
2. Ensure that pull requests pass all applicable tests and successfully build the project
3. Merge the pull request, and if applicable, clean up any merged branch
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Syncromatics Engineering

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Akka.Monitoring.NewRelic

[Monitoring system instrumentation](https://github.com/petabridge/akka-monitoring) in New Relic for [Akka.NET](https://github.com/akkadotnet/akka.net) actor systems.

## Quickstart

Add the `Akka.Monitoring.NewRelic` package to your project:

```bash
dotnet add package Akka.Monitoring.NewRelic
```

Then instrument your actor system as normal.

From [PlutoActor](src/Akka.Monitoring.NewRelic.Demo/PlutoActor.cs):
```csharp
Receive<string>(_ =>
{
Context.IncrementCounter("revolutions");
Context.GetLogger().Debug("Whee!");
Context.Gauge("revolutions.enjoyment", random.Next(1, 11));
});
```

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).

## Building

[![Travis](https://img.shields.io/travis/syncromatics/Akka.Monitoring.NewRelic.svg)](https://travis-ci.org/syncromatics/Akka.Monitoring.NewRelic)
[![NuGet](https://img.shields.io/nuget/v/Akka.Monitoring.NewRelic.svg)](https://www.nuget.org/packages/Akka.Monitoring.NewRelic/)
[![NuGet Pre Release](https://img.shields.io/nuget/vpre/Akka.Monitoring.NewRelic.svg)](https://www.nuget.org/packages/Akka.Monitoring.NewRelic/)

The package targets .NET Standard 2.0 and can be built via [.NET Core](https://www.microsoft.com/net/core):

```bash
dotnet build
```

Because the standard New Relic agent (as of verion 6.18.139.0) does not (yet) support instrumenting .NET Core apps, the [demo program](src/Akka.Monitoring.NewRelic.Demo) targets .NET Framework 4.6.2.

## Code of Conduct

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.

## Contributing

We welcome contributions and collaboration on this project. Please read our [contributor's guide](CONTRIBUTING.md) to understand how best to work with us.

## License and Authors

[![Syncromatics Engineering logo](https://en.gravatar.com/userimage/100017782/89bdc96d68ad4b23998e3cdabdeb6e13.png?size=16) Syncromatics Engineering](https://github.com/syncromatics)

[![license](https://img.shields.io/github/license/syncromatics/Akka.Monitoring.NewRelic.svg)](https://github.com/syncromatics/Akka.Monitoring.NewRelic/blob/master/LICENSE)
[![GitHub contributors](https://img.shields.io/github/contributors/syncromatics/Akka.Monitoring.NewRelic.svg)](https://github.com/syncromatics/Akka.Monitoring.NewRelic/graphs/contributors)

This software is made available by Syncromatics Engineering under the MIT license.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net462</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Akka.Monitoring.NewRelic\Akka.Monitoring.NewRelic.csproj" />
</ItemGroup>

</Project>
37 changes: 37 additions & 0 deletions src/Akka.Monitoring.NewRelic.Demo/CharonActor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Akka.Actor;
using Akka.Dispatch.SysMsg;
using Akka.Event;

namespace Akka.Monitoring.NewRelic.Demo
{
public class CharonActor : ReceiveActor
{
public class ImYourMoon { }

public class WeGoRoundAndRound { }

public CharonActor()
{
Context.IncrementActorCreated();

Receive<IActorRef>(actor =>
{
Context.IncrementMessagesReceived();
actor.Tell(new ImYourMoon());
});

Receive<PlutoActor.YoureMyMoon>(_ =>
{
Context.IncrementMessagesReceived();
Sender.Tell(new WeGoRoundAndRound());
Context.GetLogger().Warning("From out here...");
Self.Tell(PoisonPill.Instance);
});

Receive<Stop>(_ =>
{
Context.IncrementActorStopped();
});
}
}
}
59 changes: 59 additions & 0 deletions src/Akka.Monitoring.NewRelic.Demo/PlutoActor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Diagnostics;
using Akka.Actor;
using Akka.Dispatch.SysMsg;
using Akka.Event;

namespace Akka.Monitoring.NewRelic.Demo
{
public class PlutoActor : ReceiveActor
{
private Stopwatch _stopwatch;

public class YoureMyMoon { }
public PlutoActor()
{
Context.IncrementActorCreated();

var random = new Random();

Receive<CharonActor.ImYourMoon>(_ =>
{
Context.IncrementMessagesReceived();
Sender.Tell(new YoureMyMoon());
});

Receive<CharonActor.WeGoRoundAndRound>(_ =>
{
Context.IncrementMessagesReceived();
_stopwatch = Stopwatch.StartNew();
Context.GetLogger().Info("Start \"revolving\"");
var cancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(TimeSpan.Zero, TimeSpan.FromSeconds(1), Self, "revolve", Self);
Context.GetLogger().Info("Stop \"revolving\"");
Context.System.Scheduler.ScheduleTellOnce(TimeSpan.FromSeconds(5), Self, cancelable, Self);
});

Receive<string>(_ =>
{
Context.IncrementCounter("revolutions");
Context.GetLogger().Debug("Whee!");
Context.Gauge("revolutions.enjoyment", random.Next(1, 11));
});

Receive<ICancelable>(cancelable =>
{
cancelable.Cancel();
Context.Timing("revolutions.elapsed", _stopwatch.ElapsedMilliseconds);
Context.GetLogger().Warning("... the rest of the world seems so small");
Self.Tell(PoisonPill.Instance);
});

Receive<Stop>(_ =>
{
Context.IncrementActorStopped();
});
}
}
}
39 changes: 39 additions & 0 deletions src/Akka.Monitoring.NewRelic.Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Threading;
using Akka.Actor;

namespace Akka.Monitoring.NewRelic.Demo
{
internal class Program
{
private static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Starting up actor system...");
var system = ActorSystem.Create("akka-performance-demo");

var registeredMonitor = ActorMonitoringExtension.RegisterMonitor(system, new ActorNewRelicMonitor());
Console.WriteLine(registeredMonitor
? "Successfully registered NewRelic monitor"
: "Failed to register New Relic monitor");

// Start up three sets of Pluto and Charon (reference to I'm Your Moon by Jonathan Coulton)
for (var i = 0; i < 3; i++)
{
var pluto = system.ActorOf<PlutoActor>();
var charon = system.ActorOf<CharonActor>();
charon.Tell(pluto);
}

Console.WriteLine("Waiting 60 seconds so the New Relic agent has time to harvest metrics");
Thread.Sleep(TimeSpan.FromSeconds(60));

Console.WriteLine("Shutting down...");
system.Terminate().Wait();
Console.WriteLine("Shutdown complete");

Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
}
7 changes: 7 additions & 0 deletions src/Akka.Monitoring.NewRelic.Demo/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="NewRelic.AgentEnabled" value="true" />
<add key="NewRelic.AppName" value="Akka.Monitoring.NewRelic.Demo" />
</appSettings>
</configuration>
Loading

0 comments on commit 43966cf

Please sign in to comment.