public void Finish(object token, InstrumentationContext extraContext = null) { if (token == null) { return; // not meant to be instrumented prob due to sampling rate } try { var itoken = ValidateToken(token); if (ShouldInstrument(itoken.SamplingRate)) { foreach (var kv in _tracers) { kv.Value.Finish(itoken.TracerContexts[kv.Key], itoken.Kronometer.ElapsedMilliseconds, itoken.CorrelationId?.ToString(), extraContext); } } } catch (Exception e) { Console.WriteLine(e); if (_info.RaisePublishErrors) { throw; } } }
public void Finish(object token, long timeTakenMilli, string correlationId = null, InstrumentationContext extraContext = null) { var info = (IInstrumentationInfo)token; InstrumentationEventSource.Instance.WriteInstrumentationEvent(info.CategoryName, info.InstanceName, timeTakenMilli, correlationId, extraContext); }
public async Task InstrumentAsync(Func <Task> asyncAspect, double?samplingRate = null, InstrumentationContext extraContext = null) { var token = Start(samplingRate ?? _info.SamplingRate); try { await asyncAspect(); } finally { Finish(token, extraContext); } }
public void Instrument(Action aspect, double?samplingRate = null, InstrumentationContext extraContext = null) { var token = Start(samplingRate ?? _info.SamplingRate); try { aspect(); } finally { Finish(token, extraContext); } }
public void Finish(object token, long timeTakenMilli, string correlationId = null, InstrumentationContext extraContext = null) { var contexts = (Tuple <IEnumerable <PerfitHandlerContext>, Dictionary <string, object> >)token; CompleteContexts(contexts); }
public static void WriteInstrumentationEvent(this InstrumentationEventSource source, string categoryName, string instanceName, long timeTakenMilli, string correlationId = null, InstrumentationContext extraContext = null) { source.WriteInstrumentationEvent(categoryName ?? "NoCategory", instanceName ?? "NoInstance", timeTakenMilli, correlationId == null ? string.Empty : correlationId, extraContext?.Text1, extraContext?.Text2 ?? string.Empty, extraContext?.Numeric ?? 0, extraContext?.Decimal ?? 0); }