This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: (171 commits) Let's set the next version to 2.0 Makefile: add `--debug' switch when running tests on mono in order to get better stack traces Fix a NRE in ExceptionFrame.cs when StackFrame.GetMethod() returns null Added documentation about the Exception.Data support Documenting the ErrorOnCapture property of SharpRaven. Fixed indentation in documentation I quite like var Added SentryEvent Add the net40 flag to SharpRaven.Nancy.UnitTests and check for it in the LogModule Added missing ticks in documentation Updated documentation Added docs to solution items Use CaptureMessageAsync() in the async Nancy test Changed the obsoleted CaptureEvent() methods to cause compile time warnings Change CaptureMessage() and its async counterpart to use IDictionary<,> instead of Dictionary<,>. Removed the Dsn parameter from RavenClient.SendAsync() so it's consistent with the Send() method. Fixed "messge" typo Casing matters How about Travis invoking make so we don't have to duplicate stuff in both make and Travis? Install NUnit.Runners v2.6.4 and update the path in the Makefile to reference the correct version. ...
- Loading branch information
Showing
81 changed files
with
4,750 additions
and
953 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ obj/ | |
!/src/packages/repositories.config | ||
/TestResult.xml | ||
docs/_build | ||
.vs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
language: csharp | ||
solution: src/SharpRaven.sln | ||
sudo: false | ||
install: | ||
- make | ||
script: | ||
- make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
next-version: 2.0 | ||
branches: | ||
feature[/-]: | ||
mode: ContinuousDeployment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
test: | ||
mono --runtime=v4.0.30319 ".nuget/NuGet.exe" Restore "src" | ||
build: setup-nuget restore | ||
|
||
setup-nuget: | ||
mkdir -p .nuget | ||
wget -O .nuget/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe | ||
|
||
restore: | ||
mono --runtime=v4.0.30319 ".nuget/nuget.exe" Restore "src" | ||
|
||
test: restore | ||
xbuild "./src/SharpRaven.build" | ||
mono --runtime=v4.0.30319 ./src/packages/NUnit.Runners.2.6.3/tools/nunit-console.exe ./src/tests/SharpRaven.UnitTests/bin/Release/net45/SharpRaven.UnitTests.dll -exclude=NuGet,NoMono -nodots | ||
mono --debug --runtime=v4.0.30319 ./src/packages/NUnit.Runners.2.6.4/tools/nunit-console.exe ./src/tests/SharpRaven.UnitTests/bin/Release/net45/SharpRaven.UnitTests.dll -exclude=NuGet,NoMono -nodots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
Usage | ||
===== | ||
Instantiate the client with your DSN: | ||
|
||
```csharp | ||
var ravenClient = new RavenClient("http://public:[email protected]/project-id"); | ||
``` | ||
|
@@ -31,24 +32,128 @@ ravenClient.CaptureMessage("Hello World!"); | |
|
||
Additional Data | ||
--------------- | ||
The capture methods allow you to provide additional data to be sent with your request. CaptureException supports both the | ||
`tags` and `extra` properties, and CaptureMessage additionally supports the `level` property. | ||
You can add additional data to the [`Exception.Data`](https://msdn.microsoft.com/en-us/library/system.exception.data.aspx) | ||
property on exceptions thrown about in your solution: | ||
|
||
```csharp | ||
try | ||
{ | ||
// ... | ||
} | ||
catch (Exception exception) | ||
{ | ||
exception.Data.Add("SomeKey", "SomeValue"); | ||
throw; | ||
} | ||
``` | ||
|
||
The data `SomeKey` and `SomeValue` will be captured and presented in the `extra` property on Sentry. | ||
|
||
Additionally, the capture methods allow you to provide additional data to be sent with your request. | ||
`CaptureException` supports both the `tags` and `extra` properties, and `CaptureMessage` additionally | ||
supports the `level` property. | ||
|
||
The full argument specs are: | ||
|
||
```csharp | ||
CaptureException(Exception e, IDictionary<string, string> tags = null, object extra = null) | ||
CaptureMessage(string message, ErrorLevel level = ErrorLevel.info, Dictionary<string, string> tags = null, object extra = null) | ||
string CaptureException(Exception exception, | ||
SentryMessage message = null, | ||
ErrorLevel level = ErrorLevel.Error, | ||
IDictionary<string, string> tags = null, | ||
string[] fingerprint = null, | ||
object extra = null) | ||
|
||
string CaptureMessage(SentryMessage message, | ||
ErrorLevel level = ErrorLevel.Info, | ||
IDictionary<string, string> tags = null, | ||
string[] fingerprint = null, | ||
object extra = null) | ||
|
||
``` | ||
|
||
Async Support | ||
------------- | ||
In the .NET 4.5 build of SharpRaven, there are `async` versions of the above methods as well: | ||
|
||
```csharp | ||
Task<string> CaptureExceptionAsync(Exception exception, | ||
SentryMessage message = null, | ||
ErrorLevel level = ErrorLevel.Error, | ||
IDictionary<string, string> tags = null, | ||
string[] fingerprint = null, | ||
object extra = null); | ||
|
||
Task<string> CaptureMessageAsync(SentryMessage message, | ||
ErrorLevel level = ErrorLevel.Info, | ||
IDictionary<string, string> tags = null, | ||
string[] fingerprint = null, | ||
object extra = null); | ||
``` | ||
|
||
Nancy Support | ||
------------- | ||
You can install the [SharpRaven.Nancy](https://www.nuget.org/packages/SharpRaven.Nancy) package to capture the HTTP context | ||
in [Nancy](http://nancyfx.org/) applications. It will auto-register on the `IPipelines.OnError` event, so all unhandled | ||
exceptions will be sent to Sentry. | ||
|
||
The only thing you have to do is provide a DSN, either by registering an instance of the `Dsn` class in your container: | ||
|
||
```csharp | ||
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) | ||
{ | ||
container.Register(new Dsn("http://public:[email protected]/project-id")); | ||
} | ||
``` | ||
|
||
or through configuration: | ||
|
||
```xml | ||
<configuration> | ||
<configSections> | ||
<section name="sharpRaven" type="SharpRaven.Nancy.NancyConfiguration, SharpRaven.Nancy" /> | ||
</configSections> | ||
<sharpRaven> | ||
<dsn value="http://public:[email protected]/project-id" /> | ||
</sharpRaven> | ||
</configuration> | ||
``` | ||
|
||
The DSN will be picked up by the auto-registered `IRavenClient` instance, so if you want to send events to | ||
Sentry, all you have to do is add a requirement on `IRavenClient` in your classes: | ||
|
||
```csharp | ||
public class LoggingModule : NancyModule | ||
{ | ||
private readonly IRavenClient ravenClient; | ||
|
||
public LoggingModule(IRavenClient ravenClient) | ||
{ | ||
this.ravenClient = ravenClient; | ||
} | ||
} | ||
```` | ||
|
||
Debugging SharpRaven | ||
-------------------- | ||
|
||
If an exception is raised internally to `RavenClient` it is logged to the Console. To extend this behaviour use | ||
the property `ErrorOnCapture`: | ||
|
||
```csharp | ||
ravenClient.ErrorOnCapture = exception => { | ||
// custom code here | ||
}; | ||
```` | ||
|
||
|
||
Get it! | ||
------- | ||
You can clone and build SharpRaven yourself, but for those of us who are happy with prebuilt binaries, there's [a NuGet package](https://www.nuget.org/packages/SharpRaven). | ||
Resources | ||
--------- | ||
* [Build Status](http://teamcity.codebetter.com/project.html?projectId=project344&tab=projectOverview) (requires registration) | ||
* [![Build Status](http://teamcity.codebetter.com/app/rest/builds/buildType:(id:bt1000)/statusIcon)](http://teamcity.codebetter.com/viewType.html?buildTypeId=bt1000&guest=1) | ||
* [![Join the chat at https://gitter.im/getsentry/raven-csharp](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/getsentry/raven-csharp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
* [Code](http://github.com/getsentry/raven-csharp) | ||
* [Mailing List](https://groups.google.com/group/getsentry) | ||
* [IRC](irc://irc.freenode.net/sentry) (irc.freenode.net, #sentry) | ||
* [![Join the chat at https://gitter.im/getsentry/raven-csharp](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/getsentry/raven-csharp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
* [IRC](irc://irc.freenode.net/sentry) (irc.freenode.net, #sentry) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,22 @@ You can capture a message without being bound by an exception: | |
Additional Data | ||
--------------- | ||
|
||
You can add additional data to the `Exception.Data <https://msdn.microsoft.com/en-us/library/system.exception.data.aspx>` | ||
property on exceptions thrown about in your solution: | ||
|
||
.. sourcecode:: csharp | ||
|
||
try | ||
{ | ||
// ... | ||
} | ||
catch (Exception exception) | ||
{ | ||
exception.Data.Add("SomeKey", "SomeValue"); | ||
throw; | ||
} | ||
|
||
|
||
The capture methods allow you to provide additional data to be sent with | ||
your request. ``CaptureException`` supports both the ``tags`` and extra | ||
``properties``, and ``CaptureMessage`` additionally supports the | ||
|
@@ -70,13 +86,85 @@ The full argument specs are: | |
|
||
.. sourcecode:: csharp | ||
|
||
CaptureException(Exception e, | ||
IDictionary<string, string> tags = null, | ||
object extra = null) | ||
CaptureMessage(string message, | ||
ErrorLevel level = ErrorLevel.info, | ||
Dictionary<string, string> tags = null, | ||
object extra = null) | ||
string CaptureException(Exception exception, | ||
SentryMessage message = null, | ||
ErrorLevel level = ErrorLevel.Error, | ||
IDictionary<string, string> tags = null, | ||
string[] fingerprint = null, | ||
object extra = null) | ||
|
||
string CaptureMessage(SentryMessage message, | ||
ErrorLevel level = ErrorLevel.Info, | ||
IDictionary<string, string> tags = null, | ||
string[] fingerprint = null, | ||
object extra = null) | ||
|
||
|
||
Async Support | ||
------------- | ||
In the .NET 4.5 build of SharpRaven, there are ``async`` versions of the | ||
above methods as well: | ||
|
||
.. sourcecode:: csharp | ||
|
||
Task<string> CaptureExceptionAsync(Exception exception, | ||
SentryMessage message = null, | ||
ErrorLevel level = ErrorLevel.Error, | ||
IDictionary<string, string> tags = null, | ||
string[] fingerprint = null, | ||
object extra = null); | ||
|
||
Task<string> CaptureMessageAsync(SentryMessage message, | ||
ErrorLevel level = ErrorLevel.Info, | ||
IDictionary<string, string> tags = null, | ||
string[] fingerprint = null, | ||
object extra = null); | ||
|
||
Nancy Support | ||
------------- | ||
You can install the `SharpRaven.Nancy <https://www.nuget.org/packages/SharpRaven.Nancy>`_ | ||
package to capture the HTTP context in `Nancy <http://nancyfx.org/>`_ applications. It | ||
will auto-register on the ``IPipelines.OnError`` event, so all unhandled exceptions will be | ||
sent to Sentry. | ||
|
||
The only thing you have to do is provide a DSN, either by registering an instance of the | ||
``Dsn`` class in your container: | ||
|
||
.. sourcecode:: csharp | ||
|
||
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) | ||
{ | ||
container.Register(new Dsn("http://public:[email protected]/project-id")); | ||
} | ||
|
||
or through configuration: | ||
|
||
.. sourcecode:: xml | ||
|
||
<configuration> | ||
<configSections> | ||
<section name="sharpRaven" type="SharpRaven.Nancy.NancyConfiguration, SharpRaven.Nancy" /> | ||
</configSections> | ||
<sharpRaven> | ||
<dsn value="http://public:[email protected]/project-id" /> | ||
</sharpRaven> | ||
</configuration> | ||
|
||
The DSN will be picked up by the auto-registered ``IRavenClient`` instance, so if you want to send events to | ||
Sentry, all you have to do is add a requirement on ``IRavenClient`` in your classes: | ||
|
||
.. sourcecode:: csharp | ||
|
||
public class LoggingModule : NancyModule | ||
{ | ||
private readonly IRavenClient ravenClient; | ||
|
||
public LoggingModule(IRavenClient ravenClient) | ||
{ | ||
this.ravenClient = ravenClient; | ||
} | ||
} | ||
|
||
|
||
Resources | ||
--------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="NUnit.Runners" version="2.6.4" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#region License | ||
|
||
// Copyright (c) 2014 The Sentry Team and individual contributors. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without modification, are permitted | ||
// provided that the following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this list of | ||
// conditions and the following disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of | ||
// conditions and the following disclaimer in the documentation and/or other materials | ||
// provided with the distribution. | ||
// | ||
// 3. Neither the name of the Sentry nor the names of its contributors may be used to | ||
// endorse or promote products derived from this software without specific prior written | ||
// permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
#endregion | ||
|
||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly : AssemblyDescription("SharpRaven is a C# client for Sentry https://www.getsentry.com")] | ||
[assembly : AssemblyCompany("Sentry")] | ||
[assembly : AssemblyProduct("SharpRaven")] | ||
[assembly : AssemblyCopyright("Copyright © Sentry")] | ||
[assembly : ComVisible(false)] |
Oops, something went wrong.