コード例 #1
0
 public void ShouldEndTraceSegments(
     [Frozen] IAWSXRayRecorder recorder,
     [Target] AwsXRayTracingService service
     )
 {
     service.StartTrace();
     service.EndTrace();
     recorder.Received().EndSegment();
 }
コード例 #2
0
            public void ShouldReturnTheCurrentTraceHeader(
                string id,
                [Frozen, Substitute] ITracingIdService tracingIdService,
                [Target] AwsXRayTracingService service
                )
            {
                tracingIdService.CreateId().Returns(id);
                tracingIdService.GetIdFromHeader(Any <string?>()).Returns(null as string);

                service.StartTrace();
                service.Header.Should().Be($"Root={id}; Sampled=1");
            }
コード例 #3
0
            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));
            }
コード例 #4
0
            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();
            }
コード例 #5
0
            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)
                    );
            }