Skip to content

Instantly share code, notes, and snippets.

@bruno-garcia
bruno-garcia / enumerator-measure.cs
Created September 10, 2021 03:01
sentry measure IEnumerator
// measure enumeration:
//Where each enumeration is a result of a potentially coslty operation such as a DB cursor read
foreach (var group in groups.Measure())
{
// work
}
//Code:

Installation

Create a Sentry module in <jboss-path>/modules/io/sentry/main/module.xml:

<?xml version='1.0' encoding='UTF-8'?>
<module xmlns="urn:jboss:module:1.1" name="io.sentry">
  <resources>
    <resource-root path="sentry-4.3.0.jar"/>
 
https://github.com/Aminator/UwpWithoutVisualStudio
<PropertyGroup>
<TargetFrameworks>net5.0;netcoreapp3.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net5.0-windows10.0.18362.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net5.0-windows10.0.18362.0'">
<!-- <TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>-->
<!-- <TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>-->
@bruno-garcia
bruno-garcia / gist:860f8b61d857183989b989c869d777bb
Created May 13, 2021 23:16
msbuild task: wait for file to exist
<WaitFor FilePath="$(MSBuildProjectDirectory)/../../samples/unity-of-bugs/Library/ScriptAssemblies/UnityEngine.TestRunner.dll" Delay="5000" />
<UsingTask
TaskName="WaitFor"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
<ParameterGroup>
<FilePath ParameterType="System.String" Required="true" />
<Delay ParameterType="System.Int32" Required="true" />
using System;
using System.Globalization;
using System.IO;
using Sentry.Extensibility;
using Sentry.Protocol;
public class FileAppenderDiagnosticLogger : IDiagnosticLogger
{
private readonly SentryLevel _minimalLevel;
private readonly StreamWriter _writer;
https://550e76353f1b41f7899e32875f22f08c@sentry.io/1512778
// Modifying root scope
Sentry.setTag("a","a");
// Creates a new scope and pushes in the stap, a clone of the previous one.
Sentry.pushScope();
// Here we have a tag a with value a
Sentry.setTag("a","b");
// Now a has value b
// Throw away the current scope (goes back to the previous item in the stack)
Sentry.popScope();
// Now tag a has value a
@bruno-garcia
bruno-garcia / link.xml
Created October 8, 2018 14:39
link.xml for Unity IL2CPP to work with Newtonsoft.Json (Tested with the Sentry SDK https://github.com/getsentry/sentry-dotnet)
@bruno-garcia
bruno-garcia / ASP.NET Core middleware return Exception as text on response body
Created August 12, 2018 13:46
ASP.NET Core middleware which return Exception as text on response body (useful when using swagger UI to test API in development instead of default HTML view)
using System;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
internal class ExceptionInResponseMiddleware
{
private readonly RequestDelegate _next;
@echo off
for /f %%a in ('dir /b *.sln 2^> nul') do set sln=%%a
if defined sln set sln=%cd%\%sln%
start "" /b "C:\Program Files (x86)\Microsoft Visual Studio\Preview\Community\Common7\IDE\devenv.exe" %sln%