示例#1
0
        public void WhenInitializeEndpoint3IsCalled_BehaviorIsAdded()
        {
            ServiceEndpoint endpoint = CreateEndpoint();

            endpoint.Address = new EndpointAddress("http://localhost/Service1.svc");
            using (ChannelFactory factory = new ChannelFactory <ISimpleService>(endpoint))
            {
                var module = new WcfDependencyTrackingTelemetryModule();
                module.Initialize(TelemetryConfiguration.Active);

                var wcfProcessing = new ProfilerWcfClientProcessing(module);
                wcfProcessing.OnEndInitializeEndpoint3(null, null, factory, null, null, null);

                var behavior = endpoint.Behaviors.Find <ClientTelemetryEndpointBehavior>();
                Assert.IsNotNull(behavior, "Behavior was not added to endpoint");
            }
        }
        private void DoInitialization(TelemetryConfiguration configuration)
        {
            this.TelemetryClient = new TelemetryClient(configuration);
            if (string.IsNullOrEmpty(this.RootOperationIdHeaderName))
            {
                this.RootOperationIdHeaderName = CorrelationHeaders.HttpStandardRootIdHeader;
            }

            if (string.IsNullOrEmpty(this.ParentOperationIdHeaderName))
            {
                this.ParentOperationIdHeaderName = CorrelationHeaders.HttpStandardParentIdHeader;
            }

            if (this.SoapHeaderNamespace == null)
            {
                this.SoapHeaderNamespace = CorrelationHeaders.SoapStandardNamespace;
            }

            if (string.IsNullOrEmpty(this.SoapParentOperationIdHeaderName))
            {
                this.SoapParentOperationIdHeaderName = CorrelationHeaders.SoapStandardParentIdHeader;
            }

            if (string.IsNullOrEmpty(this.SoapRootOperationIdHeaderName))
            {
                this.SoapRootOperationIdHeaderName = CorrelationHeaders.SoapStandardRootIdHeader;
            }

            if (Decorator.IsHostEnabled())
            {
                WcfClientEventSource.Log.ClientDependencyTrackingInfo("Profiler is attached");
                WcfClientEventSource.Log.ClientDependencyTrackingInfo("Agent version: " + Decorator.GetAgentVersion());
                if (!this.DisableRuntimeInstrumentation)
                {
                    this.wcfClientProcessing = new ProfilerWcfClientProcessing(this);
                    this.DecorateProfilerForWcfClientProcessing();
                }
                else
                {
                    WcfClientEventSource.Log.ClientDependencyTrackingInfo("Runtime Instrumentation is disabled.");
                }
            }
        }
示例#3
0
        public void WhenInitializeEndpoint1IsCalled_AndBehaviorExists_BehaviorIsNotAdded()
        {
            ServiceEndpoint endpoint = CreateEndpoint();

            endpoint.Address = new EndpointAddress("http://localhost/Service1.svc");
            endpoint.Behaviors.Add(new ClientTelemetryEndpointBehavior(TelemetryConfiguration.Active));

            using (ChannelFactory factory = new ChannelFactory <ISimpleService>(endpoint))
            {
                var module = new WcfDependencyTrackingTelemetryModule();
                module.Initialize(TelemetryConfiguration.Active);

                var wcfProcessing = new ProfilerWcfClientProcessing(module);
                wcfProcessing.OnEndInitializeEndpoint1(null, null, factory, null);

                var numBehaviors = endpoint.Behaviors.OfType <ClientTelemetryEndpointBehavior>().Count();
                Assert.AreEqual(1, numBehaviors, "Behavior was added to endpoint twice");
            }
        }