public void ErrorTelemetryEventsContainDetailedInfoOnTypedFault()
        {
            TestTelemetryChannel.Clear();
            var host = new HostingContext <SimpleService, ISimpleService>()
                       .ShouldWaitForCompletion();

            using (host)
            {
                host.Open();
                ISimpleService client = host.GetChannel();
                try
                {
                    client.CallFailsWithTypedFault();
                }
                catch
                {
                }
            }

            var error = (from item in TestTelemetryChannel.CollectedData()
                         where item is ExceptionTelemetry
                         select item).Cast <ExceptionTelemetry>().First();

            Assert.IsNotNull(error.Exception);
            Assert.IsNotNull(error.Context.Operation.Id);
            Assert.IsNotNull(error.Context.Operation.Name);
        }
        public void ErrorTelemetryEventsAreGeneratedOnExceptionAndIEDIF_True()
        {
            TestTelemetryChannel.Clear();
            var host = new HostingContext <SimpleService, ISimpleService>()
                       .ShouldWaitForCompletion()
                       .IncludeDetailsInFaults();

            using (host)
            {
                host.Open();

                ISimpleService client = host.GetChannel();
                try
                {
                    client.CallFailsWithException();
                }
                catch
                {
                }
            }

            var errors = from item in TestTelemetryChannel.CollectedData()
                         where item is ExceptionTelemetry
                         select item;

            Assert.IsTrue(errors.Count() > 0);
        }
        public void ErrorTelemetryEventsAreGeneratedOnAsyncExceptionAndIEDIF_False()
        {
            TestTelemetryChannel.Clear();
            var host = new HostingContext <AsyncService, IAsyncService>()
                       .ShouldWaitForCompletion();

            using (host)
            {
                host.Open();
                IAsyncService client = host.GetChannel();
                try
                {
                    client.FailWithExceptionAsync().Wait();
                }
                catch
                {
                }
            }

            var errors = from item in TestTelemetryChannel.CollectedData()
                         where item is ExceptionTelemetry
                         select item;

            Assert.IsTrue(errors.Count() > 0);
        }
Beispiel #4
0
        public void ResponseIsTraced()
        {
            TraceTelemetryModule.Enable();
            try
            {
                TestTelemetryChannel.Clear();
                using (var host = new HostingContext <SimpleService, ISimpleService>())
                {
                    host.Open();
                    ISimpleService client = host.GetChannel();
                    client.GetSimpleData();
                }

                var trace = TestTelemetryChannel.CollectedData()
                            .OfType <EventTelemetry>()
                            .FirstOrDefault(x => x.Name == "WcfResponse");
                Assert.IsNotNull(trace, "No WcfResponse trace found");
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(trace.Properties["Body"]);
            }
            finally
            {
                TraceTelemetryModule.Disable();
            }
        }
        public void IsClientSideContextReturnsFalseForServerChannel()
        {
            using (var host = new HostingContext <SimpleService, ISimpleService>())
            {
                host.Open();
                ISimpleService client = host.GetChannel();

                Assert.IsFalse(client.CallIsClientSideContext());
            }
        }
 public void TelemetryEventsAreGeneratedOnServiceCall()
 {
     TestTelemetryChannel.Clear();
     using (var host = new HostingContext <SimpleService, ISimpleService>())
     {
         host.Open();
         ISimpleService client = host.GetChannel();
         client.GetSimpleData();
         Assert.IsTrue(TestTelemetryChannel.CollectedData().Count > 0);
     }
 }
 public void TelemetryEventsAreGeneratedOnAsyncCall()
 {
     TestTelemetryChannel.Clear();
     using (var host = new HostingContext <AsyncService, IAsyncService>())
     {
         host.Open();
         IAsyncService client = host.GetChannel();
         client.GetDataAsync().Wait();
         Assert.IsTrue(TestTelemetryChannel.CollectedData().Count > 0);
     }
 }
