public void TestSubsegment() { _recorder.BeginSubsegment("subsegment1"); Subsegment subsegment1 = (Subsegment)TraceContext.GetEntity(); FacadeSegment facadeSegment = (FacadeSegment)subsegment1.RootSegment; _recorder.EndSubsegment(); Assert.AreEqual(facadeSegment.GetType(), typeof(FacadeSegment)); Assert.IsFalse(facadeSegment.Subsegments.Contains(subsegment1)); // only subsegment is streamed Assert.IsFalse(TraceContext.IsEntityPresent()); // facade segment is cleared from TraceContext }
protected override object Invoke(MethodInfo m, object[] args) { // If not tracing then call underlying method // as efficiently as possible. if (!shouldTrace(m)) { return(m.Invoke(_instance, args)); } try { _recorder.BeginSubsegment($"{m.DeclaringType.Name}.{m.Name}"); logArgs(m, args); // Invoke underlying method. var res = m.Invoke(_instance, args); // Post-process the result, which may // replace it in case of Tasks. var handler = _handlerCache.GetOrAdd(m.ReturnType, createResultHandler); res = handler(res); return(res); } catch (TargetInvocationException ex) { logException(ex.InnerException); _recorder.EndSubsegment(); throw ex.InnerException; } catch (Exception e) { logException(e); _recorder.EndSubsegment(); throw; } }
public void Dispose() { _xRayRecorder.EndSubsegment(); }