public XRaySubsegment(IAWSXRayRecorder xRayRecorder, string subsegment) { _xRayRecorder = xRayRecorder; _xRayRecorder.BeginSubsegment(subsegment); _xRayRecorder.SetNamespace("remote"); }
public static XRaySegment Create(IAWSXRayRecorder xRayRecorder, string serviceName) { xRayRecorder.BeginSegment(serviceName); xRayRecorder.AddAnnotation("Environment", "Test"); xRayRecorder.AddAnnotation("Version", "1.0"); return(new XRaySegment(xRayRecorder)); }
public void ShouldThrowInvalidOperationExceptionIfNoTraceIsActive( [Frozen] IAWSXRayRecorder recorder, [Target] AwsXRayTracingService service ) { Action func = service.EndTrace; func.Should().Throw <InvalidOperationException>(); }
public void ShouldEndTraceSegments( [Frozen] IAWSXRayRecorder recorder, [Target] AwsXRayTracingService service ) { service.StartTrace(); service.EndTrace(); recorder.Received().EndSegment(); }
/// <summary> /// Create a tracing proxy around the given instance that implements TInterface. /// </summary> /// <typeparam name="TInterface"></typeparam> /// <param name="instance"></param> /// <param name="r"></param> /// <returns></returns> public static TInterface ProxyInstance <TInterface>( TInterface instance, IAWSXRayRecorder r = null, Options options = null) { var p = DispatchProxy.Create <TInterface, XrayProxy>(); (p as XrayProxy).Init(instance, r ?? AWSXRayRecorder.Instance, options ?? new Options()); return(p); }
public void ShouldThrowIfNoTraceIsActive( string name, string value, [Frozen] IAWSXRayRecorder recorder, [Target] AwsXRayTracingService service ) { Action func = () => service.AddMetadata(name, value); func.Should().Throw <InvalidOperationException>(); }
public static XRaySegment Create(IAWSXRayRecorder xRayRecorder, string serviceName, string traceHeader, SampleDecision sampleDecision = SampleDecision.Unknown) { GetSamplingDetails(xRayRecorder, serviceName, traceHeader, out string traceId, out SamplingResponse samplingResponse, out string parentId); xRayRecorder.BeginSegment( serviceName, traceId, parentId, sampleDecision == SampleDecision.Unknown ? samplingResponse : new SamplingResponse(sampleDecision)); xRayRecorder.AddAnnotation("Environment", "Test"); xRayRecorder.AddAnnotation("Version", "1.0"); return(new XRaySegment(xRayRecorder)); }
public void ShouldAddMetadata( string name, string value, [Frozen] IAWSXRayRecorder recorder, [Target] AwsXRayTracingService service ) { service.StartTrace(); service.AddMetadata(name, value); recorder.Received().AddMetadata(Is(name), Is(value)); }
/// <summary> /// If the entity is missing from the context, the behavior is defined using <see cref="ContextMissingStrategy"/> /// </summary> /// <param name="recorder"><see cref="IAWSXRayRecorder"/> instance</param> /// <param name="e">Instance of <see cref="Exception"/></param> /// <param name="message">String message</param> public void HandleEntityMissing(IAWSXRayRecorder recorder, Exception e, string message) { _logger.Error(e, message); if (recorder.ContextMissingStrategy == ContextMissingStrategy.LOG_ERROR) { _logger.DebugFormat("The ContextMissingStrategy is set to be LOG_ERROR. EntityNotAvailableException exception is suppressed."); } else { ExceptionDispatchInfo.Capture(e).Throw(); } }
public void ShouldStopTraceWhenContextIsDisposed( string header, string parentId, string traceId, [Frozen, Substitute] ITracingIdService tracingIdService, [Frozen, Substitute] IAWSXRayRecorder recorder, [Target] AwsXRayTracingService service ) { tracingIdService.CreateId().Returns(traceId); tracingIdService.GetIdFromHeader(Is(header)).Returns(parentId); using (var context = service.StartTrace(header)) { } recorder.Received().EndSegment(); }
public void ShouldStartSegmentWithNewId( string traceId, [Frozen, Substitute] ITracingIdService tracingIdService, [Frozen, Substitute] IAWSXRayRecorder recorder, [Target] AwsXRayTracingService service ) { tracingIdService.CreateId().Returns(traceId); tracingIdService.GetIdFromHeader(Any <string>()).Returns(null as string); service.StartTrace(); recorder.Received().BeginSegment( name: Is(AwsXRayTracingService.ServiceName), traceId: Is(traceId), parentId: Is(null as string), samplingResponse: Is <SamplingResponse>(response => response.SampleDecision == SampleDecision.Sampled) ); }
private static void GetSamplingDetails( IAWSXRayRecorder xRayRecorder, string serviceName, string traceHeader, out string traceId, out SamplingResponse samplingResponse, out string parentId) { if (TraceHeader.TryParse(traceHeader, out TraceHeader header)) { traceId = header.RootTraceId; samplingResponse = new SamplingResponse { SampleDecision = header.Sampled }; parentId = header.ParentId; } else { traceId = TraceId.NewId(); samplingResponse = xRayRecorder.SamplingStrategy.ShouldTrace(new SamplingInput { ServiceName = serviceName }); parentId = null; } }
public void HandleEntityMissing(IAWSXRayRecorder recorder, Exception e, string message) => throw new NotImplementedException();
public Handler( IAWSXRayRecorder recorder ) { this.recorder = recorder; }
public XRaySubsegmentFactory(IAWSXRayRecorder xRayRecorder) { _xRayRecorder = xRayRecorder; }
public void Init(object instance, IAWSXRayRecorder recorder, Options options) { _instance = instance; _recorder = recorder; Options = options; }
/// <summary> /// Default constructor that Lambda will invoke. /// </summary> public Functions(IAWSXRayRecorder xray = null) { this.xray = xray ?? AWSXRayRecorder.Instance; }
public void Initialize() { _recorder = new AWSXRayRecorder(); Environment.SetEnvironmentVariable(AWSXRayRecorder.LambdaTaskRootKey, "test"); Environment.SetEnvironmentVariable(AWSXRayRecorder.LambdaTraceHeaderKey, _traceHeaderValue); }
private XRaySegment(IAWSXRayRecorder xRayRecorder) { _xRayRecorder = xRayRecorder; }