Beispiel #8
0
 public void WhenOperationContextIsServiceContextReturnsRequest()
 {
     using (var host = new HostingContext <ContextCheckService, IContextCheckService>())
     {
         host.Open();
         var client = host.GetChannel();
         using (var scope = new OperationContextScope((IContextChannel)client))
         {
             Assert.IsTrue(client.CanGetRequestTelemetry());
         }
     }
 }
        public void IsClientSideContextReturnsTrueForClientChannel()
        {
            using (var host = new HostingContext <SimpleService, ISimpleService>())
            {
                host.Open();
                ISimpleService client = host.GetChannel();

                using (var scope = new OperationContextScope((IContextChannel)client))
                {
                    Assert.IsTrue(OperationContext.Current.IsClientSideContext());
                }
            }
        }
Beispiel #10
0
        public void CallsToOpMarkedWithOperationTelemetryGeneratesEvents()
        {
            TestTelemetryChannel.Clear();
            var host = new HostingContext <SelectiveTelemetryService, ISelectiveTelemetryService>();

            using ( host )
            {
                host.Open();

                ISelectiveTelemetryService client = host.GetChannel();
                client.OperationWithTelemetry();
            }
            Assert.IsTrue(TestTelemetryChannel.CollectedData().Count > 0);
        }
Beispiel #11
0
        public void CallsToOpWithoutOperationTelemetryGeneratesEvents()
        {
            TestTelemetryChannel.Clear();
            var host = new HostingContext <SelectiveTelemetryService, ISelectiveTelemetryService>();

            using ( host )
            {
                host.Open();

                ISelectiveTelemetryService client = host.GetChannel();
                client.OperationWithoutTelemetry();
            }
            Assert.AreEqual(0, TestTelemetryChannel.CollectedData().Count);
        }
Beispiel #12
0
 public void OperationMethodThatCallsAnotherServiceDoesNotLoseOperationContext()
 {
     TestTelemetryChannel.Clear();
     using (var host = new HostingContext <SimpleService, ISimpleService>())
         using (var hostSecond = new HostingContext <SimpleService, ISimpleService>())
         {
             host.IncludeDetailsInFaults();
             host.Open();
             hostSecond.Open();
             ISimpleService client = host.GetChannel();
             client.CallAnotherServiceAndLeakOperationContext(hostSecond.GetServiceAddress());
             Assert.IsTrue(TestTelemetryChannel.CollectedData().Count > 0);
         }
 }
        public void SuccessfulOneWayCallGeneratesRequestEvent()
        {
            TestTelemetryChannel.Clear();
            using (var host = new HostingContext <OneWayService, IOneWayService>())
            {
                host.Open();
                IOneWayService client = host.GetChannel();
                client.SuccessfullOneWayCall();
            }
            var req = TestTelemetryChannel.CollectedData()
                      .FirstOrDefault(x => x is RequestTelemetry);

            Assert.IsNotNull(req);
        }
Beispiel #14
0
        public void AllTelemetryEventsFromOneCallHaveSameOperationId()
        {
            TestTelemetryChannel.Clear();
            using (var host = new HostingContext <SimpleService, ISimpleService>())
            {
                host.Open();
                ISimpleService client = host.GetChannel();
                client.GetSimpleData();
            }
            var ids = TestTelemetryChannel.CollectedData()
                      .Select(x => x.Context.Operation.Id)
                      .Distinct();

            Assert.AreEqual(1, ids.Count());
        }
Beispiel #15
0
        public void OperationNameIsSetBasedOnOperationCalled()
        {
            TestTelemetryChannel.Clear();
            using (var host = new HostingContext <SimpleService, ISimpleService>())
            {
                host.Open();
                ISimpleService client = host.GetChannel();
                client.GetSimpleData();
            }
            var operationName = TestTelemetryChannel.CollectedData()
                                .Select(x => x.Context.Operation.Name)
                                .First();

            Assert.IsTrue(operationName.EndsWith("GetSimpleData", StringComparison.Ordinal));
        }
Beispiel #16
0
        public void OperationMarksRequestAsFailedAndIsPropagated()
        {
            TestTelemetryChannel.Clear();
            var host = new HostingContext <SimpleService, ISimpleService>();

            using ( host )
            {
                host.Open();

                ISimpleService client = host.GetChannel();
                client.CallMarksRequestAsFailed();
            }
            var request = TestTelemetryChannel.CollectedData().OfType <RequestTelemetry>().First();

            Assert.IsFalse(request.Success.Value);
        }
