-
-
Notifications
You must be signed in to change notification settings - Fork 120
Add support for .NET Core #125
Comments
@polarina I tried porting it to core, but it felt like non-trivial. Looks like the CoreFX project still needs to update some legacy C# stuff for SharpRaven to work (for example: adding Environment.UserName dotnet/corefx#9851). It was thinking of manually sending HTTP requests to sentry to avoid using SharpRaven, but I don't see a tutorial for that. I guess I'll make the javascript report server errors since I'm doing an AspNet site. |
Anything new about .NET Core support? |
Any update on what needs to be done? I'm looking through the codebase now. |
@wakawaka54 I have no idea, to be honest. I've not started using .NET Core in any projects yet, so I don't know what the requirements are. |
Just FYI, I made a .NET Core port. You can add it to your .Net Core dependencies: {
"RavenSharp.Core": "1.0.0-beta-1"
} Then add the configuration to your "RavenOptions": {
"DSN": "dsnfromsentry"
} You need to configure your public void ConfigureServices(IServiceCollection services)
{
services.Configure<RavenOptions>(Configuration.GetSection("RavenOptions"));
//Add HTTPContextAccessor as Singleton
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
//Configure RavenClient
services.AddScoped<IRavenClient, RavenClient>((s) => {
var rc = new RavenClient(s.GetRequiredService<IOptions<RavenOptions>>(), s.GetRequiredService<IHttpContextAccessor>())
{
Environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")
};
return rc;
});
} You can then inject the I am not sure how we are going to merge this into the existing RavenSharp code base because I had to rewrite a lot of stuff. The tests had legacy C# stuff in them and the HttpContext stuff has all changed so I had to change all that. But that new port works well for me and I don't have any issues. |
@wakawaka54 I had the same idea of porting and my code end up very much like yours, but I got very upset tryng to make it compatible with net45, net451, netstandard15 and netstandard16, a lot of things I had comment like you did and I also had to rewrite the Requester, so I thought that it wouldn't be any far for been candidate to get merged. So I decided to create a 'Light' Version myself: RavenSharp Light I am still working on it and right now I am writing more information at the README.md. I copied the |
@wakawaka54: Awesome work! We can merge your changes into a new branch for now and publish releases from it with a new major version number. Then as we get feedback and feel the .NET Core is stable and sturdy, we can move the |
@wakawaka54 great, it works without any problems! :) |
@asbjornu Cool. Maybe I was wrong about what I thought. |
@wakawaka54 I would like to help porting the code too, if you need. My fork already compiles to the old .NET (NET45, NET451, NET46) and it also works very much like yours on netstandard1.6. The module part was removed at netstandard1.5, so I had to #if and remove it, so after your PR I could also help with that multi-platform compatibility. maybe! |
@asbjornu Okay a new branch sounds good. I can help rewrite and implement some of the tests I had to comment out. Mostly the tests that use the Are you going to make a new branch for me to merge into? |
@ricardoalcantara Okay sure. I like the idea of making a "light" version. However, Sentry.io has some requirements that they like their APIs to meet which is why you have all the Log Scrubbing stuff on there. It would be more of a challenge to get the .Net Core stuff to be backwards compatible with a lot of the older .Net releases, I am not sure if that's worth the extra effort. |
@wakawaka54 I meant I literally forked the Raven-CSharp . I stopped trying to migrate because I had a lot of troubles with Nancy, and I had to comment few things which I didn't feel comfortable with. I also didn't migrate the configuration you have done. |
I've created a |
Yeah that's something to look into. The biggest difficulty that I see with RavenSharp and using .NET Standard is |
Using this configuration:
It seems only 1 sentry message is captured per application start. First capture is sent to Sentry, every another one not. Something wrong with raven services configuration? EDIT The problem was this: I had this version in my project.json With this one it works ok! |
+1 |
@sabiland Yeah my bad, I'm a Nuget Noob and didn't think about it too much while I was uploading the package 😞 |
@wakawaka54 So it still has to be "RavenSharp.Core": "1.0.0-beta-1" right? |
Hi all, question for anyone who has got this working, I've followed @wakawaka54 's instructions, added the snippets in the right place.
I've added |
@AlexanderNZ: I haven't looked at the code and haven't even compiled a .NET Core project yet, but as the name of the project is |
I thought that too @asbjornu - I tried In the end I pulled I'm sure I'm just importing wrong, but I can't find any reference to how to import and use |
Any updates on this? I would really like to use Sentry for my .NET core web application. |
@raRaRa: We have #161 and #163 that tries to tackle the problem, but none of them are completed. I don't know what @wakawaka54 and @reflectiondm can say about the current status? |
Is there a plan to make implementations of EDIT: I added this as a separate issue. |
@jose-cf FWIW in my case I'm using https://github.com/ricardoalcantara/raven-csharp-light in the meantime. |
When coming? Almost :) |
Any update on this? We are also working on porting all our apps to Net Standard 2 for the libraries, and Net Core 2 for the apps; and really want to continue using Raven! |
Since #189 is merged, we now only need to get an AppVeyor build up and running. I'm working on it, but any help would be appreciated. |
How will we know which version it will be that will have this? Will it work for .NET Standard 2.0, and .NET Core 2.0 apps without requiring any framework modules to be added to the solution? |
I think #197 gives us what we want. I'll merge that and try to get a new pre-release package out over the next few days. |
Excellent! When it is available via NUGET, post on here, and I will pull it down and test it a lot next week as I am working on/testing my code migration! THANKS!!! |
SharpRaven version |
I have been testing it out this week on Net Standard 2.0 DLL's being used within a .NET Framework 4.6.2 application, as well as from within .NET Core 2.0 Microservices running within Docker on Linux, and everything has been running as expected, with appropriate logging being posted! |
@jjradke: I'm glad it works! Given your feedback and the 236 downloads of the beta so far, I think we can declare this done and done. Closing this as complete. Thanks for the patience everyone, I'm happy we finally nailed this and that you stuck with it for so long. |
Cool! @asbjornu any eta for 2.2.1 nuget without |
@davidroth: Minus 60 seconds. 😄 2.3 is out the door. |
@asbjornu Thank you. Looks like its working. :) |
Are there any examples that show how to set this up using ASP Core 2? e.g. ConfigureServices |
I've just tested it and it worked: using System;
using System.Collections.Generic;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using SharpRaven;
using SharpRaven.Data;
namespace AspNetCore
{
[Route("/throw")]
public class Program : Controller
{
[HttpGet("null")]
public void Get() => throw null;
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureServices(s =>
{
s.AddMvc();
s.AddSingleton<IRavenClient>(
new RavenClient(
dsn));
})
.Configure(a =>
{
a.Use(async (context, next) =>
{
try
{
await next.Invoke();
}
catch (Exception e)
{
var client = context.RequestServices.GetService<IRavenClient>();
if (client != null)
{
var id = await client.CaptureAsync(new SentryEvent(e));
if (id != null && !context.Response.HasStarted)
{
context.Response.Headers.TryAdd("X-Sentry-Id", id);
}
}
throw;
}
});
a.UseMvc();
})
.Build();
}
} Please note that Sentry will be working on providing a better experience for ASP.NET Core integration. |
@bruno-garcia Thanks, that works |
@bruno-garcia - Using your example, I created an extension class that will add that functionality using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using SharpRaven.Data;
namespace SharpRaven.Extensions
{
public static class SentryExtensions
{
public static void UseSentry(this IApplicationBuilder builder)
{
builder.Use(async (context, next) =>
{
try
{
await next.Invoke();
}
catch (Exception e)
{
var client = context.RequestServices.GetService<IRavenClient>();
if (client != null)
{
var id = await client.CaptureAsync(new SentryEvent(e));
if (id != null && !context.Response.HasStarted)
{
context.Response.Headers.TryAdd("X-Sentry-Id", id);
}
}
throw;
}
});
}
}
} startup.cs.Configure() ...
app.UseSentry();
... |
@razfriman our goal is to provide a package which will give you that experience. It'll be coming soon. |
@bruno-garcia Is that going to be a separate package specifically for ASP.Net core? Will it also populate sentry reports with request/response data? |
I've only been involved with the project for about a month but from what I see in the code: It already has support to extracting the payload. I also believe I read that the support to All of this could probably be validate by @asbjornu, but he's on vacation :D |
@bruno-garcia, that’s correct. :) |
@bruno-garcia Thanks for the feedback. I've started to integrate this into my asp.net core project. How do I integrate |
We've just released the first preview of the I would love to get some feedback as we work toward a major release: It's on NuGet: https://www.nuget.org/packages/Sentry.AspNetCore/ There's a video showing how to integrate in your solution: https://www.youtube.com/watch?v=xK6a1goK_w0 Release on GitHub: Docs: I'm online on Gitter: https://gitter.im/getsentry/dotnet |
Do you have any support for previous versions of .Net? 2.0 more precisely webforms? |
SharpRaven supports anything from .NET Framework 3.5 all the way to .NET Standard 2.0. Although for the latter we advise using our new SDK instead. |
So I could use SharpRaven in an asp net webforms application? no problem?
And when to the Sentry Api user and a good use? is there documentation with
C #
Att,
[image: cid:[email protected]]
*Eduardo Mendonça Braga**Skype:* [email protected]
*Slack:* eduardomendonca
www.smn.com.br
Rua Elias Sampaio Silva, 2060
Polo Industrial São Bernardo - Franca/SP
* (16) 3409-9514 / 3409-9513*
[image: microsoft-partner] *[image: gptw]* [image:
qrcode]
* "Para ter sucesso é necessário amar de verdade o que se faz!"*
2018-08-08 9:23 GMT-03:00 Bruno Garcia <[email protected]>:
… SharpRaven <https://www.nuget.org/packages/SharpRaven> supports anything
from *.NET Framework 3.5* all the way to .NET Standard 2.0. Although for
the latter we advise using our new SDK
<https://github.com/getsentry/sentry-dotnet/> instead.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#125 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Am_7bxq46CqUqawd265QHTh65QE1mpePks5uOtgvgaJpZM4I12_W>
.
|
Using SharpRaven with ASP.NET WebForms is a common use case. |
Hi,
Is it possible to get the ability to use this library with .NET Core?
Thanks in advance!
The text was updated successfully, but these errors were encountered: