Skip to content

Instantly share code, notes, and snippets.

View kerslake's full-sized avatar

Richard Kerslake kerslake

View GitHub Profile
NewRelic.Api.Agent.NewRelic.NoticeError(new Exception(“WorkerRole test exception”));
<system.diagnostics>
<trace>
<listeners>
<add
type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener,
Microsoft.WindowsAzure.Diagnostics,
Version=2.5.0.0,
Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
workflow Stop-VM
{
Param (
[parameter(Mandatory=$true)]
[String]
$VMName,
[parameter(Mandatory=$true)]
[String]
$ServiceName
workflow Start-VM
{
Param (
[parameter(Mandatory=$true)]
[String]
$VMName,
[parameter(Mandatory=$true)]
[String]
$ServiceName
void Main()
{
IObservable<PerformanceSample> performanceCounterObservable = PerfCounterObservable.FromRealTime(TimeSpan.FromSeconds(1), new[]{
@"\Processor(_Total)\% Processor Time",
@"\Memory(_Total)\% Committed Bytes In Use",
@"\Memory(_Total)\Available MBytes"})
.Take(6);
performanceCounterObservable.Subscribe(new PerfSampleObserver());
}
public class NewRelicLogger
{
public static void LogError(Exception ex, ErrorAction actionTaken, object parameters)
{
/* code omitted */
var errorDetails = Create(ex, ex.Message, ex.StackTrace, actionTaken, parameters);
LogToNewRelic(errorDetails);
public class TwilioRequestErrorFilter : ExceptionFilterAttribute
{
public override void OnException(HttpActionExecutedContext context)
{
/* code omitted */
var customException = context.Exception as CustomException;
var errorAction = customException == null ? ErrorAction.Escalate : customException.ErrorAction;
var parameters = context.ActionContext.ActionArguments.ToRequestParameters();
public static class FilterConfig
{
public static void Register(HttpConfiguration config)
{
config.Filters.Add(new TwilioRequestErrorFilter());
}
}
public class InvalidPinException : CustomException
{
/* code omitted */
public override ErrorAction ErrorAction
{
get
{
return ErrorAction.Ignore;
}
public class UserController : TwilioApiController
{
public HttpResponseMessage Post(VoiceRequest request, string pin)
{
var user = AuthenticationService.GetUser(pin);
var response = new TwilioResponse();
response.Say(string.Format("Hello {0}", user.Name));
response.Pause(2);
response.Hangup();