Closed olsh closed 4 years ago
We don't have an OWIN integration yet. This is the second time it came up (the other outside of GH). Are you using WebAPI 1 or 2? Would you be willing to submit a PR to add support?
The error message you're showing is odd, also likely unrelated to OWIN. Could you please attach the JSON event? Are you using sentry.io or self hosted?
Hi @bruno-garcia, We are using WebAPI 2 and sentry.io. I'll submit a PR if I have time.
Thanks for sharing the event @olsh . I'm not sure why the timestamp is getting errored. Does it happen with all your events? I wonder if it's a event normalization regression on the backend or something with SDK event serialization or else. I dogfood the SDK with a couple of projects and those are not erroring with the timestamp at all.
If you're willing to contribute it would be great! feel free to open a draft PR with any sketch, we can collaborate on the idea etc. I believe it would be a new package Sentry.AspNet.WebApi
, what do you think?
Ideally Web API 2 and 1 but the least would be 2 since most apps are there I believe are on 2.0.
I get the error for all events in the project.
I believe it would be a new package Sentry.AspNet.WebApi, what do you think?
Yes, probably, you're right, I'll try to find time for the contribution. Sorry for misleading, we don't use OWIN, we use bare Web.API 2.
Not sure, but probably the issue is related to our Web.API serialization configuration
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
};
oh that would explain it. Strange because we ping the settings we use:
Well, I manage to reproduce the issue with the error.
public class WebApiApplication : HttpApplication
{
protected void Application_Start()
{
SentrySdk.Init("dsn");
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
};
GlobalConfiguration.Configure(WebApiConfig.Register);
}
}
Add an empty API controller with an action
public void Post([FromBody]string value)
{
try
{
throw new InvalidOperationException("Post");
}
catch (Exception e)
{
SentrySdk.CaptureException(e);
}
}
Run the curl command curl http://localhost:4839/api/default/post -d "'my payload'" -H "Content-Type: application/json"
P.S. it seems like the body capturing and the timestamp error are unrelated. The body is not captured even if I don't use MicrosoftDateFormat.
Yeah we don't support HTTP extraction for Web API projects yet. But you mentioned you get Headers? Oh and it's not OWIN?
So it's System.Web, we get the headers here.
Did you configure it to extract values?
This is an opt-in.
With regards to the JSON configuration, it's just unfortunate that this static
DefaultSettings affects the serializer the SDK uses even though it passes explicit configuration to it.
Is it possible to configure Web API JSON settings via some instance base settings object? As opposed to this static global configuration?
Hi @bruno-garcia,
Thanks for pointing me out. Indeed, I need to set RequestSize.Always
for MaxRequestBodySize
.
The old Raven SDK captured the body by default, so I missed this. Updated the issue title.
2.0.2 is out with this fix: https://github.com/getsentry/sentry-dotnet/releases/tag/2.0.2
Please mark the type framework used:
Please mark the type of the runtime used:
[x] .NET Framework
[ ] Mono
[ ] .NET Core
Version:
Please mark the NuGet packages used:
[x] Sentry
[x] Sentry.Serilog
[ ] Sentry.NLog
[ ] Sentry.Log4Net
[ ] Sentry.Extensions.Logging
[ ] Sentry.AspNetCore
Version: 2.0.1
When we are trying to log an event, an HTTP body is not recorded. I can see HTTP headers, though. There is an error in the Sentry event
I suppose that the issue was in the old SDK (Raven) too.