Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Commit 2b94249

Browse files
committed
Merge branch 'develop'
* 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. ...
2 parents 930d02f + 6bae19b commit 2b94249

81 files changed

Lines changed: 4750 additions & 953 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ obj/
1313
!/src/packages/repositories.config
1414
/TestResult.xml
1515
docs/_build
16+
.vs

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: csharp
2+
solution: src/SharpRaven.sln
3+
sudo: false
4+
install:
5+
- make
6+
script:
7+
- make test

GitVersionConfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
next-version: 2.0
12
branches:
23
feature[/-]:
34
mode: ContinuousDeployment

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
test:
2-
mono --runtime=v4.0.30319 ".nuget/NuGet.exe" Restore "src"
1+
build: setup-nuget restore
2+
3+
setup-nuget:
4+
mkdir -p .nuget
5+
wget -O .nuget/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
6+
7+
restore:
8+
mono --runtime=v4.0.30319 ".nuget/nuget.exe" Restore "src"
9+
10+
test: restore
311
xbuild "./src/SharpRaven.build"
4-
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
12+
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

README.md

Lines changed: 112 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Usage
22
=====
33
Instantiate the client with your DSN:
4+
45
```csharp
56
var ravenClient = new RavenClient("http://public:secret@example.com/project-id");
67
```
@@ -31,24 +32,128 @@ ravenClient.CaptureMessage("Hello World!");
3132

3233
Additional Data
3334
---------------
34-
The capture methods allow you to provide additional data to be sent with your request. CaptureException supports both the
35-
`tags` and `extra` properties, and CaptureMessage additionally supports the `level` property.
35+
You can add additional data to the [`Exception.Data`](https://msdn.microsoft.com/en-us/library/system.exception.data.aspx)
36+
property on exceptions thrown about in your solution:
37+
38+
```csharp
39+
try
40+
{
41+
// ...
42+
}
43+
catch (Exception exception)
44+
{
45+
exception.Data.Add("SomeKey", "SomeValue");
46+
throw;
47+
}
48+
```
49+
50+
The data `SomeKey` and `SomeValue` will be captured and presented in the `extra` property on Sentry.
51+
52+
Additionally, the capture methods allow you to provide additional data to be sent with your request.
53+
`CaptureException` supports both the `tags` and `extra` properties, and `CaptureMessage` additionally
54+
supports the `level` property.
3655

3756
The full argument specs are:
3857

3958
```csharp
40-
CaptureException(Exception e, IDictionary<string, string> tags = null, object extra = null)
41-
CaptureMessage(string message, ErrorLevel level = ErrorLevel.info, Dictionary<string, string> tags = null, object extra = null)
59+
string CaptureException(Exception exception,
60+
SentryMessage message = null,
61+
ErrorLevel level = ErrorLevel.Error,
62+
IDictionary<string, string> tags = null,
63+
string[] fingerprint = null,
64+
object extra = null)
65+
66+
string CaptureMessage(SentryMessage message,
67+
ErrorLevel level = ErrorLevel.Info,
68+
IDictionary<string, string> tags = null,
69+
string[] fingerprint = null,
70+
object extra = null)
71+
72+
```
73+
74+
Async Support
75+
-------------
76+
In the .NET 4.5 build of SharpRaven, there are `async` versions of the above methods as well:
77+
78+
```csharp
79+
Task<string> CaptureExceptionAsync(Exception exception,
80+
SentryMessage message = null,
81+
ErrorLevel level = ErrorLevel.Error,
82+
IDictionary<string, string> tags = null,
83+
string[] fingerprint = null,
84+
object extra = null);
85+
86+
Task<string> CaptureMessageAsync(SentryMessage message,
87+
ErrorLevel level = ErrorLevel.Info,
88+
IDictionary<string, string> tags = null,
89+
string[] fingerprint = null,
90+
object extra = null);
91+
```
92+
93+
Nancy Support
94+
-------------
95+
You can install the [SharpRaven.Nancy](https://www.nuget.org/packages/SharpRaven.Nancy) package to capture the HTTP context
96+
in [Nancy](http://nancyfx.org/) applications. It will auto-register on the `IPipelines.OnError` event, so all unhandled
97+
exceptions will be sent to Sentry.
98+
99+
The only thing you have to do is provide a DSN, either by registering an instance of the `Dsn` class in your container:
100+
101+
```csharp
102+
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
103+
{
104+
container.Register(new Dsn("http://public:secret@example.com/project-id"));
105+
}
42106
```
43107

108+
or through configuration:
109+
110+
```xml
111+
<configuration>
112+
<configSections>
113+
<section name="sharpRaven" type="SharpRaven.Nancy.NancyConfiguration, SharpRaven.Nancy" />
114+
</configSections>
115+
<sharpRaven>
116+
<dsn value="http://public:secret@example.com/project-id" />
117+
</sharpRaven>
118+
</configuration>
119+
```
120+
121+
The DSN will be picked up by the auto-registered `IRavenClient` instance, so if you want to send events to
122+
Sentry, all you have to do is add a requirement on `IRavenClient` in your classes:
123+
124+
```csharp
125+
public class LoggingModule : NancyModule
126+
{
127+
private readonly IRavenClient ravenClient;
128+
129+
public LoggingModule(IRavenClient ravenClient)
130+
{
131+
this.ravenClient = ravenClient;
132+
}
133+
}
134+
````
135+
136+
Debugging SharpRaven
137+
--------------------
138+
139+
If an exception is raised internally to `RavenClient` it is logged to the Console. To extend this behaviour use
140+
the property `ErrorOnCapture`:
141+
142+
```csharp
143+
ravenClient.ErrorOnCapture = exception => {
144+
// custom code here
145+
};
146+
````
147+
148+
44149
Get it!
45150
-------
46151
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).
47152
48153
Resources
49154
---------
50-
* [Build Status](http://teamcity.codebetter.com/project.html?projectId=project344&tab=projectOverview) (requires registration)
155+
* [![Build Status](http://teamcity.codebetter.com/app/rest/builds/buildType:(id:bt1000)/statusIcon)](http://teamcity.codebetter.com/viewType.html?buildTypeId=bt1000&guest=1)
156+
* [![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)
51157
* [Code](http://github.com/getsentry/raven-csharp)
52158
* [Mailing List](https://groups.google.com/group/getsentry)
53-
* [IRC](irc://irc.freenode.net/sentry) (irc.freenode.net, #sentry)
54-
* [![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)
159+
* [IRC](irc://irc.freenode.net/sentry) (irc.freenode.net, #sentry)

docs/index.rst

Lines changed: 95 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ You can capture a message without being bound by an exception:
6161
Additional Data
6262
---------------
6363

64+
You can add additional data to the `Exception.Data <https://msdn.microsoft.com/en-us/library/system.exception.data.aspx>`
65+
property on exceptions thrown about in your solution:
66+
67+
.. sourcecode:: csharp
68+
69+
try
70+
{
71+
// ...
72+
}
73+
catch (Exception exception)
74+
{
75+
exception.Data.Add("SomeKey", "SomeValue");
76+
throw;
77+
}
78+
79+
6480
The capture methods allow you to provide additional data to be sent with
6581
your request. ``CaptureException`` supports both the ``tags`` and extra
6682
``properties``, and ``CaptureMessage`` additionally supports the
@@ -70,13 +86,85 @@ The full argument specs are:
7086

7187
.. sourcecode:: csharp
7288

73-
CaptureException(Exception e,
74-
IDictionary<string, string> tags = null,
75-
object extra = null)
76-
CaptureMessage(string message,
77-
ErrorLevel level = ErrorLevel.info,
78-
Dictionary<string, string> tags = null,
79-
object extra = null)
89+
string CaptureException(Exception exception,
90+
SentryMessage message = null,
91+
ErrorLevel level = ErrorLevel.Error,
92+
IDictionary<string, string> tags = null,
93+
string[] fingerprint = null,
94+
object extra = null)
95+
96+
string CaptureMessage(SentryMessage message,
97+
ErrorLevel level = ErrorLevel.Info,
98+
IDictionary<string, string> tags = null,
99+
string[] fingerprint = null,
100+
object extra = null)
101+
102+
103+
Async Support
104+
-------------
105+
In the .NET 4.5 build of SharpRaven, there are ``async`` versions of the
106+
above methods as well:
107+
108+
.. sourcecode:: csharp
109+
110+
Task<string> CaptureExceptionAsync(Exception exception,
111+
SentryMessage message = null,
112+
ErrorLevel level = ErrorLevel.Error,
113+
IDictionary<string, string> tags = null,
114+
string[] fingerprint = null,
115+
object extra = null);
116+
117+
Task<string> CaptureMessageAsync(SentryMessage message,
118+
ErrorLevel level = ErrorLevel.Info,
119+
IDictionary<string, string> tags = null,
120+
string[] fingerprint = null,
121+
object extra = null);
122+
123+
Nancy Support
124+
-------------
125+
You can install the `SharpRaven.Nancy <https://www.nuget.org/packages/SharpRaven.Nancy>`_
126+
package to capture the HTTP context in `Nancy <http://nancyfx.org/>`_ applications. It
127+
will auto-register on the ``IPipelines.OnError`` event, so all unhandled exceptions will be
128+
sent to Sentry.
129+
130+
The only thing you have to do is provide a DSN, either by registering an instance of the
131+
``Dsn`` class in your container:
132+
133+
.. sourcecode:: csharp
134+
135+
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
136+
{
137+
container.Register(new Dsn("http://public:secret@example.com/project-id"));
138+
}
139+
140+
or through configuration:
141+
142+
.. sourcecode:: xml
143+
144+
<configuration>
145+
<configSections>
146+
<section name="sharpRaven" type="SharpRaven.Nancy.NancyConfiguration, SharpRaven.Nancy" />
147+
</configSections>
148+
<sharpRaven>
149+
<dsn value="http://public:secret@example.com/project-id" />
150+
</sharpRaven>
151+
</configuration>
152+
153+
The DSN will be picked up by the auto-registered ``IRavenClient`` instance, so if you want to send events to
154+
Sentry, all you have to do is add a requirement on ``IRavenClient`` in your classes:
155+
156+
.. sourcecode:: csharp
157+
158+
public class LoggingModule : NancyModule
159+
{
160+
private readonly IRavenClient ravenClient;
161+
162+
public LoggingModule(IRavenClient ravenClient)
163+
{
164+
this.ravenClient = ravenClient;
165+
}
166+
}
167+
80168

81169
Resources
82170
---------

src/.nuget/packages.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="NUnit.Runners" version="2.6.4" />
4+
</packages>

src/Build.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ echo === NuGet Pack ===
3030
echo =====================
3131
echo.
3232
NuGet pack app\SharpRaven\SharpRaven.csproj -Properties ReleaseNotes='Test'
33+
NuGet pack app\SharpRaven.Nancy\SharpRaven.Nancy.csproj -Properties ReleaseNotes='Test'
3334
echo.
3435
ENDLOCAL

src/CommonAssemblyInfo.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#region License
2+
3+
// Copyright (c) 2014 The Sentry Team and individual contributors.
4+
// All rights reserved.
5+
//
6+
// Redistribution and use in source and binary forms, with or without modification, are permitted
7+
// provided that the following conditions are met:
8+
//
9+
// 1. Redistributions of source code must retain the above copyright notice, this list of
10+
// conditions and the following disclaimer.
11+
//
12+
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
13+
// conditions and the following disclaimer in the documentation and/or other materials
14+
// provided with the distribution.
15+
//
16+
// 3. Neither the name of the Sentry nor the names of its contributors may be used to
17+
// endorse or promote products derived from this software without specific prior written
18+
// permission.
19+
//
20+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
21+
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22+
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26+
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27+
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
29+
#endregion
30+
31+
using System.Reflection;
32+
using System.Runtime.InteropServices;
33+
34+
[assembly : AssemblyDescription("SharpRaven is a C# client for Sentry https://www.getsentry.com")]
35+
[assembly : AssemblyCompany("Sentry")]
36+
[assembly : AssemblyProduct("SharpRaven")]
37+
[assembly : AssemblyCopyright("Copyright © Sentry")]
38+
[assembly : ComVisible(false)]

0 commit comments

Comments
 (0)