Beispiel #17
0
        public void TelemetryContextIsFlowedAccrossAsyncCalls()
        {
            TestTelemetryChannel.Clear();
            using (var host = new HostingContext <AsyncService, IAsyncService>())
            {
                host.Open();
                IAsyncService client = host.GetChannel();
                client.WriteDependencyEventAsync().Wait();
            }
            var data    = TestTelemetryChannel.CollectedData();
            var request = data
                          .OfType <RequestTelemetry>()
                          .First();
            var dependency = data
                             .OfType <DependencyTelemetry>()
                             .FirstOrDefault();

            Assert.AreEqual(request.Context.Operation.Id, dependency.Context.Operation.Id);
            Assert.AreEqual(request.Context.Operation.Name, dependency.Context.Operation.Name);
        }
Beispiel #18
0
        public void ErrorTelemetryEventsWrittenFromMethodAreLogged()
        {
            TestTelemetryChannel.Clear();
            var host = new HostingContext <SimpleService, ISimpleService>();

            using ( host )
            {
                host.Open();

                ISimpleService client = host.GetChannel();
                client.CallWritesExceptionEvent();
            }
            var request = TestTelemetryChannel.CollectedData().OfType <RequestTelemetry>().First();
            var errors  = from item in TestTelemetryChannel.CollectedData()
                          where item is ExceptionTelemetry
                          select item;

            Assert.IsTrue(errors.Count() > 0);
            Assert.AreEqual(request.Id, errors.First().Context.Operation.Id);
        }
Beispiel #19
0
        public void CallCanFlowRootOperationId()
        {
            TestTelemetryChannel.Clear();
            var host = new HostingContext <SelectiveTelemetryService, ISelectiveTelemetryService>();

            using ( host )
            {
                host.Open();

                ISelectiveTelemetryService client = host.GetChannel();
                using (var scope = new OperationContextScope((IContextChannel)client))
                {
                    var rootId = new RootIdMessageHeader();
                    rootId.RootId = "rootId";
                    OperationContext.Current.OutgoingMessageHeaders.Add(rootId);
                    client.OperationWithTelemetry();
                }
            }
            Assert.AreEqual("rootId", TestTelemetryChannel.CollectedData().First().Context.Operation.Id);
        }
Beispiel #20
0
        public void CallWithUnknownActionReportsCatchAllOperation()
        {
            TestTelemetryChannel.Clear();
            var host = new HostingContext <SimpleService, ISimpleService>();

            using ( host )
            {
                host.Open();

                ISimpleService client = host.GetChannel();
                using (OperationContextScope scope = new OperationContextScope((IContextChannel)client))
                {
                    OperationContext.Current.OutgoingMessageHeaders.Action = "http://someaction";
                    client.CatchAllOperation();
                }
            }
            var evt = TestTelemetryChannel.CollectedData().First();

            Assert.AreEqual("ISimpleService.CatchAllOperation", evt.Context.Operation.Name);
        }
        public void TelemetryEventsEmittedInsideServiceCallContainExpectedContext()
        {
            TestTelemetryChannel.Clear();
            using (var host = new HostingContext <SimpleService, ISimpleService>())
            {
                host.Open();
                ISimpleService client = host.GetChannel();
                client.CallThatEmitsEvent();

                var data    = TestTelemetryChannel.CollectedData();
                var request = data
                              .OfType <RequestTelemetry>()
                              .First();
                var customEvent = data
                                  .OfType <EventTelemetry>()
                                  .FirstOrDefault();
                Assert.IsNotNull(customEvent);
                Assert.AreEqual(request.Context.Operation.Id, customEvent.Context.Operation.Id);
                Assert.AreEqual(request.Context.Operation.Name, customEvent.Context.Operation.Name);
            }
        }
        public void FailedOneWayCallGeneratesExceptionEvent()
        {
            TestTelemetryChannel.Clear();
            var host = new HostingContext <OneWayService, IOneWayService>()
                       .ExpectFailure();

            using ( host )
            {
                host.Open();
                IOneWayService client = host.GetChannel();
                try
                {
                    client.FailureOneWayCall();
                } catch
                {
                }
            }
            var req = TestTelemetryChannel.CollectedData()
                      .FirstOrDefault(x => x is ExceptionTelemetry);

            Assert.IsNotNull(req);
        }